jlibrtp
Class RTCPSession

java.lang.Object
  extended by jlibrtp.RTCPSession

public class RTCPSession
extends java.lang.Object

This class acts as an organizer for most of the information and functions pertaining to RTCP packet generation and reception

Author:
Arne Kepp

Field Summary
protected  java.util.Hashtable<java.lang.Long,java.util.LinkedList<RtcpPktAPP>> appQueue
          APP queue , index is SSRC of target
protected  int avgPktSize
          The average compound RTCP packet size, in octets, including UDP and IP headers
protected  boolean fbAllowEarly
          Whether next RTCP packet can be sent early
protected  java.util.Hashtable<java.lang.Long,java.util.LinkedList<RtcpPkt>> fbQueue
          Feedback queue , index is SSRC of target
protected  long fbWaiting
          Is there a feedback packet waiting? SSRC of destination
protected  boolean initial
          Are we just starting up?
protected  java.net.InetAddress mcGroup
          Multicast group
protected  int nextDelay
          Delay between RTCP transmissions, in ms.
protected  long prevTime
          Previous time a delay was calculated
protected  RTCPReceiverThread recvThrd
          RTCP Receiver thread
protected  java.net.MulticastSocket rtcpMCSock
          Multicast socket
protected  java.net.DatagramSocket rtcpSock
          Unicast socket
protected  RTPSession rtpSession
          Parent session
protected  int senderCount
          Pessimistic case estimate of the current number of senders
protected  RTCPSenderThread senderThrd
          RTCP Sender thread
 
Constructor Summary
protected RTCPSession(RTPSession parent, java.net.DatagramSocket rtcpSocket)
          Constructor for unicast sessions
protected RTCPSession(RTPSession parent, java.net.MulticastSocket rtcpSocket, java.net.InetAddress multicastGroup)
          Constructor for multicast sessions
 
Method Summary
protected  void addToAppQueue(long targetSsrc, RtcpPktAPP aPkt)
          Adds an RTCP APP (application) packet to the queue
protected  int addToFbQueue(long targetSsrc, RtcpPkt aPkt)
          Check the feedback queue for similar packets and adds the new packet if it is not redundant
protected  void calculateDelay()
          Calculate the delay before the next RTCP packet can be sent
protected  void calculateRegularDelay()
          Calculates a delay value in accordance with RFC 3550
protected  void cleanAppQueue(long ssrc)
          Cleans the TCP APP (application) packet queues of any packets that are too old, defined as 60 seconds since insertion.
protected  void cleanFbQueue(long ssrc)
          Cleans the feeback queue of any packets that have expired, ie feedback packet that are no longer relevant.
private  boolean equivalent(RtcpPkt one, RtcpPkt two)
          Compares two packets to check whether they are equivalent feedback messages, to avoid sending the same feedback to a host twice.
protected  boolean fbSendEarly()
          Check whether the conditions are satisfied to send a feedbkac packet immediately.
protected  boolean fbSendImmediately()
          Check whether the conditions are satisfied to send a feedbkac packet immediately.
protected  RtcpPktAPP[] getFromAppQueue(long targetSsrc)
          Adds an RTCP APP (application) packet to the queue
protected  RtcpPkt[] getFromFbQueue(long ssrc)
          Checks whether there are ny feedback packets waiting to be sent.
protected  void sendByes()
          Send bye packets, handled by RTCP Sender thread
protected  void start()
          Starts the session, calculates delays and fires up the threads.
protected  void updateAvgPacket(int length)
          Update the average packet size
protected  void wakeSenderThread(long ssrc)
          Wake the sender thread because of this ssrc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rtpSession

protected RTPSession rtpSession
Parent session


rtcpSock

protected java.net.DatagramSocket rtcpSock
Unicast socket


rtcpMCSock

protected java.net.MulticastSocket rtcpMCSock
Multicast socket


mcGroup

protected java.net.InetAddress mcGroup
Multicast group


recvThrd

protected RTCPReceiverThread recvThrd
RTCP Receiver thread


senderThrd

protected RTCPSenderThread senderThrd
RTCP Sender thread


prevTime

protected long prevTime
Previous time a delay was calculated


nextDelay

protected int nextDelay
Delay between RTCP transmissions, in ms. Initialized in start()


