jlibrtp
Class DataFrame

java.lang.Object
  extended by jlibrtp.DataFrame

public class DataFrame
extends java.lang.Object

Data structure to hold a complete frame if frame reconstruction is enabled, or the data from an individual packet if it is not It also contains most of the data from the individual packets that it is based on.

Author:
Arne Kepp

Field Summary
private  boolean anyMarked
          Whether any packets were marked or not
private  long[] CSRCs
          contributing CSRCs, only read from the first packet
private  byte[][] data
          The data from the individual packets, ordered
protected  int firstSeqNum
          The first sequence number in this frame
private  int isComplete
          Whether the frame contains the expected number of packets
protected  int lastSeqNum
          The last sequence number in this frame
private  boolean[] marks
          The marks on individual packets, ordered
protected  int noPkts
          The number of packets expected for a complete frame
private  int payloadType
          RTP payload type
private  long rtpTimestamp
          The share RTP timestamp
private  int[] seqNum
          The sequence numbers of the individual packets, ordered
private  long SSRC
          the SSRC from which this frame originated
private  long timestamp
          The calculated UNIX timestamp, guessed after 2 Sender Reports
private  int totalLength
          The total amount of data bytes in this frame
 
Constructor Summary
protected DataFrame(PktBufNode aBufNode, Participant p, int noPkts)
          The usual way to construct a frame is by giving it a PktBufNode, which contains links to all the other pkts that make it up.
 
Method Summary
 int complete()
          Checks whether the difference in sequence numbers corresponds to the number of packets received for the current timestamp, and whether this value corresponds to the expected number of packets.
 long[] csrcs()
          The SSRCs that contributed to this frame
 byte[] getConcatenatedData()
          Returns a concatenated version of the data from getData() It ignores missing sequence numbers, but then isComplete() will return false provided that RTPAppIntf.frameSize() provides a non-negative number for this payload type.
 byte[][] getData()
          Returns a two dimensial array where the first dimension represents individual packets, from which the frame is made up, in order of increasing sequence number.
 boolean marked()
          Returns true if any packet in the frame was marked.
 boolean[] marks()
          Returns an array whose values, for the same index, correpond to whether the data was marked or not.
 int payloadType()
          Returns the payload type of the packets
 long rtpTimestamp()
          Returns the RTP timestamp of all the packets in the frame.
 int[] sequenceNumbers()
          Returns an array whose values, for the same index, correpond to the sequence number of the packet from which the data came.
 long ssrc()
          The SSRC associated with this frame.
 long timestamp()
          If two SR packet have been received jlibrtp will attempt to calculate the local UNIX timestamp (in milliseconds) of all packets received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rtpTimestamp

private long rtpTimestamp
The share RTP timestamp


timestamp

private long timestamp
The calculated UNIX timestamp, guessed after 2 Sender Reports


SSRC

private long SSRC
the SSRC from which this frame originated


CSRCs

private long[] CSRCs
contributing CSRCs, only read from the first packet


payloadType

private int payloadType
RTP payload type


marks

private boolean[] marks
The marks on individual packets, ordered


anyMarked

private boolean anyMarked
Whether any packets were marked or not


isComplete

private int isComplete
Whether the frame contains the expected number of packets


data

private byte[][] data
The data from the individual packets, ordered


seqNum

private int[] seqNum
The sequence numbers of the individual packets, ordered


totalLength

private int totalLength
The total amount of data bytes in this frame


lastSeqNum

protected int lastSeqNum
The last sequence number in this frame


firstSeqNum

protected int firstSeqNum
The first sequence number in this frame


noPkts

protected int noPkts
The number of packets expected for a complete frame

Constructor Detail

DataFrame

protected DataFrame(PktBufNode aBufNode,
                    Participant p,
                    int noPkts)
The usual way to construct a frame is by giving it a PktBufNode, which contains links to all the other pkts that make it up.

Method Detail

getData

public byte[][] getData()
Returns a two dimensial array where the first dimension represents individual packets, from which the frame is made up, in order of increasing sequence number. These indeces can be matched to the sequence numbers returned by sequenceNumbers().

Returns:
2-dim array with raw data from packets

getConcatenatedData

public byte[] getConcatenatedData()
Returns a concatenated version of the data from getData() It ignores missing sequence numbers, but then isComplete() will return false provided that RTPAppIntf.frameSize() provides a non-negative number for this payload type.

Returns:
byte[] with all the data concatenated

timestamp

public long timestamp()
If two SR packet have been received jlibrtp will attempt to calculate the local UNIX timestamp (in milliseconds) of all packets received. This value should ideally correspond to the local time when the SSRC sent the packet. Note that the source may not be reliable. Returns -1 if less than two SRs have been received

Returns:
the UNIX timestamp, similar to System.currentTimeMillis() or -1;

rtpTimestamp

public long rtpTimestamp()
Returns the RTP timestamp of all the packets in the frame.

Returns:
unmodified RTP timestamp

payloadType

public int payloadType()
Returns the payload type of the packets

Returns:
the payload type of the packets

sequenceNumbers

public int[] sequenceNumbers()
Returns an array whose values, for the same index, correpond to the sequence number of the packet from which the data came. This information can be valuable in conjunction with getData(), to identify what parts of a frame are missing.

Returns:
array with sequence numbers

marks

public boolean[] marks()
Returns an array whose values, for the same index, correpond to whether the data was marked or not. This information can be valuable in conjunction with getData().

Returns:
array of booleans

marked

public boolean marked()
Returns true if any packet in the frame was marked. This function should be used if all your frames fit into single packets.

Returns:
true if any packet was marked, false otherwise

ssrc

public long ssrc()
The SSRC associated with this frame.

Returns:
the ssrc that created this frame

csrcs

public long[] csrcs()
The SSRCs that contributed to this frame

Returns:
an array of contributing SSRCs, or null

complete

public int complete()
Checks whether the difference in sequence numbers corresponds to the number of packets received for the current timestamp, and whether this value corresponds to the expected number of packets.

Returns:
true if the right number of packets make up the frame