com.googlecode.mp4parser.authoring.builder
Class FragmentedMp4Builder

java.lang.Object
  extended by com.googlecode.mp4parser.authoring.builder.FragmentedMp4Builder
All Implemented Interfaces:
Mp4Builder

public class FragmentedMp4Builder
extends Object
implements Mp4Builder

Creates a fragmented MP4 file.


Field Summary
protected  FragmentIntersectionFinder intersectionFinder
           
 
Constructor Summary
FragmentedMp4Builder()
           
 
Method Summary
 IsoFile build(Movie movie)
          Builds the actual IsoFile from the Movie.
protected  DataInformationBox createDinf(Movie movie, Track track)
           
 Box createFtyp(Movie movie)
           
protected  Box createMdat(long startSample, long endSample, Track track, int i)
           
protected  Box createMdhd(Movie movie, Track track)
           
protected  Box createMdia(Track track, Movie movie)
           
protected  Box createMdiaHdlr(Track track, Movie movie)
           
protected  Box createMfhd(long startSample, long endSample, Track track, int sequenceNumber)
           
protected  Box createMfra(Movie movie, IsoFile isoFile)
          Creates a 'mfra' - movie fragment random access box for the given movie in the given isofile.
protected  Box createMinf(Track track, Movie movie)
           
protected  Box createMoof(long startSample, long endSample, Track track, int sequenceNumber)
          Creates a 'moof' box for a given sequence of samples.
protected  List<Box> createMoofMdat(Movie movie)
           
protected  Box createMoov(Movie movie)
          Creates a fully populated 'moov' box with all child boxes.
protected  Box createMvex(Movie movie)
          Creates a 'mvex' - movie extends box and populates it with 'trex' boxes by calling createTrex(com.googlecode.mp4parser.authoring.Movie, com.googlecode.mp4parser.authoring.Track) for each track to generate them
protected  Box createMvhd(Movie movie)
          Creates a single 'mvhd' movie header box for a given movie.
protected  Box createStbl(Movie movie, Track track)
           
protected  Box createTfhd(long startSample, long endSample, Track track, int sequenceNumber)
           
protected  Box createTfra(Track track, IsoFile isoFile)
          Creates a 'tfra' - track fragment random access box for the given track with the isoFile.
protected  Box createTkhd(Movie movie, Track track)
           
protected  Box createTraf(long startSample, long endSample, Track track, int sequenceNumber)
           
protected  Box createTrak(Track track, Movie movie)
           
protected  Box createTrex(Movie movie, Track track)
           
protected  List<? extends Box> createTruns(long startSample, long endSample, Track track, int sequenceNumber)
          Creates one or more track run boxes for a given sequence.
 List<String> getAllowedHandlers()
           
protected  long getDuration(Track track)
           
 FragmentIntersectionFinder getFragmentIntersectionFinder()
           
protected  List<ByteBuffer> getSamples(long startSample, long endSample, Track track, int sequenceNumber)
          Gets the all samples starting with startSample (one based -> one is the first) and ending with endSample (exclusive).
protected  long[] getSampleSizes(long startSample, long endSample, Track track, int sequenceNumber)
          Gets the sizes of a sequence of samples-
 void setIntersectionFinder(FragmentIntersectionFinder intersectionFinder)
           
protected  List<Track> sortTracksInSequence(List<Track> tracks, int cycle, Map<Track,long[]> intersectionMap)
          Some formats require sorting of the fragments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

intersectionFinder

protected FragmentIntersectionFinder intersectionFinder
Constructor Detail

FragmentedMp4Builder

public FragmentedMp4Builder()
Method Detail

getAllowedHandlers

public List<String> getAllowedHandlers()

createFtyp

public Box createFtyp(Movie movie)

sortTracksInSequence

protected List<Track> sortTracksInSequence(List<Track> tracks,
                                           int cycle,
                                           Map<Track,long[]> intersectionMap)
Some formats require sorting of the fragments. E.g. Ultraviolet CFF files are required to contain the fragments size sort: make this fragment:
  1. video[1]
  2. audio[1]
  3. subs[1]
  4. audio[2]
  5. video[2]
  6. subs[2]

Parameters:
tracks - the list of tracks to returned sorted
cycle - current fragment (sorting may vary between the fragments)
intersectionMap - a map from tracks to their fragments' first samples.
Returns:
the list of tracks in order of appearance in the fragment

createMoofMdat

protected List<Box> createMoofMdat(Movie movie)

build

public IsoFile build(Movie movie)
Builds the actual IsoFile from the Movie.

Specified by:
build in interface Mp4Builder
Parameters:
movie - data source
Returns:
the freshly built IsoFile

createMdat

