jlibrtpDemos
Class XmlPacketRecorder

java.lang.Object
  extended by jlibrtpDemos.XmlPacketRecorder
All Implemented Interfaces:
DebugAppIntf, RTCPAppIntf, RTPAppIntf

public class XmlPacketRecorder
extends java.lang.Object
implements RTPAppIntf, RTCPAppIntf, DebugAppIntf

Author:
Arne Kepp

Field Summary
(package private)  int dataCount
           
(package private)  int maxPacketCount
           
(package private)  boolean noBye
           
(package private)  int packetCount
           
(package private)  int pktCount
           
(package private)  RTPSession rtpSession
           
(package private)  org.jdom.Document sessionDocument
           
(package private)  org.jdom.Element sessionElement
           
 
Constructor Summary
XmlPacketRecorder(int rtpPortNum, int rtcpPortNum, int maxPacketCount)
          Constructor
 
Method Summary
 void APPPktReceived(Participant part, int subtype, byte[] name, byte[] data)
          This function is called whenever an Application (APP) packet is received.
 void BYEPktReceived(Participant[] relevantParticipants, java.lang.String reason)
          This function is called whenever a Bye (BYE) packet is received.
 void createDocument()
          Creates the document instance that will hold all other elements.
 int frameSize(int payloadType)
          The callback method through which the application can specify the number of packets that make up a frame for a given payload type.
 void importantEvent(int type, java.lang.String description)
          Other important events that can occur in session -1 SSRC conflict 0 Session is terminating
static void main(java.lang.String[] args)
           
 void packetReceived(int type, java.net.InetSocketAddress socket, java.lang.String description)
          This function wil notify you of any packets received, valid or not.
 void packetSent(int type, java.net.InetSocketAddress socket, java.lang.String description)
          This function will notify you of any packets sent from this instance of RTPSession.
 void receiveData(DataFrame frame, Participant part)
          RTP
 void RRPktReceived(long reporterSsrc, long[] reporteeSsrc, int[] lossFraction, int[] cumulPacketsLost, long[] extHighSeq, long[] interArrivalJitter, long[] lastSRTimeStamp, long[] delayLastSR)
          This function is called whenever a Receiver Report (SR) packet is received and returns unmodified values.
 void SDESPktReceived(Participant[] relevantParticipants)
          This function is called whenever a Source Description (SDES) packet is received.
 void SRPktReceived(long ssrc, long ntpHighOrder, long ntpLowOrder, long rtpTimestamp, long packetCount, long octetCount, long[] reporteeSsrc, int[] lossFraction, int[] cumulPacketsLost, long[] extHighSeq, long[] interArrivalJitter, long[] lastSRTimeStamp, long[] delayLastSR)
          RTCP
 void userEvent(int type, Participant[] participant)
          The callback method through which the application will receive notifications about user updates, additions and byes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rtpSession

RTPSession rtpSession

packetCount

int packetCount

maxPacketCount

int maxPacketCount

noBye

boolean noBye

dataCount

int dataCount

pktCount

int pktCount

sessionDocument

org.jdom.Document sessionDocument

sessionElement

org.jdom.Element sessionElement
Constructor Detail

XmlPacketRecorder

public XmlPacketRecorder(int rtpPortNum,
                         int rtcpPortNum,
                         int maxPacketCount)
Constructor

Method Detail

packetReceived

public void packetReceived(int type,
                           java.net.InetSocketAddress socket,
                           java.lang.String description)
Description copied from interface: DebugAppIntf
This function wil notify you of any packets received, valid or not. Useful for network debugging, and finding bugs in jlibrtp. Type is an integer describing the type of event -2 - Invalid RTCP packet received -1 - Invalid RTP packet received 0 - RTP packet received 1 - RTCP packet received Description is a string that should be meaningful to advanced users, such as "RTP packet received from 127.0.0.1:12312, SSRC: 1380912 , payload type 1, packet size 16 octets" or "Invalid RTP packet received from 127.0.0.1:12312" This function is synchonous and should return quickly.

Specified by:
packetReceived in interface DebugAppIntf
Parameters:
type - , the type of event, see above.
socket - , taken directly from the UDP packet
description - , see above.

packetSent

public void packetSent(int type,
                       java.net.InetSocketAddress socket,
                       java.lang.String description)
Description copied from interface: DebugAppIntf
This function will notify you of any packets sent from this instance of RTPSession. Useful for network debugging, and finding bugs in jlibrtp. Type is an integer describing the type of event 0 - RTP unicast packet sent 1 - RTP multicast packet sent 2 - RTCP unicast packet sent 3 - RTCP multicast packet sent Description is a string that should be meaningful to advanced users, such as This function is synchonous and should return quickly.

Specified by:
packetSent in interface DebugAppIntf
Parameters:
type - , the type of event, see above
socket - , taken directly from the UDP packet
description - , see above

importantEvent

public void importantEvent(int type,
                           java.lang.String description)
Description copied from interface: DebugAppIntf
Other important events that can occur in session -1 SSRC conflict 0 Session is terminating

Specified by:
importantEvent in interface DebugAppIntf
Parameters:
type - see above
description - , see above

SRPktReceived

