public class FragmentedMp4Writer extends DefaultBoxes implements SampleSink
acceptSample(StreamingSample, StreamingTrack).
It has to be closed (close()) actively to trigger the write of remaining buffered
samples and the footer.| Modifier and Type | Class and Description |
|---|---|
class |
FragmentedMp4Writer.FragmentContainer |
| Modifier and Type | Field and Description |
|---|---|
protected Map<StreamingTrack,CountDownLatch> |
congestionControl |
protected Date |
creationTime |
protected Map<StreamingTrack,Queue<FragmentedMp4Writer.FragmentContainer>> |
fragmentBuffers
Buffers segements until it's time for a segment to be written.
|
protected Map<StreamingTrack,Long> |
nextFragmentCreateStartTime
Contains the start time of the next segment in line that will be created.
|
protected Map<StreamingTrack,Long> |
nextFragmentWriteStartTime
Contains the start time of the next segment in line that will be written.
|
protected Map<StreamingTrack,Long> |
nextSampleStartTime
Contains the next sample's start time.
|
static Object |
OBJ |
protected Map<StreamingTrack,List<StreamingSample>> |
sampleBuffers
Buffers the samples per track until there are enough samples to form a Segment.
|
protected long |
sequenceNumber |
protected WritableByteChannel |
sink |
protected List<StreamingTrack> |
source |
protected Map<StreamingTrack,long[]> |
tfraOffsets |
protected Map<StreamingTrack,long[]> |
tfraTimes |
| Constructor and Description |
|---|
FragmentedMp4Writer(List<StreamingTrack> source,
WritableByteChannel sink) |
| Modifier and Type | Method and Description |
|---|---|
void |
acceptSample(StreamingSample streamingSample,
StreamingTrack streamingTrack)
Adds a samples to the SampleSink.
|
void |
close()
Writes the remaining samples to file (even though the typical condition for wrapping up
a segment have not yet been met) and writes the MovieFragmentRandomAccessBox.
|
protected Box[] |
createFooter() |
protected Box[] |
createFragment(StreamingTrack streamingTrack,
List<StreamingSample> samples) |
protected Box[] |
createHeader() |
protected Box |
createMdhd(StreamingTrack streamingTrack) |
protected Box |
createMoov() |
protected Box |
createMvex() |
protected Box |
createMvhd() |
protected void |
createTfdt(StreamingTrack streamingTrack,
TrackFragmentBox parent) |
protected void |
createTfhd(StreamingTrack streamingTrack,
TrackFragmentBox parent) |
protected Box |
createTfra(StreamingTrack track)
Creates a 'tfra' - track fragment random access box for the given track with the isoFile.
|
protected Box |
createTrex(StreamingTrack streamingTrack) |
protected void |
createTrun(StreamingTrack streamingTrack,
TrackFragmentBox parent,
List<StreamingSample> samples) |
protected boolean |
isFragmentReady(StreamingTrack streamingTrack,
StreamingSample next)
Tests if the currently received samples for a given track
form a valid fragment taking the latest received sample into
account.
|
protected void |
write(WritableByteChannel out,
Box... boxes) |
protected void |
writeFooter(Box... boxes)
Writes the given boxes.
|
protected void |
writeFragment(Box... boxes)
Writes the given boxes.
|
protected void |
writeHeader(Box... boxes)
Writes the given boxes.
|
createDinf, createFtyp, createMdia, createMdiaHdlr, createMinf, createStbl, createTkhd, createTrakpublic static final Object OBJ
protected final WritableByteChannel sink
protected List<StreamingTrack> source
protected Date creationTime
protected long sequenceNumber
protected Map<StreamingTrack,CountDownLatch> congestionControl
protected Map<StreamingTrack,Long> nextFragmentCreateStartTime
protected Map<StreamingTrack,Long> nextFragmentWriteStartTime
protected Map<StreamingTrack,Long> nextSampleStartTime
protected Map<StreamingTrack,List<StreamingSample>> sampleBuffers
protected Map<StreamingTrack,Queue<FragmentedMp4Writer.FragmentContainer>> fragmentBuffers
protected Map<StreamingTrack,long[]> tfraOffsets
protected Map<StreamingTrack,long[]> tfraTimes
public FragmentedMp4Writer(List<StreamingTrack> source, WritableByteChannel sink) throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface SampleSinkIOException - if writing to the underlying data sink failsMovieFragmentRandomAccessBoxprotected void write(WritableByteChannel out, Box... boxes) throws IOException
IOExceptionprotected Box createMdhd(StreamingTrack streamingTrack)
createMdhd in class DefaultBoxesprotected Box createMvex()
protected Box createTrex(StreamingTrack streamingTrack)
protected Box createMvhd()
createMvhd in class DefaultBoxesprotected Box createMoov()
protected Box[] createHeader()
public void acceptSample(StreamingSample streamingSample, StreamingTrack streamingTrack) throws IOException
SampleSinkStreamingTrack must be ready and accept calls to any method.acceptSample in interface SampleSinkIOException - if writing (or reading) fails.protected boolean isFragmentReady(StreamingTrack streamingTrack, StreamingSample next)
streamingTrack - track to testnext - the lastest samplesprotected Box[] createFragment(StreamingTrack streamingTrack, List<StreamingSample> samples)
protected void writeHeader(Box... boxes) throws IOException
boxes - any number of boxes that form the headerIOException - when writing to the sink fails.FileTypeBox,
ProgressiveDownloadInformationBox,
MovieBox,
SegmentIndexBoxprotected void writeFragment(Box... boxes) throws IOException
boxes - any number of boxes that form fragmentIOException - when writing to the sink fails.MovieFragmentBox,
MediaDataBox,
SegmentTypeBox,
SegmentIndexBoxprotected void writeFooter(Box... boxes) throws IOException
boxes - any number of boxes to conclude the file.IOException - when writing to the sink fails.MovieFragmentRandomAccessBoxprotected void createTfhd(StreamingTrack streamingTrack, TrackFragmentBox parent)
protected void createTfdt(StreamingTrack streamingTrack, TrackFragmentBox parent)
protected void createTrun(StreamingTrack streamingTrack, TrackFragmentBox parent, List<StreamingSample> samples)
protected Box[] createFooter()
protected Box createTfra(StreamingTrack track)
track - the concerned trackCopyright © 2018. All rights reserved.