protected Box createMdat(long startSample,
                         long endSample,
                         Track track,
                         int i)

createTfhd

protected Box createTfhd(long startSample,
                         long endSample,
                         Track track,
                         int sequenceNumber)

createMfhd

protected Box createMfhd(long startSample,
                         long endSample,
                         Track track,
                         int sequenceNumber)

createTraf

protected Box createTraf(long startSample,
                         long endSample,
                         Track track,
                         int sequenceNumber)

getSamples

protected List<ByteBuffer> getSamples(long startSample,
                                      long endSample,
                                      Track track,
                                      int sequenceNumber)
Gets the all samples starting with startSample (one based -> one is the first) and ending with endSample (exclusive).

Parameters:
startSample - low endpoint (inclusive) of the sample sequence
endSample - high endpoint (exclusive) of the sample sequence
track - source of the samples
sequenceNumber - the fragment index of the requested list of samples
Returns:
a List<ByteBuffer> of raw samples

getSampleSizes

protected long[] getSampleSizes(long startSample,
                                long endSample,
                                Track track,
                                int sequenceNumber)
Gets the sizes of a sequence of samples-

Parameters:
startSample - low endpoint (inclusive) of the sample sequence
endSample - high endpoint (exclusive) of the sample sequence
track - source of the samples
sequenceNumber - the fragment index of the requested list of samples
Returns:

createTruns

protected List<? extends Box> createTruns(long startSample,
                                          long endSample,
                                          Track track,
                                          int sequenceNumber)
Creates one or more track run boxes for a given sequence.

Parameters:
startSample - low endpoint (inclusive) of the sample sequence
endSample - high endpoint (exclusive) of the sample sequence
track - source of the samples
sequenceNumber - the fragment index of the requested list of samples
Returns:
the list of TrackRun boxes.

createMoof

protected Box createMoof(long startSample,
                         long endSample,
                         Track track,
                         int sequenceNumber)
Creates a 'moof' box for a given sequence of samples.

Parameters:
startSample - low endpoint (inclusive) of the sample sequence
endSample - high endpoint (exclusive) of the sample sequence
track - source of the samples
sequenceNumber - the fragment index of the requested list of samples
Returns:
the list of TrackRun boxes.

createMvhd

protected Box createMvhd(Movie movie)
Creates a single 'mvhd' movie header box for a given movie.

Parameters:
movie - the concerned movie
Returns:
an 'mvhd' box

createMoov

protected Box createMoov(Movie movie)
Creates a fully populated 'moov' box with all child boxes. Child boxes are:

Parameters:
movie - the concerned movie
Returns:
fully populated 'moov'

createTfra

protected Box createTfra(Track track,
                         IsoFile isoFile)
Creates a 'tfra' - track fragment random access box for the given track with the isoFile. The tfra contains a map of random access points with time as key and offset within the isofile as value.

Parameters:
track - the concerned track
isoFile - the track is contained in
Returns:
a track fragment random access box.

createMfra

protected Box createMfra(Movie movie,
                         IsoFile isoFile)
Creates a 'mfra' - movie fragment random access box for the given movie in the given isofile. Uses createTfra(com.googlecode.mp4parser.authoring.Track, com.coremedia.iso.IsoFile) to generate the child boxes.

Parameters:
movie - concerned movie
isoFile - concerned isofile
Returns:
a complete 'mfra' box

createTrex

protected Box createTrex(Movie movie,
                         Track track)

createMvex

protected Box createMvex(Movie movie)
Creates a 'mvex' - movie extends box and populates it with 'trex' boxes by calling createTrex(com.googlecode.mp4parser.authoring.Movie, com.googlecode.mp4parser.authoring.Track) for each track to generate them

Parameters:
movie - the source movie
Returns:
a complete 'mvex'

createTkhd

protected Box createTkhd(Movie movie,
                         Track track)

createMdhd

protected Box createMdhd(Movie movie,
                         Track track)

createStbl

protected Box createStbl(Movie movie,
                         Track track)

createMinf

protected Box createMinf(Track track,
                         Movie movie)

createMdiaHdlr

protected Box createMdiaHdlr(Track track,
                             Movie movie)

createMdia

protected Box createMdia(Track track,
                         Movie movie)

createTrak

protected Box createTrak(Track track,
                         Movie movie)

createDinf

protected DataInformationBox createDinf(Movie movie,
                                        Track track)

getFragmentIntersectionFinder

public FragmentIntersectionFinder getFragmentIntersectionFinder()

setIntersectionFinder

public void setIntersectionFinder(FragmentIntersectionFinder intersectionFinder)

getDuration

protected long getDuration(Track track)


Copyright © 2012. All Rights Reserved.