rtpi.packets
Class RtpiDataPacket

java.lang.Object
  |
  +--rtpi.packets.RtpiDataPacket

public final class RtpiDataPacket
extends java.lang.Object

This class represents an RTP/I data packet.

Author:
Martin Mauve

Field Summary
static int DELTA_STATE
          DELTA_STATE ADU type.
static int EVENT
          EVENT ADU type.
static int HEADER_SIZE
          The RTP/I header size.
static int ILLEGAL_PAYLOAD_TYPE
          Illegal value for the payload type field.
static int ILLEGAL_RELIABILITY_TYPE
          Illegal value for the reliability mapping.
static int ILLEGAL_TYPE
          ILLEGAL ADU type.
static int NO_RELIABILITY
          Reliability mapping ID for unreliable transmission.
static int RELIABLE_TRANSPORT
          Reliability mapping ID for transprent transport level reliability (such as TCP).
static int STATE
          STATE ADU type.
static int STATE_QUERY
          STATE_QUERY ADU type.
static int VERSION
          The protocol version number.
 
Constructor Summary
RtpiDataPacket(byte[] transportPacket, int start)
          This creates ab RtpiDataPacket from an incoming packet.
RtpiDataPacket(byte[] data, int begin, int size)
          This creates a new RtpiDataPacket that is to be transmitted over the network.
 
Method Summary
 void deleteReliabilityHeader()
          This deletes the reliability header of a packet.
 void flush()
          This flushes a packet.
 int flushToArray(byte[] destination, int start)
           
 int getEnd()
          This returns the value of this packets end bit.
 int getExtension()
          This returns the value of the extension bit.
 int getFragmentCount()
          This gets the fragment count of this packet.
 int getLength()
          This gets the length field of the packet.
 byte[] getPacketData()
          This gets the raw bytes of the encoded packet.
 int getParticipantID()
          This gets the participant ID of this packets sender.
 int getPayloadLength()
          This returns the length of the payload in bytes.
 int getPayloadStart()
          This returns the position of the first byte of this packet's payload.
 int getPayloadType()
          This returns the payload type of the packet.
 int getPriority()
          This gets the priority of the packet.
 byte getProfileInformation()
          This gets the profile specific information contained in this packet.
 byte[] getReliabilityHeader()
          This returns the reliability header.
 int getReliabilityHeaderLength()
          This returns the length of the reliability header in multiples of four bytes.
 byte[] getReliabilityInformation()
          This gets the reliability specific information contained in the packet.
 int getReliabilityType()
          This returns the reliability type of the packet.
 int getSequenceNumber()
          This returns the sequence number of the ADU this packet belongs to.
 long getSubcomponentID()
          This gets the subcomponent ID of the subcomponent this packet refers to.
 long getTimestamp()
          This returns the timestamp of this packet.
 int getType()
          This returns the ADU type of the packet.
 int getVersion()
          This returns the protocol version of the packet.
 void parse()
          This parses a packet.
 void setEnd(int e)
          This sets the value of the end bit for this packet.
 void setExtension(int e)
          This sets the value of the extension bit for this packet.
 void setFragmentCount(int fc)
          Thist sets the fragment count of this packet.
 void setParticipantID(int pid)
          This sets the participant ID of this packet.
 void setPayloadType(int pt)
          This sets the payload type for the packet.
 void setPriority(int p)
          This sets the priority of the packet.
 void setProfileInformation(byte pi)
          This sets the profile specific information for this packet.
 void setReliabilityHeader(byte[] header)
          This sets the reliablity extension header.
 void setReliabilityInformation(byte b0, byte b1)
          This sets the reliability specific information for this packet.
 void setReliabilityType(int rt)
          This sets the reliability type of the packet.
 void setSequenceNumber(int nr)
          This sets the sequence number of the packet.
 void setSubcomponentID(long subID)
          This sets the subcomponent ID for this packet.
 void setTimestamp(long ts)
          This sets the timestamp of this packet.
 void setType(int t)
          This sets the ADU type for this packet.
 java.lang.String toString()
          Print this object to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HEADER_SIZE

public static final int HEADER_SIZE
The RTP/I header size.

VERSION

public static final int VERSION
The protocol version number.

EVENT

public static final int EVENT
EVENT ADU type.

STATE

public static final int STATE
STATE ADU type.

DELTA_STATE

public static final int DELTA_STATE
DELTA_STATE ADU type.

STATE_QUERY

public static final int STATE_QUERY
STATE_QUERY ADU type.

ILLEGAL_TYPE

public static final int ILLEGAL_TYPE
ILLEGAL ADU type.

NO_RELIABILITY

public static final int NO_RELIABILITY
Reliability mapping ID for unreliable transmission.

RELIABLE_TRANSPORT

public static final int RELIABLE_TRANSPORT
Reliability mapping ID for transprent transport level reliability (such as TCP).

ILLEGAL_RELIABILITY_TYPE

public static final int ILLEGAL_RELIABILITY_TYPE
Illegal value for the reliability mapping.

ILLEGAL_PAYLOAD_TYPE

public static final int ILLEGAL_PAYLOAD_TYPE
Illegal value for the payload type field.
Constructor Detail

RtpiDataPacket

public RtpiDataPacket(byte[] transportPacket,
                      int start)
This creates ab RtpiDataPacket from an incoming packet. The incoming transport layer packet may contain more than one RtpiDataPacket.
Parameters:
transportPacket - The transport packet that has been received.
start - The start of the RtpiDataPacket within the transport packet. This identifies the position of the first byte of the header of this RtpiDataPacket in the transportPacket. It must be in the range between 0 and transportPacket.length.