public void SRPktReceived(long ssrc,
                          long ntpHighOrder,
                          long ntpLowOrder,
                          long rtpTimestamp,
                          long packetCount,
                          long octetCount,
                          long[] reporteeSsrc,
                          int[] lossFraction,
                          int[] cumulPacketsLost,
                          long[] extHighSeq,
                          long[] interArrivalJitter,
                          long[] lastSRTimeStamp,
                          long[] delayLastSR)
RTCP

Specified by:
SRPktReceived in interface RTCPAppIntf
Parameters:
ssrc - the (SR) SSRC of the sender
ntpHighOrder - (SR) NTP high order
ntpLowOrder - (SR) NTP low order
rtpTimestamp - (SR) RTP timestamp corresponding to the NTP timestamp
packetCount - (SR) Packets sent since start of session
octetCount - (SR) Octets sent since start of session
reporteeSsrc - (RR) SSRC of sender the receiver is reporting in
lossFraction - (RR) Loss fraction, see RFC 3550
cumulPacketsLost - (RR) Cumulative number of packets lost
extHighSeq - (RR) Extended highest sequence RTP packet received
interArrivalJitter - (RR) Interarrival jitter, see RFC 3550
lastSRTimeStamp - (RR) RTP timestamp when last SR was received
delayLastSR - (RR) Delay, in RTP, since last SR was received

RRPktReceived

public void RRPktReceived(long reporterSsrc,
                          long[] reporteeSsrc,
                          int[] lossFraction,
                          int[] cumulPacketsLost,
                          long[] extHighSeq,
                          long[] interArrivalJitter,
                          long[] lastSRTimeStamp,
                          long[] delayLastSR)
Description copied from interface: RTCPAppIntf
This function is called whenever a Receiver Report (SR) packet is received and returns unmodified values. A receiver report may optionally include report blocks, which are returned as arrays. Index i corresponds to the same report throughout all of the arrays.

Specified by:
RRPktReceived in interface RTCPAppIntf
Parameters:
reporterSsrc - SSRC of the receiver reporting
reporteeSsrc - (RR) SSRC of sender the receiver is reporting in
lossFraction - (RR) Loss fraction, see RFC 3550
cumulPacketsLost - (RR) Cumulative number of packets lost
extHighSeq - (RR) Extended highest sequence RTP packet received
interArrivalJitter - (RR) Interarrival jitter, see RFC 3550
lastSRTimeStamp - (RR) RTP timestamp when last SR was received
delayLastSR - (RR) Delay, in RTP, since last SR was received

SDESPktReceived

public void SDESPktReceived(Participant[] relevantParticipants)
Description copied from interface: RTCPAppIntf
This function is called whenever a Source Description (SDES) packet is received. It currently returns the updated participants AFTER they have been updated.

Specified by:
SDESPktReceived in interface RTCPAppIntf
Parameters:
relevantParticipants - participants mentioned in the SDES packet

BYEPktReceived

public void BYEPktReceived(Participant[] relevantParticipants,
                           java.lang.String reason)
Description copied from interface: RTCPAppIntf
This function is called whenever a Bye (BYE) packet is received. The participants will automatically be deleted from the participant database after some time, but in the mean time the application may still receive RTP packets from this source.

Specified by:
BYEPktReceived in interface RTCPAppIntf
Parameters:
relevantParticipants - participants whose SSRC was in the packet
reason - the reason provided in the packet

APPPktReceived

public void APPPktReceived(Participant part,
                           int subtype,
                           byte[] name,
                           byte[] data)
Description copied from interface: RTCPAppIntf
This function is called whenever an Application (APP) packet is received.

Specified by:
APPPktReceived in interface RTCPAppIntf
Parameters:
part - the participant associated with the SSRC
subtype - specified in the packet
name - ASCII description of packet
data - in the packet

receiveData

public void receiveData(DataFrame frame,
                        Participant part)
RTP

Specified by:
receiveData in interface RTPAppIntf
Parameters:
frame - the frame containing the data
part - the participant from which the data came

userEvent

public void userEvent(int type,
                      Participant[] participant)
Description copied from interface: RTPAppIntf
The callback method through which the application will receive notifications about user updates, additions and byes. Types: 1 - Bye 2 - New through RTP, check .getRtpSendSock() 3 - New through RTCP, check .getRtcpSendSock() 4 - SDES packet received, check the getCname() etc methods 5 - Matched SSRC to ip-address provided by application

Specified by:
userEvent in interface RTPAppIntf
Parameters:
type - the type of event
participant - the participants in question

frameSize

public int frameSize(int payloadType)
Description copied from interface: RTPAppIntf
The callback method through which the application can specify the number of packets that make up a frame for a given payload type. A negative value denotes frames of variable length, so jlibrtp will return whatever it has at the time. In most applications, this function can simply return 1. This should be implemented as something fast, such as an integer array with the indeces being the payload type.

Specified by:
frameSize in interface RTPAppIntf
Parameters:
payloadType - the payload type specified in the RTP packet
Returns:
the number of packets that make up a frame

createDocument

public void createDocument()
Creates the document instance that will hold all other elements.


main

public static void main(java.lang.String[] args)