Interface Muxer
-
- All Known Implementing Classes:
DefaultMuxer
public interface Muxer
Abstracts media muxing operations.Query whether sample MIME types are supported and add all tracks, then write sample data to mux samples. Once any sample data has been written, it is not possible to add tracks. After writing all sample data, release the instance to finish writing to the output and return any resources to the system.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Muxer.Factory
Factory for muxers.static class
Muxer.MuxerException
Thrown when a muxing failure occurs.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
addTrack(Format format)
Adds a track with the specified format, and returns its index (to be passed in subsequent calls towriteSampleData(int, ByteBuffer, boolean, long)
).long
getMaxDelayBetweenSamplesMs()
Returns the maximum delay allowed between output samples, in milliseconds, orC.TIME_UNSET
if there is no maximum.void
release(boolean forCancellation)
Finishes writing the output and releases any resources associated with muxing.void
writeSampleData(int trackIndex, ByteBuffer data, boolean isKeyFrame, long presentationTimeUs)
Writes the specified sample.
-
-
-
Method Detail
-
addTrack
int addTrack(Format format) throws Muxer.MuxerException
Adds a track with the specified format, and returns its index (to be passed in subsequent calls towriteSampleData(int, ByteBuffer, boolean, long)
).- Parameters:
format
- TheFormat
of the track.- Throws:
Muxer.MuxerException
- If the muxer encounters a problem while adding the track.
-
writeSampleData
void writeSampleData(int trackIndex, ByteBuffer data, boolean isKeyFrame, long presentationTimeUs) throws Muxer.MuxerException
Writes the specified sample.- Parameters:
trackIndex
- The index of the track, previously returned byaddTrack(Format)
.data
- A buffer containing the sample data to write to the container.isKeyFrame
- Whether the sample is a key frame.presentationTimeUs
- The presentation time of the sample in microseconds.- Throws:
Muxer.MuxerException
- If the muxer fails to write the sample.
-
release
void release(boolean forCancellation) throws Muxer.MuxerException
Finishes writing the output and releases any resources associated with muxing.The muxer cannot be used anymore once this method has been called.
- Parameters:
forCancellation
- Whether the reason for releasing the resources is the transformation cancellation.- Throws:
Muxer.MuxerException
- If the muxer fails to finish writing the output andforCancellation
is false.
-
getMaxDelayBetweenSamplesMs
long getMaxDelayBetweenSamplesMs()
Returns the maximum delay allowed between output samples, in milliseconds, orC.TIME_UNSET
if there is no maximum.This is the maximum delay between samples of any track. They can be of the same or of different track types.
This value is used to abort the transformation when the maximum delay is reached. Note that there is no guarantee that the transformation will be aborted exactly at that time.
-
-