Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia
Class RTPConnectorImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.RTPConnectorImpl
All Implemented Interfaces:
javax.media.rtp.RTPConnector
Direct Known Subclasses:
RTPTransformConnector

public class RTPConnectorImpl
extends Object
implements javax.media.rtp.RTPConnector

Author:
Bing SU (nova.su@gmail.com), Lubomir Marinov

Constructor Summary
RTPConnectorImpl(StreamConnector connector)
          Initializes a new RTPConnectorImpl which is to use a given pair of datagram sockets for RTP and RTCP traffic specified in the form of a StreamConnector.
 
Method Summary
 void addTarget(javax.media.rtp.SessionAddress target)
          Add a stream target.
 void close()
          Closes all sockets, stream, and the StreamConnector that this RTPConnector is using.
protected  RTPConnectorInputStream createControlInputStream()
          Creates the RTCP packet input stream to be used by RTPManager.
protected  RTPConnectorOutputStream createControlOutputStream()
          Creates the RTCP packet output stream to be used by RTPManager.
protected  RTPConnectorInputStream createDataInputStream()
          Creates the RTP packet input stream to be used by RTPManager.
protected  RTPConnectorOutputStream createDataOutputStream()
          Creates the RTP packet output stream to be used by RTPManager.
 StreamConnector getConnector()
          Gets the StreamConnector which represents the pair of datagram sockets for RTP and RTCP traffic used by this instance.
 RTPConnectorInputStream getControlInputStream()
          Returns the input stream that is handling incoming RTCP packets.
protected  RTPConnectorInputStream getControlInputStream(boolean create)
          Gets the PushSourceStream which gives access to the RTCP data received from the remote targets and optionally creates it if it does not exist yet.
 RTPConnectorOutputStream getControlOutputStream()
          Returns the input stream that is handling outgoing RTCP packets.
protected  RTPConnectorOutputStream getControlOutputStream(boolean create)
          Gets the OutputDataStream which is used to write RTCP data to be sent to from the remote targets and optionally creates it if it does not exist yet.
 DatagramSocket getControlSocket()
          Gets the UDP Socket this instance uses to send and receive RTCP packets.
 RTPConnectorInputStream getDataInputStream()
          Returns the input stream that is handling incoming RTP packets.
protected  RTPConnectorInputStream getDataInputStream(boolean create)
          Gets the PushSourceStream which gives access to the RTP data received from the remote targets and optionally creates it if it does not exist yet.
 RTPConnectorOutputStream getDataOutputStream()
          Returns the input stream that is handling outgoing RTP packets.
 RTPConnectorOutputStream getDataOutputStream(boolean create)
          Gets the OutputDataStream which is used to write RTP data to be sent to from the remote targets and optionally creates it if it does not exist yet.
 DatagramSocket getDataSocket()
          Gets the UDP socket this instance uses to send and receive RTP packets.
 int getReceiveBufferSize()
          Provides a dummy implementation to RTPConnector.getReceiveBufferSize() that always returns -1.
 double getRTCPBandwidthFraction()
          Provides a dummy implementation to RTPConnector.getRTCPBandwidthFraction() that always returns -1.
 double getRTCPSenderBandwidthFraction()
          Provides a dummy implementation to RTPConnector.getRTCPSenderBandwidthFraction() that always returns -1.
 int getSendBufferSize()
          Provides a dummy implementation to RTPConnector.getSendBufferSize() that always returns -1.
 void removeTarget(javax.media.rtp.SessionAddress target)
          Removes a target from our session.
 void removeTargets()
          Remove all stream targets.
 void setReceiveBufferSize(int size)
          Provides a dummy implementation to RTPConnector.setReceiveBufferSize(int).
 void setSendBufferSize(int size)
          Provides a dummy implementation to RTPConnector.setSendBufferSize(int).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RTPConnectorImpl

public RTPConnectorImpl(StreamConnector connector)
Initializes a new RTPConnectorImpl which is to use a given pair of datagram sockets for RTP and RTCP traffic specified in the form of a StreamConnector.

