cgl.narada.matching.rtp
Class RtpEvent

java.lang.Object
  extended by cgl.narada.matching.rtp.RtpEvent

public class RtpEvent
extends Object

This RtpEvent class serializes and deserializes RtpEvent objects Here is the format of serialization: Byte 0 = either Protocol.NARADA_RTP_EVENT or Protocol.NARADA_RTP_CLIENT_EVENT byte 1 = media type Bytes 2-5 = an int, which is the source id Bytes 6-13 = an int, which is the topic number Bytes 14-end = data


Field Summary
static byte AUDIO_EVENT
           
static byte NO_TYPE_EVENT
           
static byte RTCP_EVENT
           
static byte VIDEO_EVENT
           
 
Constructor Summary
RtpEvent(byte[] rtpEventBytes)
          This method constructs a new RtpEvent object from a byte array.
RtpEvent(int source, long topicNumber, byte[] data)
          construct an event with the given data given byte array only has the data.
RtpEvent(int source, long topicNumber, byte[] buffer, int offset, int length)
          construct an event with the given parameters the type of this event is NO_TYPE_EVENT
RtpEvent(int source, long topicNumber, byte[] buffer, int offset, int length, byte type)
          construct an event with the given parameters.
 
Method Summary
 byte[] getBuffer()
          return the buffer array which might have both data and some other info, so it should be used with offset and length to access the real data.
 byte[] getBytes()
          return serialized event.
 byte[] getBytes(byte flag)
          return serialized event with the given flag.
 byte[] getBytesWithClientFlag()
          Serializes the RtpEvent object with the Protocol.NARADA_RTP_CLIENT_EVENT as first byte
 byte[] getData()
          returns a byte array which only has the data
 int getDataLength()
           
 int getOffset()
           
 int getSource()
           
 long getTopic()
           
 byte getType()
           
 boolean isAudio()
           
static boolean isAudioEvent(byte[] data)
          check whether the given data array has a serialized audio rtp event
static void main(String[] args)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AUDIO_EVENT

public static final byte AUDIO_EVENT
See Also:
Constant Field Values

VIDEO_EVENT

public static final byte VIDEO_EVENT
See Also:
Constant Field Values

RTCP_EVENT

public static final byte RTCP_EVENT
See Also:
Constant Field Values

NO_TYPE_EVENT

public static final byte NO_TYPE_EVENT
See Also:
Constant Field Values
Constructor Detail

RtpEvent

public RtpEvent(int source,
                long topicNumber,
                byte[] data)
construct an event with the given data given byte array only has the data. it means the offset is zero and the length of data is the length of the array. the type of this event is NO_TYPE_EVENT


RtpEvent

public RtpEvent(int source,
                long topicNumber,
                byte[] buffer,
                int offset,
                int length)
construct an event with the given parameters the type of this event is NO_TYPE_EVENT


RtpEvent

public RtpEvent(int source,
                long topicNumber,
                byte[] buffer,
                int offset,
                int length,
                byte type)
construct an event with the given parameters.

Parameters:
source - source id
topicNumber - topic number
buffer - byte array.
offset - the start point of the data in the buffer array
length - the length of the data in the buffer
type - the type of this event

RtpEvent

public RtpEvent(byte[] rtpEventBytes)
This method constructs a new RtpEvent object from a byte array. byte array must be constructed with one of the getbytes method of this class.

Method Detail

toString

public String toString()
Overrides:
toString in class Object

getType

public byte getType()
Returns:
the type of this event

isAudio

public boolean isAudio()
Returns:
true if this is an audio event

getTopic

public long getTopic()

getBuffer

public byte[] getBuffer()
return the buffer array which might have both data and some other info, so it should be used with offset and length to access the real data.


getData

public byte[] getData()
returns a byte array which only has the data


getSource

public int getSource()

getOffset

public int getOffset()

getDataLength

public int getDataLength()

getBytes

public byte[] getBytes()
return serialized event. It will has Protocol.NARADA_RTP_EVENT flag.


getBytesWithClientFlag

public byte[] getBytesWithClientFlag()
Serializes the RtpEvent object with the Protocol.NARADA_RTP_CLIENT_EVENT as first byte


getBytes

public byte[] getBytes(byte flag)
return serialized event with the given flag. It can be either one of the following flags: Protocol.NARADA_RTP_EVENT Protocol.NARADA_RTP_CLIENT_EVENT


isAudioEvent

public static boolean isAudioEvent(byte[] data)
check whether the given data array has a serialized audio rtp event

Returns:

main

public static void main(String[] args)


For comments and suggestions please send e-mail to The NaradaBrokering Project