org.ow2.clif.probe.rtp
Class ReportPacket

java.lang.Object
  extended by org.ow2.clif.probe.rtp.RTCPPacket
      extended by org.ow2.clif.probe.rtp.ReportPacket

public class ReportPacket
extends RTCPPacket

Create a RTCP SR/RR packet. Cf. RFC 3550 for details about construction of SR/RR packet.

Author:
Remi Druilhe

Constructor Summary
ReportPacket(java.lang.Long ssrc)
          Constructor for a receiver report.
ReportPacket(java.lang.Long ssrc, java.lang.Long rtpTimestamp, java.lang.Long packetCount, java.lang.Long octetCount)
          Contructor for a sender report.
 
Method Summary
 void addReportBlock(java.lang.Long ssrc, java.lang.Integer fractionLost, java.lang.Integer packetsLost, java.lang.Integer cycle, java.lang.Integer maxSeqNum, java.lang.Long jitter, java.lang.Long lsr, java.lang.Long dlsr)
          Add an item to the report packet.
 byte[] createPacket()
          Convert every information of the sender's report header in bytes.
static java.lang.Long decodeSrLswNtpTimestamp(byte[] data, java.lang.Integer offset)
          Decode LSW Timestamp from a SR report.
static java.lang.Long decodeSrMswNtpTimestamp(byte[] data, java.lang.Integer offset)
          Decode MSW Timestamp from a SR report.
static java.lang.Long decodeSsrc(byte[] data, java.lang.Integer offset)
          Decode SSRC from a SR/RR report.
static java.lang.Long generateLswNtpTimestamp(java.lang.Long time)
          Decimal part of the NTP Timestamp.
static java.lang.Long generateMswNtpTimestamp(java.lang.Long time)
          Floor part of the NTP timestamp.
 java.lang.Integer getPacketType()
          /** Returns the packet type.
 void receiverToSender()
          Change type of report (201 to 200)
 void senderToReceiver()
          Change type of report (200 to 201)
 void setNewValues(java.lang.Long rtpTimestamp, java.lang.Long packetCount, java.lang.Long octetCount)
          To add new value to the SR report.
 
Methods inherited from class org.ow2.clif.probe.rtp.RTCPPacket
createRtcpPacket, decodeCount, decodeLength, decodePacketType, decodePadding, decodeTwoComplement, decodeTwoComplement, decodeVersion, getRtcpPackets, packetTypeAvailable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReportPacket

public ReportPacket(java.lang.Long ssrc)
Constructor for a receiver report.

Parameters:
ssrc -

ReportPacket

public ReportPacket(java.lang.Long ssrc,
                    java.lang.Long rtpTimestamp,
                    java.lang.Long packetCount,
                    java.lang.Long octetCount)
Contructor for a sender report.

Method Detail

createPacket

public byte[] createPacket()
Convert every information of the sender's report header in bytes.

Specified by:
createPacket in class RTCPPacket
Returns:
the header formatted in bytes for sender's report.

addReportBlock

public void addReportBlock(java.lang.Long ssrc,
                           java.lang.Integer fractionLost,
                           java.lang.Integer packetsLost,
                           java.lang.Integer cycle,
                           java.lang.Integer maxSeqNum,
                           java.lang.Long jitter,
                           java.lang.Long lsr,
                           java.lang.Long dlsr)
Add an item to the report packet.

Parameters:
ssrc - the SSRC associated to the statistics.
fractionLost - the fraction lost (cf. RFC 3550 p32).
packetsLost - the cumulative number packets lost (cf.RFC 3550 p32).
cycle - the number of cycle of the sequence number (cf.RFC 3550 p33).
maxSeqNum - the maximum sequence number read (cf.RFC 3550 p33).
jitter - the jitter (cf.RFC 3550 p33).
lsr - last sender report (cf.RFC 3550 p33).
dlsr - delay since last sender report (cf.RFC 3550 p33).

receiverToSender

public void receiverToSender()
Change type of report (201 to 200)


senderToReceiver

public void senderToReceiver()
Change type of report (200 to 201)


generateMswNtpTimestamp

public static java.lang.Long generateMswNtpTimestamp(java.lang.Long time)
Floor part of the NTP timestamp. Calculation of the time since Jan 01, 1900 at midnight. MSW = (24 * 60 * 60) * ((70 * 365) + 17) + time / 1000

Returns:
the time in seconds.

generateLswNtpTimestamp

public static java.lang.Long generateLswNtpTimestamp(java.lang.Long time)
Decimal part of the NTP Timestamp. LSW = E(2^32 * (time & 0xF) / 1000)

Returns:
the time in seconds.

getPacketType

public java.lang.Integer getPacketType()
/** Returns the packet type. Here it is 200 or 201.

Specified by:
getPacketType in class RTCPPacket
Returns:
the packet type.

decodeSsrc

public static java.lang.Long decodeSsrc(byte[] data,
                                        java.lang.Integer offset)
Decode SSRC from a SR/RR report.

Parameters:
data - : the data to decode.
offset - : the beginning of the report.
Returns:
SSRC of the report.

decodeSrMswNtpTimestamp

public static java.lang.Long decodeSrMswNtpTimestamp(byte[] data,
                                                     java.lang.Integer offset)
Decode MSW Timestamp from a SR report.

Parameters:
data - : the data to decode.
offset - : the beginning of the report.
Returns:
MSW Timestamp of the report.

decodeSrLswNtpTimestamp

public static java.lang.Long decodeSrLswNtpTimestamp(byte[] data,
                                                     java.lang.Integer offset)
Decode LSW Timestamp from a SR report.

Parameters:
data - : the data to decode.
offset - : the beginning of the report.
Returns:
LSW Timestamp of the report.

setNewValues

public void setNewValues(java.lang.Long rtpTimestamp,
                         java.lang.Long packetCount,
                         java.lang.Long octetCount)
To add new value to the SR report.

Parameters:
rtpTimestamp - : the RTP timestamp of the last RTP packet (cf. RFC 3550 p31).
packetCount - : the number of packets since the beginning of the RTP session (cf. RFC 3550 p32).
octetCount - : the number of octets since the beginning of the RTP session (cf. RFC 3550 p32).