Parameters:
connector - the pair of datagram sockets for RTP and RTCP traffic the new instance is to use
Method Detail

addTarget

public void addTarget(javax.media.rtp.SessionAddress target)
               throws IOException
Add a stream target. A stream target is the destination address which this RTP session will send its data to. For a single session, we can add multiple SessionAddresses, and for each address, one copy of data will be sent to.

Parameters:
target - Destination target address
Throws:
IOException - if there was a socket-related error while adding the specified target

close

public void close()
Closes all sockets, stream, and the StreamConnector that this RTPConnector is using.

Specified by:
close in interface javax.media.rtp.RTPConnector

createControlInputStream

protected RTPConnectorInputStream createControlInputStream()
                                                    throws IOException
Creates the RTCP packet input stream to be used by RTPManager.

Returns:
a new RTCP packet input stream to be used by RTPManager
Throws:
IOException - if an error occurs during the creation of the RTCP packet input stream

createControlOutputStream

protected RTPConnectorOutputStream createControlOutputStream()
                                                      throws IOException
Creates the RTCP packet output stream to be used by RTPManager.

Returns:
a new RTCP packet output stream to be used by RTPManager
Throws:
IOException - if an error occurs during the creation of the RTCP packet output stream

createDataInputStream

protected RTPConnectorInputStream createDataInputStream()
                                                 throws IOException
Creates the RTP packet input stream to be used by RTPManager.

Returns:
a new RTP packet input stream to be used by RTPManager
Throws:
IOException - if an error occurs during the creation of the RTP packet input stream

createDataOutputStream

protected RTPConnectorOutputStream createDataOutputStream()
                                                   throws IOException
Creates the RTP packet output stream to be used by RTPManager.

Returns:
a new RTP packet output stream to be used by RTPManager
Throws:
IOException - if an error occurs during the creation of the RTP packet output stream

getConnector

public final StreamConnector getConnector()
Gets the StreamConnector which represents the pair of datagram sockets for RTP and RTCP traffic used by this instance.

Returns:
the StreamConnector which represents the pair of datagram sockets for RTP and RTCP traffic used by this instance

getControlInputStream

public RTPConnectorInputStream getControlInputStream()
                                              throws IOException
Returns the input stream that is handling incoming RTCP packets.

Specified by:
getControlInputStream in interface javax.media.rtp.RTPConnector
Returns:
the input stream that is handling incoming RTCP packets.
Throws:
IOException - if an error occurs during the creation of the RTCP packet input stream

getControlInputStream

protected RTPConnectorInputStream getControlInputStream(boolean create)
                                                 throws IOException
Gets the PushSourceStream which gives access to the RTCP data received from the remote targets and optionally creates it if it does not exist yet.

Parameters:
create - true to create the PushSourceStream which gives access to the RTCP data received from the remote targets if it does not exist yet; otherwise, false
Returns:
the PushBufferStream which gives access to the RTCP data received from the remote targets; null if it does not exist yet and create is false
Throws:
IOException - if creating the PushSourceStream fails

getControlOutputStream

public RTPConnectorOutputStream getControlOutputStream()
                                                throws IOException
Returns the input stream that is handling outgoing RTCP packets.

Specified by:
getControlOutputStream in interface javax.media.rtp.RTPConnector
Returns:
the input stream that is handling outgoing RTCP packets.
Throws:
IOException - if an error occurs during the creation of the RTCP packet output stream

getControlOutputStream

protected RTPConnectorOutputStream getControlOutputStream(boolean create)
                                                   throws IOException
Gets the OutputDataStream which is used to write RTCP data to be sent to from the remote targets and optionally creates it if it does not exist yet.

Parameters:
create - true to create the OutputDataStream which is to be used to write RTCP data to be sent to the remote targets if it does not exist yet; otherwise, false
Returns:
the OutputDataStream which is used to write RTCP data to be sent to the remote targets; null if it does not exist yet and create is false
Throws:
IOException - if creating the OutputDataStream fails

getControlSocket

public DatagramSocket getControlSocket()
Gets the UDP Socket this instance uses to send and receive RTCP packets.

