java.io.Closeable, java.lang.AutoCloseable, SampleSinkpublic 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 | Description |
|---|---|---|
class |
FragmentedMp4Writer.FragmentContainer |
| Modifier and Type | Field | Description |
|---|---|---|
protected java.util.Map<StreamingTrack,java.util.concurrent.CountDownLatch> |
congestionControl |
|
protected java.util.Date |
creationTime |
|
protected java.util.Map<StreamingTrack,java.util.Queue<FragmentedMp4Writer.FragmentContainer>> |
fragmentBuffers |
Buffers segements until it's time for a segment to be written.
|
protected java.util.Map<StreamingTrack,java.lang.Long> |
nextFragmentCreateStartTime |
Contains the start time of the next segment in line that will be created.
|
protected java.util.Map<StreamingTrack,java.lang.Long> |
nextFragmentWriteStartTime |
Contains the start time of the next segment in line that will be written.
|
protected java.util.Map<StreamingTrack,java.lang.Long> |
nextSampleStartTime |
Contains the next sample's start time.
|
static java.lang.Object |
OBJ |
|
protected java.util.Map<StreamingTrack,java.util.List<StreamingSample>> |
sampleBuffers |
Buffers the samples per track until there are enough samples to form a Segment.
|
protected long |
sequenceNumber |
|
protected java.nio.channels.WritableByteChannel |
sink |
|
protected java.util.List<StreamingTrack> |
source |
|
protected java.util.Map<StreamingTrack,long[]> |
tfraOffsets |
|
protected java.util.Map<StreamingTrack,long[]> |
tfraTimes |
| Constructor | Description |
|---|---|
FragmentedMp4Writer(java.util.List<StreamingTrack> source,
java.nio.channels.WritableByteChannel sink) |
| Modifier and Type | Method | 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 org.mp4parser.Box[] |
createFooter() |
|
protected org.mp4parser.Box[] |
createFragment(StreamingTrack streamingTrack,
java.util.List<StreamingSample> samples) |
|
protected org.mp4parser.Box[] |
createHeader() |
|
protected org.mp4parser.Box |
createMdhd(StreamingTrack streamingTrack) |
|
protected org.mp4parser.Box |
createMoov() |
|
protected org.mp4parser.Box |
createMvex() |
|
protected org.mp4parser.Box |
createMvhd() |
|
protected void |
createTfdt(StreamingTrack streamingTrack,
org.mp4parser.boxes.iso14496.part12.TrackFragmentBox parent) |
|
protected void |
createTfhd(StreamingTrack streamingTrack,
org.mp4parser.boxes.iso14496.part12.TrackFragmentBox parent) |
|
protected org.mp4parser.Box |
createTfra(StreamingTrack track) |
Creates a 'tfra' - track fragment random access box for the given track with the isoFile.
|
protected org.mp4parser.Box |
createTrex(StreamingTrack streamingTrack) |
|
protected void |
createTrun(StreamingTrack streamingTrack,
org.mp4parser.boxes.iso14496.part12.TrackFragmentBox parent,
java.util.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(java.nio.channels.WritableByteChannel out,
org.mp4parser.Box... boxes) |
|
protected void |
writeFooter(org.mp4parser.Box... boxes) |
Writes the given boxes.
|
protected void |
writeFragment(org.mp4parser.Box... boxes) |
Writes the given boxes.
|
protected void |
writeHeader(org.mp4parser.Box... boxes) |
Writes the given boxes.
|
createDinf, createFtyp, createMdia, createMdiaHdlr, createMinf, createStbl, createTkhd, createTrakpublic static final java.lang.Object OBJ
protected final java.nio.channels.WritableByteChannel sink
protected java.util.List<StreamingTrack> source
protected java.util.Date creationTime
protected long sequenceNumber
protected java.util.Map<StreamingTrack,java.util.concurrent.CountDownLatch> congestionControl
protected java.util.Map<StreamingTrack,java.lang.Long> nextFragmentCreateStartTime
protected java.util.Map<StreamingTrack,java.lang.Long> nextFragmentWriteStartTime
protected java.util.Map<StreamingTrack,java.lang.Long> nextSampleStartTime
protected java.util.Map<StreamingTrack,java.util.List<StreamingSample>> sampleBuffers
protected java.util.Map<StreamingTrack,java.util.Queue<FragmentedMp4Writer.FragmentContainer>> fragmentBuffers
protected java.util.Map<StreamingTrack,long[]> tfraOffsets
protected java.util.Map<StreamingTrack,long[]> tfraTimes
public FragmentedMp4Writer(java.util.List<StreamingTrack> source, java.nio.channels.WritableByteChannel sink) throws java.io.IOException
java.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeableclose in interface SampleSinkjava.io.IOException - if writing to the underlying data sink failsMovieFragmentRandomAccessBoxprotected void write(java.nio.channels.WritableByteChannel out,
org.mp4parser.Box... boxes)
throws java.io.IOException
java.io.IOExceptionprotected org.mp4parser.Box createMdhd(StreamingTrack streamingTrack)
createMdhd in class DefaultBoxesprotected org.mp4parser.Box createMvex()
protected org.mp4parser.Box createTrex(StreamingTrack streamingTrack)
protected org.mp4parser.Box createMvhd()
createMvhd in class DefaultBoxesprotected org.mp4parser.Box createMoov()
protected org.mp4parser.Box[] createHeader()
public void acceptSample(StreamingSample streamingSample, StreamingTrack streamingTrack) throws java.io.IOException
SampleSinkStreamingTrack must be ready and accept calls to any method.acceptSample in interface SampleSinkjava.io.IOException - if writing (or reading) fails.protected boolean isFragmentReady(StreamingTrack streamingTrack, StreamingSample next)
streamingTrack - track to testnext - the lastest samplesprotected org.mp4parser.Box[] createFragment(StreamingTrack streamingTrack, java.util.List<StreamingSample> samples)
protected void writeHeader(org.mp4parser.Box... boxes)
throws java.io.IOException
boxes - any number of boxes that form the headerjava.io.IOException - when writing to the sink fails.FileTypeBox,
ProgressiveDownloadInformationBox,
MovieBox,
SegmentIndexBoxprotected void writeFragment(org.mp4parser.Box... boxes)
throws java.io.IOException
boxes - any number of boxes that form fragmentjava.io.IOException - when writing to the sink fails.MovieFragmentBox,
MediaDataBox,
SegmentTypeBox,
SegmentIndexBoxprotected void writeFooter(org.mp4parser.Box... boxes)
throws java.io.IOException
boxes - any number of boxes to conclude the file.java.io.IOException - when writing to the sink fails.MovieFragmentRandomAccessBoxprotected void createTfhd(StreamingTrack streamingTrack, org.mp4parser.boxes.iso14496.part12.TrackFragmentBox parent)
protected void createTfdt(StreamingTrack streamingTrack, org.mp4parser.boxes.iso14496.part12.TrackFragmentBox parent)
protected void createTrun(StreamingTrack streamingTrack, org.mp4parser.boxes.iso14496.part12.TrackFragmentBox parent, java.util.List<StreamingSample> samples)
protected org.mp4parser.Box[] createFooter()
protected org.mp4parser.Box createTfra(StreamingTrack track)
track - the concerned trackCopyright © 2019. All rights reserved.