
public class MediaPacket extends MediaEncoded
| Modifier and Type | Class and Description |
|---|---|
static class |
MediaPacket.SideDataType |
DEFAULT_TIME_STAMP_FORMAT| Modifier and Type | Method and Description |
|---|---|
MediaPacket |
copyReference()
Create a new MediaPacket 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.
|
long |
getConvergenceDuration()
Time difference in IStream#getTimeBase() units
from the presentation time stamp of this packet to the point at which the output from the decoder has converged independent from the availability of previous frames. |
Buffer |
getData()
Get any underlying raw data available for this packet.
|
long |
getDts()
Get the Decompression Time Stamp (DTS) for this packet.
|
long |
getDuration()
Return the duration of this packet, in units of #getTimeBase()
|
int |
getFlags()
Get any flags set on this packet, as a 4-byte binary-ORed bit-mask.
This is access to raw FFMPEG flags, but it is easier to use the is* methods below. |
int |
getMaxSize()
Get the maximum size (in bytes) of payload this packet can hold.
|
int |
getNumSideDataElems()
Get the number of side data elements in this packet.
|
long |
getPosition()
Return the position (in bytes) of this packet in the stream.
|
long |
getPts()
Get the Presentation Time Stamp (PTS) for this packet.
This is the time at which the payload for this packet should be presented to the user, in units of #getTimeBase(), relative to the start of stream. |
Buffer |
getSideData(int n)
Get the n'th item of SideData.
|
MediaPacket.SideDataType |
getSideDataType(int n)
Get the n'th item of SideData.
|
int |
getSize()
Get the size in bytes of the payload currently in this packet.
|
int |
getStreamIndex()
Get the container-specific index for the stream this packet is
part of. |
int |
hashCode()
Get a hashable value for this object.
|
boolean |
isKeyPacket()
Does this packet contain Key data? i.e.
|
static MediaPacket |
make()
Create a new Packet
|
static MediaPacket |
make(Buffer buffer)
Allocate a new packet that wraps an existing Buffer.
NOTE: At least 16 bytes of the passed in buffer will be used for header information, so the resulting Packet.getSize() will be smaller than Buffer.getBufferSize() . |
static MediaPacket |
make(int size)
Allocate a new packet.
|
static MediaPacket |
make(MediaPacket packet,
boolean copyData)
Allocate a new packet wrapping the existing contents of
a passed in packet. |
void |
reset(int payloadSize)
Discard the current payload and allocate a new payload.
|
void |
setConvergenceDuration(long duration)
Set the convergence duration.
|
void |
setDts(long aDts)
Set a new Decompression Time Stamp (DTS) for this packet.
|
void |
setDuration(long duration)
Set the duration.
|
void |
setFlags(int flags)
Set any internal flags.
|
void |
setKeyPacket(boolean keyPacket)
Set if this is a key packet.
|
void |
setPosition(long position)
Set the position.
|
void |
setPts(long aPts)
Set a new Presentation Time Stamp (PTS) for this packet.
|
void |
setStreamIndex(int streamIndex)
Set the stream index for this packet.
|
String |
toString() |
setTimeBasegetFormattedTimeStamp, getFormattedTimeStamp, getTimeBase, getTimeStamp, isComplete, isKey, setTimeStampdelete, getCurrentRefCountpublic MediaPacket copyReference()
copyReference in class MediaEncodedpublic boolean equals(Object obj)
equals in class MediaEncodedpublic int hashCode()
hashCode in class MediaEncodedpublic static MediaPacket make()
public static MediaPacket make(Buffer buffer)
buffer - The Buffer to wrap.public static MediaPacket make(MediaPacket packet, boolean copyData)
packet - Packet to reuse buffer from and tocopyData - if true copy data from packetpublic static MediaPacket make(int size)
Note that any buffers this packet needs will be
lazily allocated (i.e. we won't actually grab all
the memory until we need it).
size - The maximum size, in bytes, of data youpublic Buffer getData()
public int getNumSideDataElems()
public Buffer getSideData(int n)
WARNING: Callers must ensure that the the packet object
this is called form is NOT reset or destroyed while using this buffer,
as unfortunately we cannot ensure this buffer survives the
underlying packet data.
n - The n'th item to get.InvalidArgument - if n < 0 || n >= #getNumSideDataElems()public MediaPacket.SideDataType getSideDataType(int n)
n - The n'th item to get.InvalidArgument - if n < 0 || n >= #getNumSideDataElems()public long getPts()
public void setPts(long aPts)
aPts - a new PTS for this packet.getPts()public long getDts()
This is the time at which the payload for this packet should
be decompressed, in units of
#getTimeBase(), relative to the start of stream.
Some media codecs can require packets from the "future" to
be decompressed before earliest packets as an additional way to compress
data. In general you don't need to worry about this, but if you're
curious start reading about the difference between I-Frames, P-Frames
and B-Frames (or Bi-Directional Frames). B-Frames can use information
from future frames when compressed.
public void setDts(long aDts)
aDts - a new DTS for this packet.getDts()public int getSize()
public int getMaxSize()
public int getStreamIndex()
public int getFlags()
public boolean isKeyPacket()
public long getDuration()
public long getPosition()
public void setKeyPacket(boolean keyPacket)
keyPacket - true for yes, false for no.public void setFlags(int flags)
flags - Flags to setpublic void setStreamIndex(int streamIndex)
streamIndex - The stream index, as determined from the IContainer this packet will be written to.public void setDuration(long duration)
duration - new durationgetDuration()public void setPosition(long position)
position - new positiongetPosition()public long getConvergenceDuration()
The purpose of this field is to allow seeking in streams that have no
keyframes in the conventional sense. It corresponds to the
recovery point SEI in H.264 and match_time_delta in NUT. It is also
essential for some types of subtitle streams to ensure that all
subtitles are correctly displayed after seeking.
If you didn't follow that, try drinking one to two glasses
of Absinthe. It won't help, but it'll be more fun.
public void setConvergenceDuration(long duration)
duration - the new durationpublic void reset(int payloadSize)
Note that if any people have access to the old payload using
getData(), the memory will continue to be available to them
until they release their hold of the Buffer.
When requesting a packet size, the system
may allocate a larger payloadSize.
payloadSize - The (minimum) payloadSize of this packet in bytes. It is ok toCopyright © 2018 Humble Software. All rights reserved.