jlibrtp
Class ParticipantDatabase

java.lang.Object
  extended by jlibrtp.ParticipantDatabase

public class ParticipantDatabase
extends java.lang.Object

The participant database maintains three hashtables with participants. The key issue is to be fast for operations that happen every time an RTP packet is sent or received. We allow linear searching in cases where we need to update participants with information. The keying is therefore usually the SSRC. In cases where we have the cname, but no SSRC is known (no SDES packet has been received), a simple hash i calculated based on the CNAME. The RTCP code should, when receiving SDES packets, check whether the participant is known and update the copy in this database with SSRC if needed.

Author:
Arne Kepp

Field Summary
(package private)  java.util.LinkedList<Participant> receivers
          A linked list to hold participants explicitly added by the application In unicast mode this is the list used for RTP and RTCP transmission, in multicast it should not be in use.
(package private)  RTPSession rtpSession
          The parent RTP Session
(package private)  java.util.concurrent.ConcurrentHashMap<java.lang.Long,Participant> ssrcTable
          The hashtable holds participants added through received RTP and RTCP packets, as well as participants that have been linked to an SSRC by ip address (in unicast mode).
 
Constructor Summary
protected ParticipantDatabase(RTPSession parent)
          Simple constructor
 
Method Summary
protected  int addParticipant(int cameFrom, Participant p)
           
private  int addParticipantMulticast(int cameFrom, Participant p)
          Add a multicast participant to the database
private  int addParticipantUnicast(int cameFrom, Participant p)
          Add a unicast participant to the database Result will be reported back through tpSession.appIntf.userEvent
protected  void debugPrint()
           
protected  Participant getParticipant(long ssrc)
          Find a participant based on the ssrc
protected  java.util.Enumeration<Participant> getParticipants()
          Enumeration of all the participants with known ssrcs.
protected  java.util.Iterator<Participant> getUnicastReceivers()
          Iterator for all the unicast receivers.
protected  void removeParticipant(Participant p)
          Remove a participant from all tables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rtpSession

RTPSession rtpSession
The parent RTP Session


receivers

java.util.LinkedList<Participant> receivers
A linked list to hold participants explicitly added by the application In unicast mode this is the list used for RTP and RTCP transmission, in multicast it should not be in use.


ssrcTable

java.util.concurrent.ConcurrentHashMap<java.lang.Long,Participant> ssrcTable
The hashtable holds participants added through received RTP and RTCP packets, as well as participants that have been linked to an SSRC by ip address (in unicast mode).

Constructor Detail

ParticipantDatabase

protected ParticipantDatabase(RTPSession parent)
Simple constructor

Parameters:
parent - parent RTPSession
Method Detail

addParticipant

protected int addParticipant(int cameFrom,
                             Participant p)
Parameters:
cameFrom - 0: Application, 1: RTP packet, 2: RTCP
p - the participant
Returns:
0 if okay, -1 if not

addParticipantMulticast

private int addParticipantMulticast(int cameFrom,
                                    Participant p)
Add a multicast participant to the database

Parameters:
cameFrom - 0: Application, 1,2: discovered through RTP or RTCP
p - the participant to add
Returns:
0 if okay, -2 if redundant, -1 if adding participant to multicast

addParticipantUnicast

private int addParticipantUnicast(int cameFrom,
                                  Participant p)
Add a unicast participant to the database Result will be reported back through tpSession.appIntf.userEvent

Parameters:
cameFrom - 0: Application, 1,2: discovered through RTP or RTCP
p - the participant to add
Returns:
0 if okay

removeParticipant

protected void removeParticipant(Participant p)
Remove a participant from all tables

Parameters:
p - the participant to be removed

getParticipant

protected Participant getParticipant(long ssrc)
Find a participant based on the ssrc

Parameters:
ssrc - of the participant to be found
Returns:
the participant, null if unknonw

getUnicastReceivers

protected java.util.Iterator<Participant> getUnicastReceivers()
Iterator for all the unicast receivers. This one is used by both RTP for sending packets, as well as RTCP.

Returns:
iterator for unicast participants

getParticipants

protected java.util.Enumeration<Participant> getParticipants()
Enumeration of all the participants with known ssrcs. This is primarily used for sending packets in multicast sessions.

Returns:
enumerator with all the participants with known SSRCs

debugPrint

protected void debugPrint()