avgPktSize

protected int avgPktSize
The average compound RTCP packet size, in octets, including UDP and IP headers


senderCount

protected int senderCount
Pessimistic case estimate of the current number of senders


fbAllowEarly

protected boolean fbAllowEarly
Whether next RTCP packet can be sent early


fbQueue

protected java.util.Hashtable<java.lang.Long,java.util.LinkedList<RtcpPkt>> fbQueue
Feedback queue , index is SSRC of target


appQueue

protected java.util.Hashtable<java.lang.Long,java.util.LinkedList<RtcpPktAPP>> appQueue
APP queue , index is SSRC of target


initial

protected boolean initial
Are we just starting up?


fbWaiting

protected long fbWaiting
Is there a feedback packet waiting? SSRC of destination

Constructor Detail

RTCPSession

protected RTCPSession(RTPSession parent,
                      java.net.DatagramSocket rtcpSocket)
Constructor for unicast sessions

Parameters:
parent - RTPSession that started this
rtcpSocket - the socket to use for listening and sending

RTCPSession

protected RTCPSession(RTPSession parent,
                      java.net.MulticastSocket rtcpSocket,
                      java.net.InetAddress multicastGroup)
Constructor for multicast sessions

Parameters:
parent - parent RTPSession
rtcpSocket - parent RTPSession that started this
multicastGroup - multicast group to bind the socket to
Method Detail

start

protected void start()
Starts the session, calculates delays and fires up the threads.


sendByes

protected void sendByes()
Send bye packets, handled by RTCP Sender thread


calculateDelay

protected void calculateDelay()
Calculate the delay before the next RTCP packet can be sent


calculateRegularDelay

protected void calculateRegularDelay()
Calculates a delay value in accordance with RFC 3550


updateAvgPacket

protected void updateAvgPacket(int length)
Update the average packet size

Parameters:
length - of latest packet

addToAppQueue

protected void addToAppQueue(long targetSsrc,
                             RtcpPktAPP aPkt)
Adds an RTCP APP (application) packet to the queue

Parameters:
targetSsrc - the SSRC of the recipient
aPkt -

getFromAppQueue

protected RtcpPktAPP[] getFromAppQueue(long targetSsrc)
Adds an RTCP APP (application) packet to the queue

Parameters:
targetSsrc - the SSRC of the recipient
Returns:
array of RTCP Application packets

cleanAppQueue

protected void cleanAppQueue(long ssrc)
Cleans the TCP APP (application) packet queues of any packets that are too old, defined as 60 seconds since insertion.

Parameters:
ssrc - The SSRC of the user who has left, negative value -> general cleanup

addToFbQueue

protected int addToFbQueue(long targetSsrc,
                           RtcpPkt aPkt)
Check the feedback queue for similar packets and adds the new packet if it is not redundant

Parameters:
aPkt -
Returns:
0 if the packet was added, 1 if it was dropped

getFromFbQueue

protected RtcpPkt[] getFromFbQueue(long ssrc)
Checks whether there are ny feedback packets waiting to be sent.

Parameters:
ssrc - of the participant we are notifying
Returns:
all relevant feedback packets, or null

cleanFbQueue

protected void cleanFbQueue(long ssrc)
Cleans the feeback queue of any packets that have expired, ie feedback packet that are no longer relevant.

Parameters:
ssrc - The SSRC of the user who has left, negative value -> general cleanup

fbSendImmediately

protected boolean fbSendImmediately()
Check whether the conditions are satisfied to send a feedbkac packet immediately.

Returns:
true if they are, false otherwise

fbSendEarly

protected boolean fbSendEarly()
Check whether the conditions are satisfied to send a feedbkac packet immediately.

Returns:
true if they are, false otherwise

wakeSenderThread

protected void wakeSenderThread(long ssrc)
Wake the sender thread because of this ssrc

Parameters:
ssrc - that has feedback waiting.

equivalent

private boolean equivalent(RtcpPkt one,
                           RtcpPkt two)
Compares two packets to check whether they are equivalent feedback messages, to avoid sending the same feedback to a host twice. Expect false negatives, but not false positives.

Parameters:
one - packet
two - packet
Returns:
true if they are equivalent, false otherwise