fi.helsinki.cs.ohtu.mpeg2
Class AudioVideoPESPacket

java.lang.Object
  extended by fi.helsinki.cs.ohtu.mpeg2.PESPacket
      extended by fi.helsinki.cs.ohtu.mpeg2.AudioVideoPESPacket

public final class AudioVideoPESPacket
extends PESPacket

Represents a PES packet carrying data from a MPEG-2 audio/video stream or any other type of stream with the same packet format.


Field Summary
private  java.lang.Double dts
           
private  java.lang.Double pts
           
private  int stuffing
           
 
Constructor Summary
AudioVideoPESPacket(StreamID streamID)
          Class constructor.
 
Method Summary
 double getDecodingTimestamp()
          Gets the decoding timestamp specified by the packet.
 double getPresentationTimestamp()
          Gets the presentation timestamp specified by the packet.
 int getStuffingLength()
          Returns the number of stuffing bytes.
 boolean hasDecodingTimestamp()
          Determines whether this packet specifies a decoding timestamp or not.
 boolean hasPresentationTimestamp()
          Determines whether this packet specifies a presentation timestamp or not.
protected  void insertTemplateBytes()
          Overload of the base class method, inserting the additional header bytes.
 void setPresentationTimestamp(double timestamp)
          Sets the packet to specify only a presentation timestamp.
 void setStuffingLength(int stuffing)
          Sets the number of stuffing bytes in this AudioVideoPESPacket.
 void setTimestamps(double pts, double dts)
          Sets the packet to specify both a presentation timestamp and a decoding timestamp.
 void unsetTimestamps()
          Unsets the time stamps set by setPresentationTimeStamp() and/or setTimestamps().
 
Methods inherited from class fi.helsinki.cs.ohtu.mpeg2.PESPacket
addAboutToResetListener, getAboutToResetListeners, getPacketLength, getStream, getStreamID, getTotalLength, removeAboutToResetListener, reset, writeTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pts

private java.lang.Double pts

dts

private java.lang.Double dts

stuffing

private int stuffing
Constructor Detail

AudioVideoPESPacket

public AudioVideoPESPacket(StreamID streamID)
Class constructor. The resulting packet will specify no optional fields. Use the individual setters to change that.

Parameters:
streamID - The ID of the stream the carried data belongs to.
Method Detail

hasPresentationTimestamp

public boolean hasPresentationTimestamp()
Determines whether this packet specifies a presentation timestamp or not.

Returns:
true if the packet specifies a PTS, false otherwise.

getPresentationTimestamp

public double getPresentationTimestamp()
Gets the presentation timestamp specified by the packet. Must not be used if the packet doesn't specify a presentation timestamp, as indicated by hasPresentationTimestamp() returning false.

Returns:
The timestamp, in seconds.

getDecodingTimestamp

public double getDecodingTimestamp()
Gets the decoding timestamp specified by the packet. Must not be used if the packet doesn't specify a decoding timestamp, as indicated by hasDecodingTimestamp() returning false.

Returns:
The timestamp, in seconds.

hasDecodingTimestamp

public boolean hasDecodingTimestamp()
Determines whether this packet specifies a decoding timestamp or not.

Returns:
true if the packet specifies a DTS, false otherwise.

unsetTimestamps

public void unsetTimestamps()
Unsets the time stamps set by setPresentationTimeStamp() and/or setTimestamps(). Afterwards, the PES packet will not specify neither a presentation timestamp nor a decoding timestamp. Will reset the header, as if a call to reset() was made. If there are no timestamps currently set, nothing will happen.


getStuffingLength

public int getStuffingLength()
Returns the number of stuffing bytes.

Returns:
the number of stuffing bytes

setPresentationTimestamp

public void setPresentationTimestamp(double timestamp)
Sets the packet to specify only a presentation timestamp. The packet won't specify a decoding timestamp, even if it did so before a call to this function. Will reset the header, as if a call to reset() was made. If the packet already specifies the given PTS and doesn't specify a DTS, nothing will happen.

Parameters:
timestamp - The timestamp to specify, in seconds. Must be non-negative.

setTimestamps

public void setTimestamps(double pts,
                          double dts)
Sets the packet to specify both a presentation timestamp and a decoding timestamp. Will reset the header, as if a call to reset() was made. However, if the packet already exactly specifies the given timestamps, nothing will happen.

Parameters:
pts - The presentation timestamp to specify, in seconds. Must be non-negative.
dts - The decoding timestamp to specify, in seconds. Must be non-negative.

setStuffingLength

public void setStuffingLength(int stuffing)
Sets the number of stuffing bytes in this AudioVideoPESPacket.

Parameters:
stuffing - the number of stuffing bytes, in range [0..255]

insertTemplateBytes

protected void insertTemplateBytes()
Overload of the base class method, inserting the additional header bytes.

Overrides:
insertTemplateBytes in class PESPacket