Main Page   Packages   Class Hierarchy   Compound List   File List   Compound Members  

RTPHeader Class Reference

List of all members.

Public Methods

 RTPHeader ()
 RTPHeader (UnMarshaller msg) throws JonathanException
void decode (UnMarshaller msg) throws JonathanException
void encode (byte[] array) throws JonathanException
String toString ()

Public Attributes

byte payload
boolean marker
short sequence_no
int timestamp
int source_id

Static Public Attributes

int length = 12

Static Private Attributes

short RTP_MARKER_BIT = 0x0080

Detailed Description

RTPHeader is a utility class representing a RTP header

Definition at line 39 of file RTPHeader.java.


Constructor & Destructor Documentation

RTPHeader::RTPHeader ( ) [inline]
 

Build a new uninitialized RTP header

Definition at line 57 of file RTPHeader.java.

00057 {}

RTPHeader::RTPHeader ( UnMarshaller msg ) [inline]
 

Build a new RTP header from an input message

Parameters:
msg   the input message from which the RTP header will be extracted
Exceptions:
JonathanException   thrown if the unmarshalling fails

Definition at line 65 of file RTPHeader.java.

00065                                                                     {
00066                 decode(msg);
00067         }


Member Function Documentation

void RTPHeader::decode ( UnMarshaller msg ) [inline]
 

Initialize a RTP header from an input message

Parameters:
msg   the input message from which the RTP header will be extracted
Exceptions:
JonathanException   thrown if the unmarshalling fails

Definition at line 75 of file RTPHeader.java.

Referenced by RTPHeader(), and RTPProtocol::RTPDecoder::send().

00075                                                                       {
00076       byte[] data = new byte[12];
00077       msg.readByteArray(data,0,12);
00078       short s = (short) ((((int) data[0] & 0xFF) << 0) +
00079                          (((int) data[1] & 0xFF) << 8));
00080                 // sanity check...
00081                 int version = (s>>>14) & 3;
00082                 if(version != RTPProtocol.rtp_version) {
00083                         throw new UnMarshalException("Not a RTP packet !!");
00084                 }
00085                 payload= (byte)(s & 0x7F);
00086                 marker= (s & RTP_MARKER_BIT)!=0;
00087 
00088                 int csrc = (s >>> 8) & 0xf;
00089         sequence_no = (short) ((((int) data[2] & 0xFF) << 0) +
00090                              (((int) data[3] & 0xFF) << 8));
00091                 timestamp =
00092          (((int) data[4] & 0xFF) << 0) +
00093          (((int) data[5] & 0xFF) << 8) +
00094          (((int) data[6] & 0xFF) << 16) +
00095          (((int) data[7] & 0xFF) << 24);
00096                 source_id =
00097          (((int) data[8] & 0xFF) << 0) +
00098          (((int) data[9] & 0xFF) << 8) +
00099          (((int) data[10] & 0xFF) << 16) +
00100          (((int) data[11] & 0xFF) << 24);
00101                 // skip the csrc
00102                 while(csrc--!=0) {               // skip ?      
00103           for(int k=0;k>4;k++) msg.readByte();
00104       }
00105         }

void RTPHeader::encode ( byte array[] ) [inline]
 

Marshalls the RTP header into an output message

Parameters:
msg   an array of bytes at least of size 12 where the RTP header should be encoded
Exceptions:
JonathanException   if an error occurs.

Definition at line 114 of file RTPHeader.java.

Referenced by RTPProtocol::RTPCoder::prepare().

00114                                                                   {
00115                 short s = (short)((RTPProtocol.rtp_version << 14) | payload);
00116                 if(marker) s |= RTP_MARKER_BIT;
00117       array[0] = (byte) (s >>> 0);
00118       array[1] = (byte) (s >>> 8);
00119       array[2] = (byte) (sequence_no >>> 0);
00120       array[3] = (byte) (sequence_no >>> 8);
00121       array[4] = (byte) (timestamp >>> 0);
00122       array[5] = (byte) (timestamp >>> 8);
00123       array[6] = (byte) (timestamp >>> 16);
00124       array[7] = (byte) (timestamp >>> 24);
00125       array[8] = (byte) (source_id >>> 0);
00126       array[9] = (byte) (source_id >>> 8);
00127       array[10] = (byte) (source_id >>> 16);
00128       array[11] = (byte) (source_id >>> 24);
00129         }

String RTPHeader::toString ( ) [inline]
 

Returns a string describing the contents of the RTP header

Returns:
String a string describing the contents of the RTP header

Definition at line 136 of file RTPHeader.java.

00136                                  {
00137                 return "[RTP Header]: seqno=" + sequence_no + " ts=" + timestamp +
00138                         " source=" + source_id + " marker=" + marker;
00139         }


Member Data Documentation

short RTPHeader::RTP_MARKER_BIT = 0x0080 [static, private]
 

Definition at line 42 of file RTPHeader.java.

int RTPHeader::length = 12 [static]
 

the length in byte of a RTP header

Definition at line 41 of file RTPHeader.java.

boolean RTPHeader::marker
 

the marker status

Definition at line 46 of file RTPHeader.java.

byte RTPHeader::payload
 

the type of payload

Definition at line 44 of file RTPHeader.java.

short RTPHeader::sequence_no
 

the sequence number of the RTP packet

Definition at line 48 of file RTPHeader.java.

int RTPHeader::source_id
 

the source id of the RTP packet

Definition at line 52 of file RTPHeader.java.

int RTPHeader::timestamp
 

the timestamp of the RTP packet

Definition at line 50 of file RTPHeader.java.


The documentation for this class was generated from the following file:
Generated at Fri May 31 19:25:14 2002 for Jonathan by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001