
public class Demuxer extends Container
| Modifier and Type | Class and Description |
|---|---|
static class |
Demuxer.SeekFlag
Flags that can be bitmasked in the #seek method.
|
static class |
Demuxer.State
Demuxers can only be in one of these states:
|
Container.Flag| Modifier and Type | Method and Description |
|---|---|
boolean |
canStreamsBeAddedDynamically()
Can streams be added dynamically to this container?
|
void |
close()
Close the container.
|
Demuxer |
copyReference()
Create a new Demuxer object that is actually referring to the
exact same underlying native object.
|
boolean |
equals(Object obj)
Compares two values, returning true if the underlying objects in native code are the same object.
|
int |
getBitRate()
Get the calculated overall bit rate of this file.
|
long |
getDuration()
Gets the duration, if known, of this container.
This will only work for non-streamable containers where Demuxer can calculate the container size. |
long |
getFileSize()
Get the file size in bytes of this container.
This will only return a valid value if the container is non-streamed and supports seek. |
boolean |
getFlag(Container.Flag flag)
Get the setting for the specified flag
|
int |
getFlags()
Get the flags associated with this object.
|
DemuxerFormat |
getFormat()
Get the DemuxerFormat associated with this Demuxer
or null if unknown. |
int |
getInputBufferLength()
Return the input buffer length.
|
int |
getMaxDelay()
Gets the AVFormatContext.max_delay property if possible.
|
KeyValueBag |
getMetaData()
Get the KeyValueBag of media MetaData for this object,
or null if none. |
int |
getReadRetryCount()
Get the number of times Demuxer#readNextPacket(Packet)
will retry a read if it gets a Error.Type#ERROR_AGAIN value back. Defaults to 1 times. |
long |
getStartTime()
Get the starting timestamp in microseconds of the first packet of the earliest stream in this container.
|
Demuxer.State |
getState()
Get the current state of the container.
|
DemuxerStream |
getStream(int streamIndex)
Get the stream at the given position.
|
String |
getURL()
Get the URL the Demuxer was opened with.
May return null if unknown. |
int |
hashCode()
Get a hashable value for this object.
|
static Demuxer |
make()
Create a new Demuxer
|
void |
open(String url,
DemuxerFormat format,
boolean streamsCanBeAddedDynamically,
boolean queryStreamMetaData,
KeyValueBag options,
KeyValueBag optionsNotSet)
Open this container and make it ready for reading, optionally
reading as far into the container as necessary to find all streams. |
void |
pause()
Pause a playing network source.
|
void |
play()
Start playing a network source.
|
void |
queryStreamMetaData()
Attempts to read all the meta data in this stream, potentially by reading ahead
and decoding packets. |
int |
read(MediaPacket packet)
Reads the next packet in the Demuxer into the Packet.
|
int |
seek(int stream_index,
long min_ts,
long ts,
long max_ts,
int flags)
Seek to timestamp ts.
Seeking will be done so that the point from which all active streams can be presented successfully will be closest to ts and within min/max_ts. Active streams are all streams that have Stream.getDiscardSetting < Codec.DISCARD_ALL. If flags contain SeekFlags.SEEK_BYTE, then all timestamps are in bytes and are the file position (this may not be supported by all demuxers). If flags contain SeekFlags.SEEK_FRAME, then all timestamps are in frames in the stream with stream_index (this may not be supported by all demuxers). Otherwise all timestamps are in units of the stream selected by stream_index or if stream_index is -1, in (1/Global.DEFAULT_PTS_MICROSECONDS} units. If flags contain SeekFlags.SEEK_ANY, then non-keyframes are treated as keyframes (this may not be supported by all demuxers). |
void |
setFlag(Container.Flag flag,
boolean value)
Set the flag.
|
void |
setFlags(int newFlags)
Set the flags to use with this object.
|
int |
setForcedAudioCodec(Codec.ID id)
Forces the Demuxer to assume all audio streams are
encoded with the given audio codec when demuxing. |
int |
setForcedSubtitleCodec(Codec.ID id)
Forces the Demuxer to assume all subtitle streams are
encoded with the given subtitle codec when demuxing. |
int |
setForcedVideoCodec(Codec.ID id)
Forces the Demuxer to assume all video streams are
encoded with the given video codec when demuxing. |
void |
setInputBufferLength(int size)
Set the buffer length Humble Video will suggest to FFMPEG for reading inputs.
If called when a Container is open, the call is ignored and -1 is returned. |
void |
setReadRetryCount(int count)
Sets the read retry count.
|
String |
toString() |
getNumStreamsgetNumProperties, getPropertyAsBoolean, getPropertyAsDouble, getPropertyAsInt, getPropertyAsLong, getPropertyAsRational, getPropertyAsString, getPropertyMetaData, getPropertyMetaData, setProperty, setProperty, setProperty, setProperty, setProperty, setPropertydelete, getCurrentRefCountpublic Demuxer copyReference()
copyReference in class Containerpublic boolean equals(Object obj)
public int hashCode()
public static Demuxer make()
public Demuxer.State getState()
public DemuxerFormat getFormat()
public void setInputBufferLength(int size)
size - The suggested buffer size.InvalidArgument - if size <= 0public int getInputBufferLength()
public void open(String url, DemuxerFormat format, boolean streamsCanBeAddedDynamically, boolean queryStreamMetaData, KeyValueBag options, KeyValueBag optionsNotSet) throws InterruptedException, IOException
The caller must call #close() when done, but if not, the
Demuxer will eventually close
them later but warn to the logging system.
url - The resource to open; The format of this string is anyformat - A pointer to a InputFormat object specifyingstreamsCanBeAddedDynamically - If true, open() will expect that newqueryStreamMetaData - If true, open() will call #queryStreamMetaData()options - If not null, a set of key-value pairs that will be set on the container immediatelyoptionsNotSet - If not null, on return this KeyValueBag object will be cleared out, andoptions but could not be set on thisInterruptedExceptionIOExceptionpublic void close()
throws InterruptedException,
IOException
If this method exits because of an interruption,
all resources will be closed anyway.
InterruptedExceptionIOExceptionpublic DemuxerStream getStream(int streamIndex) throws InterruptedException, IOException
streamIndex - the index of this stream in the containerInterruptedExceptionIOExceptionpublic int read(MediaPacket packet) throws InterruptedException, IOException
For non-blocking IO data sources, it is possible for this method
to return as successful but with no complete packet. In that case
the caller should retry again later (think EAGAIN) semantics.
packet - [In/Out] The packet the Demuxer will read into.RuntimeException - if an error occurs except for EOF (in which case <0 returned)InterruptedExceptionIOExceptionpublic void queryStreamMetaData()
throws InterruptedException,
IOException
Any packets this method reads ahead will be cached and correctly returned when you
read packets, but this method can be non-blocking potentially until end of container
to get all meta data. Take care when you call it.
After this method is called, other meta data methods like #getDuration() should
work.
InterruptedExceptionIOExceptionpublic long getDuration()
public long getStartTime()
This will only return value values either either (a) for non-streamable
containers where Demuxer can calculate the container size or
(b) after Demuxer has actually read the
first packet from a streamable Demuxer.
public long getFileSize()
public int getBitRate()
This will only return a valid value if the container is non-streamed and supports seek.
public int getFlags()
public void setFlags(int newFlags)
newFlags - The new set flags for this codec.
public boolean getFlag(Container.Flag flag)
flag - The flag you want to find the setting forpublic void setFlag(Container.Flag flag, boolean value)
flag - The flag to setvalue - The value to set it to (true or false)public String getURL()
public int getReadRetryCount()
public void setReadRetryCount(int count)
count - The read retry count. <0 means keep trying.
public boolean canStreamsBeAddedDynamically()
public KeyValueBag getMetaData()
If the Demuxer or IStream object
that this KeyValueBag came from was opened
for reading, then changes via KeyValueBag#setValue(String, String)
will have no effect on the underlying media.
If the Demuxer or IStream object
that this KeyValueBag came from was opened
for writing, then changes via KeyValueBag#setValue(String, String)
will have no effect after Demuxer#writeHeader()
is called.
public int setForcedAudioCodec(Codec.ID id)
id - The codec idpublic int setForcedVideoCodec(Codec.ID id)
id - The codec idpublic int setForcedSubtitleCodec(Codec.ID id)
id - The codec idpublic int seek(int stream_index,
long min_ts,
long ts,
long max_ts,
int flags)
throws InterruptedException,
IOException
stream_index - index of the stream which is used as time base referencemin_ts - smallest acceptable timestampts - target timestampmax_ts - largest acceptable timestampflags - flagsInterruptedExceptionIOExceptionpublic int getMaxDelay()
public void play()
throws InterruptedException,
IOException
InterruptedExceptionIOExceptionpublic void pause()
throws InterruptedException,
IOException
InterruptedExceptionIOExceptionCopyright © 2018 Humble Software. All rights reserved.