net.sf.fmj.media.rtp
Class RTPSocketAdapter

java.lang.Object
  extended by net.sf.fmj.media.rtp.RTPSocketAdapter
All Implemented Interfaces:
RTPConnector

public class RTPSocketAdapter
extends java.lang.Object
implements RTPConnector

An implementation of RTPConnector based on UDP sockets.

Version:
1-1-alpha2
Author:
Andrew G D Rowley, Christian Vincenot

Constructor Summary
RTPSocketAdapter(java.net.InetAddress addr, int port)
          Creates a new RTPSocketAdaptor with TTL 1
RTPSocketAdapter(java.net.InetAddress addr, int port, int ttl)
          Creates a new RTPSocketAdaptor
 
Method Summary
 void addTarget(SessionAddress target)
          Add a stream target.
 void close()
          Close all the RTP, RTCP streams.
 PushSourceStream getControlInputStream()
          Returns an input stream to receive the RTCP data.
 OutputDataStream getControlOutputStream()
          Returns an output stream to send the RTCP data.
 PushSourceStream getDataInputStream()
          Returns an input stream to receive the RTP data.
 OutputDataStream getDataOutputStream()
          Returns an output stream to send the RTP data.
 int getReceiveBufferSize()
          Get the receive buffer size set on the RTP data channel.
 double getRTCPBandwidthFraction()
          Return the RTCP bandwidth fraction.
 double getRTCPSenderBandwidthFraction()
          Return the RTCP sender bandwidth fraction.
 int getSendBufferSize()
          Get the send buffer size set on the RTP data channel.
 boolean removeTarget(SessionAddress target)
          Removes a target from our session.
 void removeTargets()
          Remove all stream targets.
 void setEncryption(RTPCrypt crypter)
          Sets the encryption on the socket
 void setReceiveBufferSize(int size)
          Set the receive buffer size of the RTP data channel.
 void setSendBufferSize(int size)
          Set the send buffer size of the RTP data channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RTPSocketAdapter

public RTPSocketAdapter(java.net.InetAddress addr,
                        int port)
                 throws java.io.IOException
Creates a new RTPSocketAdaptor with TTL 1

Parameters:
addr - The address of the socket
port - The port of the socket (data)
Throws:
java.io.IOException - I/O Exception

RTPSocketAdapter

public RTPSocketAdapter(java.net.InetAddress addr,
                        int port,
                        int ttl)
                 throws java.io.IOException
Creates a new RTPSocketAdaptor

Parameters:
laddr - The local address to bind to
addr - The address of the socket
port - The port of the socket
ttl - The ttl for sending data
Throws:
java.io.IOException - I/O Exception
Method Detail

setEncryption

public void setEncryption(RTPCrypt crypter)
Sets the encryption on the socket

Parameters:
crypter - The encrypter/decrypter

getDataInputStream

public PushSourceStream getDataInputStream()
Returns an input stream to receive the RTP data.

Specified by:
getDataInputStream in interface RTPConnector
Returns:
input stream to receive the RTP data

addTarget

public void addTarget(SessionAddress target)
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

getDataOutputStream

public OutputDataStream getDataOutputStream()
Returns an output stream to send the RTP data.

Specified by:
getDataOutputStream in interface RTPConnector
Returns:
output stream to send the RTP data

getControlInputStream

public PushSourceStream getControlInputStream()
Returns an input stream to receive the RTCP data.

Specified by:
getControlInputStream in interface RTPConnector
Returns:
input stream to receive the RTCP data

getControlOutputStream

public OutputDataStream getControlOutputStream()
Returns an output stream to send the RTCP data.

Specified by:
getControlOutputStream in interface RTPConnector
Returns:
an output stream to send the RTCP data

close

public void close()
Close all the RTP, RTCP streams.

Specified by:
close in interface RTPConnector

removeTarget

public boolean removeTarget(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
Returns:
true if the target address is removed successfully false if there is something wrong

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 java.io.IOException
Set the receive buffer size of the RTP data channel. This is only a hint to the implementation. The actual implementation may not be able to do anything to this.

Specified by:
setReceiveBufferSize in interface RTPConnector
Parameters:
size - the wanted size of the buffer
Throws:
java.io.IOException - I/O Exception

getReceiveBufferSize

public int getReceiveBufferSize()
Get the receive buffer size set on the RTP data channel. Return -1 if the receive buffer size is not applicable for the implementation.

Specified by:
getReceiveBufferSize in interface RTPConnector
Returns:
the buffer's size

setSendBufferSize

public void setSendBufferSize(int size)
                       throws java.io.IOException
Set the send buffer size of the RTP data channel. This is only a hint to the implementation. The actual implementation may not be able to do anything to this.

Specified by:
setSendBufferSize in interface RTPConnector
Parameters:
size - the wanted size of the buffer
Throws:
java.io.IOException - I/O Exception

getSendBufferSize

public int getSendBufferSize()
Get the send buffer size set on the RTP data channel. Return -1 if the send buffer size is not applicable for the implementation.

Specified by:
getSendBufferSize in interface RTPConnector
Returns:
the buffer's size

getRTCPBandwidthFraction

public double getRTCPBandwidthFraction()
Return the RTCP bandwidth fraction. This value is used to initialize the RTPManager. Check RTPManager for more detauls. Return -1 to use the default values.

Specified by:
getRTCPBandwidthFraction in interface RTPConnector
Returns:
the bandwidth fraction allocated for RTCP traffic

getRTCPSenderBandwidthFraction

public double getRTCPSenderBandwidthFraction()
Return the RTCP sender bandwidth fraction. This value is used to initialize the RTPManager. Check RTPManager for more detauls. Return -1 to use the default values.

Specified by:
getRTCPSenderBandwidthFraction in interface RTPConnector
Returns:
the RTCP bandwidth fraction allocated for senders' traffic