Returns:
the UDP Socket this instance uses to send and receive RTCP packets

getDataInputStream

public RTPConnectorInputStream getDataInputStream()
                                           throws IOException
Returns the input stream that is handling incoming RTP packets.

Specified by:
getDataInputStream in interface javax.media.rtp.RTPConnector
Returns:
the input stream that is handling incoming RTP packets.
Throws:
IOException - if an error occurs during the creation of the RTP packet input stream

getDataInputStream

protected RTPConnectorInputStream getDataInputStream(boolean create)
                                              throws IOException
Gets the PushSourceStream which gives access to the RTP data received from the remote targets and optionally creates it if it does not exist yet.

Parameters:
create - true to create the PushSourceStream which gives access to the RTP data received from the remote targets if it does not exist yet; otherwise, false
Returns:
the PushBufferStream which gives access to the RTP data received from the remote targets; null if it does not exist yet and create is false
Throws:
IOException - if creating the PushSourceStream fails

getDataOutputStream

public RTPConnectorOutputStream getDataOutputStream()
                                             throws IOException
Returns the input stream that is handling outgoing RTP packets.

Specified by:
getDataOutputStream in interface javax.media.rtp.RTPConnector
Returns:
the input stream that is handling outgoing RTP packets.
Throws:
IOException - if an error occurs during the creation of the RTP

getDataOutputStream

public RTPConnectorOutputStream getDataOutputStream(boolean create)
                                             throws IOException
Gets the OutputDataStream which is used to write RTP data to be sent to from the remote targets and optionally creates it if it does not exist yet.

Parameters:
create - true to create the OutputDataStream which is to be used to write RTP data to be sent to the remote targets if it does not exist yet; otherwise, false
Returns:
the OutputDataStream which is used to write RTP data to be sent to the remote targets; null if it does not exist yet and create is false
Throws:
IOException - if creating the OutputDataStream fails

getDataSocket

public DatagramSocket getDataSocket()
Gets the UDP socket this instance uses to send and receive RTP packets.

Returns:
the UDP socket this instance uses to send and receive RTP packets

getReceiveBufferSize

public int getReceiveBufferSize()
Provides a dummy implementation to RTPConnector.getReceiveBufferSize() that always returns -1.

Specified by:
getReceiveBufferSize in interface javax.media.rtp.RTPConnector

getRTCPBandwidthFraction

public double getRTCPBandwidthFraction()
Provides a dummy implementation to RTPConnector.getRTCPBandwidthFraction() that always returns -1.

Specified by:
getRTCPBandwidthFraction in interface javax.media.rtp.RTPConnector

getRTCPSenderBandwidthFraction

public double getRTCPSenderBandwidthFraction()
Provides a dummy implementation to RTPConnector.getRTCPSenderBandwidthFraction() that always returns -1.

Specified by:
getRTCPSenderBandwidthFraction in interface javax.media.rtp.RTPConnector

getSendBufferSize

public int getSendBufferSize()
Provides a dummy implementation to RTPConnector.getSendBufferSize() that always returns -1.

Specified by:
getSendBufferSize in interface javax.media.rtp.RTPConnector

removeTarget

public void removeTarget(javax.media.rtp.SessionAddress target)
Removes a target from our session. If a target is removed, there will be no data sent to that address.

Parameters:
target - Destination target to be removed

removeTargets

public void removeTargets()
Remove all stream targets. After this operation is done. There will be no targets receiving data, so no data will be sent.


setReceiveBufferSize

public void setReceiveBufferSize(int size)
                          throws IOException
Provides a dummy implementation to RTPConnector.setReceiveBufferSize(int).

Specified by:
setReceiveBufferSize in interface javax.media.rtp.RTPConnector
Parameters:
size - ignored.
Throws:
IOException

setSendBufferSize

public void setSendBufferSize(int size)
                       throws IOException
Provides a dummy implementation to RTPConnector.setSendBufferSize(int).

Specified by:
setSendBufferSize in interface javax.media.rtp.RTPConnector
Parameters:
size - ignored.
Throws:
IOException

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.