RtpiDataPacket

public RtpiDataPacket(byte[] data,
                      int begin,
                      int size)
This creates a new RtpiDataPacket that is to be transmitted over the network.
Parameters:
rtpiDataPacket - The payload data.
start - The start of the payload data in the byte array. Ideally this should be identical to the sum of RTP/I header and reliability header. Then the header can be prepended to tha payload without copy operation.
size - The size of the payload data in the data array.
Method Detail

getPayloadStart

public int getPayloadStart()
This returns the position of the first byte of this packet's payload.
Returns:
The position of the first byte of the payload.

getPayloadLength

public int getPayloadLength()
This returns the length of the payload in bytes.
Returns:
The length of the payload.

getVersion

public int getVersion()
This returns the protocol version of the packet.
Returns:
The protocol version of this packet

getEnd

public int getEnd()
This returns the value of this packets end bit.
Returns:
Value of the end bit.

setEnd

public void setEnd(int e)
This sets the value of the end bit for this packet.
Parameters:
e - The end bit.

getExtension

public int getExtension()
This returns the value of the extension bit.
Returns:
The value of the extension bit.

setExtension

public void setExtension(int e)
This sets the value of the extension bit for this packet.
Parameters:
e - The value of the extension bit.

getType

public int getType()
This returns the ADU type of the packet.
Returns:
The ADU type (e.g. STATE or EVENT).

setType

public void setType(int t)
This sets the ADU type for this packet.
Parameters:
t - The ADU type (e.g. STATE or EVENT).

getPayloadType

public int getPayloadType()
This returns the payload type of the packet.
Returns:
The payload type.

setPayloadType

public void setPayloadType(int pt)
This sets the payload type for the packet.
Parameters:
pt - The payload type.

getLength

public int getLength()
This gets the length field of the packet.
Returns:
The length field of the packet.

getReliabilityType

public int getReliabilityType()
This returns the reliability type of the packet.
Returns:
The reliability Type.

setReliabilityType

public void setReliabilityType(int rt)
This sets the reliability type of the packet.
Parameters:
rt - The reliability Type.

getPriority

public int getPriority()
This gets the priority of the packet.
Returns:
The priority.

setPriority

public void setPriority(int p)
This sets the priority of the packet.
Parameters:
The - Priority.

getProfileInformation

public byte getProfileInformation()
This gets the profile specific information contained in this packet.
Returns:
The profile specific information.

setProfileInformation

public void setProfileInformation(byte pi)
This sets the profile specific information for this packet.
Parameters:
pi - The profile specific information.

getReliabilityInformation

public byte[] getReliabilityInformation()
This gets the reliability specific information contained in the packet.
Returns:
The profile specific information.

setReliabilityInformation

public void setReliabilityInformation(byte b0,
                                      byte b1)
This sets the reliability specific information for this packet.
Parameters:
The - reliability specific information.

getParticipantID

public int getParticipantID()
This gets the participant ID of this packets sender.
Returns:
The participant ID.

setParticipantID

public void setParticipantID(int pid)
This sets the participant ID of this packet.
Parameters:
The - participant ID.

getSubcomponentID

public long getSubcomponentID()
This gets the subcomponent ID of the subcomponent this packet refers to.
Returns:
The subcomponent ID.

setSubcomponentID

public void setSubcomponentID(long subID)
This sets the subcomponent ID for this packet.
Parameters:
The - subcomponent ID.

getSequenceNumber

public int getSequenceNumber()
This returns the sequence number of the ADU this packet belongs to.
Returns:
The sequence number.

setSequenceNumber

public void setSequenceNumber(int nr)
This sets the sequence number of the packet.
Parameters:
nr - The sequence number of the ADU this packet belongs to.

getFragmentCount

public int getFragmentCount()
This gets the fragment count of this packet.
Returns:
The fragment count of this packet.

setFragmentCount

public void setFragmentCount(int fc)
Thist sets the fragment count of this packet.

getTimestamp

public long getTimestamp()
This returns the timestamp of this packet.
Returns:
The timestamp.

setTimestamp

public void setTimestamp(long ts)
This sets the timestamp of this packet.
Parameters:
The - timestamp.

getPacketData

public byte[] getPacketData()
This gets the raw bytes of the encoded packet. This method should be called AFTER flush has been performed successfully.
Returns:
The byte array containing the encoded packet.

setReliabilityHeader

public void setReliabilityHeader(byte[] header)
                          throws IllegalValueException
This sets the reliablity extension header.
Parameters:
header - A reliability specific extension header that, when added one byte for the header length field, must be a multiple of four bytes in length.

deleteReliabilityHeader

public void deleteReliabilityHeader()
This deletes the reliability header of a packet.

getReliabilityHeaderLength

public int getReliabilityHeaderLength()
This returns the length of the reliability header in multiples of four bytes.
Returns:
The length of the reliability header.

getReliabilityHeader

public byte[] getReliabilityHeader()
This returns the reliability header.
Returns:
The reliability header.

parse

public void parse()
           throws RtpiParseException
This parses a packet.

flush

public void flush()
           throws RtpiFlushException
This flushes a packet.

flushToArray

public int flushToArray(byte[] destination,
                        int start)
                 throws RtpiFlushException

toString

public java.lang.String toString()
Print this object to a String.
Returns:
This object as a String.
Overrides:
toString in class java.lang.Object