org.mobicents.media.server.impl.rtp
Class RtpFactory

java.lang.Object
  extended by org.mobicents.media.server.impl.rtp.RtpFactory
All Implemented Interfaces:
org.mobicents.media.server.spi.rtp.RtpManager

public class RtpFactory
extends java.lang.Object
implements org.mobicents.media.server.spi.rtp.RtpManager

Author:
Oleg Kulikov, amit bhayani

Field Summary
protected  org.mobicents.media.server.spi.rtp.RtpListener listener
          RTP event listener
protected  java.net.InetSocketAddress publicAddress
           
protected  BufferConcurrentLinkedQueue<RtpSocketImpl> registerQueue
          Queue for socket registration
 
Constructor Summary
RtpFactory()
          Creates RTP Factory instance
 
Method Summary
 org.mobicents.media.server.spi.rtp.AVProfile getAVProfile()
          Gets currently used Audio/Video profile.
 java.lang.String getBindAddress()
          Gets the IP address to which trunk is bound.
 RtpClock getClock(org.mobicents.media.server.spi.MediaType media)
          Gets RTP clocks for specified media type.
 java.util.Hashtable<org.mobicents.media.server.spi.MediaType,java.util.List<org.mobicents.media.server.spi.dsp.CodecFactory>> getCodecs()
          Gets list of assigned codecs.
 int getHighPort()
          Gets the maximum available port number.
 java.lang.Integer getJitter()
          Gets the size of the jitter buffer in milliseconds.
 org.mobicents.media.server.spi.rtp.RtpListener getListener()
           
 int getLowPort()
          Gets the minimum available port number.
protected  int getNextPort()
          Get the next port to be used by the RtpSocket to bind Socket to passed port.
 org.mobicents.media.server.spi.rtp.RtpSocket getRTPSocket(org.mobicents.media.server.spi.MediaType media)
          Constructs new RTP socket for the specified media type.
 java.lang.String getStunAddress()
          Gets the address of stun server if present.
 boolean isActive()
           
protected  void notify(java.lang.Exception e)
           
protected  void register()
          Registers sockets in the receiver.
 void setAVProfile(org.mobicents.media.server.spi.rtp.AVProfile avProfile)
          Modify audio/video profile.
 void setBindAddress(java.lang.String bindAddress)
          Modify the bind address.
 void setCodecs(java.util.Hashtable<org.mobicents.media.server.spi.MediaType,java.util.List<org.mobicents.media.server.spi.dsp.CodecFactory>> codecFactories)
          Modify list of codecs.
 void setHighPort(int port)
          Modifies maximum available port
 void setJitter(java.lang.Integer jitter)
          Modify size of the jitter buffer.
 void setListener(org.mobicents.media.server.spi.rtp.RtpListener listener)
           
 void setLowPort(int lowPort)
          Modifies minimum available port
 void setStunAddress(java.lang.String address)
          Assigns address of the STUN server.
 void start(long now)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

publicAddress

protected java.net.InetSocketAddress publicAddress

registerQueue

protected BufferConcurrentLinkedQueue<RtpSocketImpl> registerQueue
Queue for socket registration


listener

protected org.mobicents.media.server.spi.rtp.RtpListener listener
RTP event listener

Constructor Detail

RtpFactory

public RtpFactory()
Creates RTP Factory instance

Method Detail

setListener

public void setListener(org.mobicents.media.server.spi.rtp.RtpListener listener)
Specified by:
setListener in interface org.mobicents.media.server.spi.rtp.RtpManager

getListener

public org.mobicents.media.server.spi.rtp.RtpListener getListener()
Specified by:
getListener in interface org.mobicents.media.server.spi.rtp.RtpManager

notify

protected void notify(java.lang.Exception e)

getStunAddress

public java.lang.String getStunAddress()
Gets the address of stun server if present.

Returns:
the address of stun server or null if not assigned.

setStunAddress

public void setStunAddress(java.lang.String address)
Assigns address of the STUN server.

Parameters:
address - the address of the stun server in format host[:port]. if port is not set then default port is used.

start

public void start(long now)
           throws java.net.SocketException,
                  java.io.IOException
Specified by:
start in interface org.mobicents.media.server.spi.rtp.RtpManager
Throws:
java.net.SocketException
java.io.IOException

isActive

public boolean isActive()

getNextPort

protected int getNextPort()
Get the next port to be used by the RtpSocket to bind Socket to passed port.
The portIndex increments cyclic starting from lowPort to highPort and then back to lowPort
The Port is incremented by 2 as every alternate port is for RTCP.

Returns:

stop

public void stop()
Specified by:
stop in interface org.mobicents.media.server.spi.rtp.RtpManager

getBindAddress

public java.lang.String getBindAddress()
Gets the IP address to which trunk is bound. All endpoints of the trunk use this address for RTP connection.

Specified by:
getBindAddress in interface org.mobicents.media.server.spi.rtp.RtpManager
Returns:
the IP address string to which this trunk is bound.

setBindAddress

public void setBindAddress(java.lang.String bindAddress)
                    throws java.net.UnknownHostException
Modify the bind address. All endpoints of the trunk use this address for RTP connection.

Parameters:
bindAddress - IP address as string or host name.
Throws:
java.net.UnknownHostException

getLowPort

public int getLowPort()
Gets the minimum available port number.

Returns:
port number

setLowPort

public void setLowPort(int lowPort)
Modifies minimum available port

Parameters:
lowPort - the port number.

getHighPort

public int getHighPort()
Gets the maximum available port number.

Returns:
port number

setHighPort

public void setHighPort(int port)
Modifies maximum available port

Parameters:
port - the port number.

getJitter

public java.lang.Integer getJitter()
Gets the size of the jitter buffer in milliseconds. Jitter buffer is used at the receiving ends of a VoIP connection. A jitter buffer stores received, time-jittered VoIP packets, that arrive within its time window. It then plays stored packets out, in sequence, and at a constant rate for subsequent decoding. A jitter buffer is typically filled half-way before playing out packets to allow early, or late, packet-arrival jitter compensation. Choosing a large jitter buffer reduces packet dropping from jitter but increases VoIP path delay

Returns:
the size of the buffer in milliseconds.

setJitter

public void setJitter(java.lang.Integer jitter)
Modify size of the jitter buffer. Jitter buffer is used at the receiving ends of a VoIP connection. A jitter buffer stores received, time-jittered VoIP packets, that arrive within its time window. It then plays stored packets out, in sequence, and at a constant rate for subsequent decoding. A jitter buffer is typically filled half-way before playing out packets to allow early, or late, packet-arrival jitter compensation. Choosing a large jitter buffer reduces packet dropping from jitter but increases VoIP path delay

Parameters:
jitter - the new buffer's size in milliseconds

getAVProfile

public org.mobicents.media.server.spi.rtp.AVProfile getAVProfile()
Gets currently used Audio/Video profile.

Returns:
audio/video profile.

setAVProfile

public void setAVProfile(org.mobicents.media.server.spi.rtp.AVProfile avProfile)
Modify audio/video profile.

Parameters:
avProfile - the new value of the audio/video profile.

getClock

public RtpClock getClock(org.mobicents.media.server.spi.MediaType media)
Gets RTP clocks for specified media type.

Parameters:
media - the media type
Returns:
the clock instance

getCodecs

public java.util.Hashtable<org.mobicents.media.server.spi.MediaType,java.util.List<org.mobicents.media.server.spi.dsp.CodecFactory>> getCodecs()
Gets list of assigned codecs.

Returns:
the map between media type and list of codec factories.

setCodecs

public void setCodecs(java.util.Hashtable<org.mobicents.media.server.spi.MediaType,java.util.List<org.mobicents.media.server.spi.dsp.CodecFactory>> codecFactories)
Modify list of codecs.

Parameters:
codecFactories - the map between media type and list of codec's factories.

register

protected void register()
Registers sockets in the receiver. This method is called from Receiver. New socket is always placed into the registration queue and later receiver will call this method in the IO cycle. It will allow to prevent usage of expensive locks during IO.


getRTPSocket

public org.mobicents.media.server.spi.rtp.RtpSocket getRTPSocket(org.mobicents.media.server.spi.MediaType media)
                                                          throws java.io.IOException,
                                                                 org.mobicents.media.server.spi.ResourceUnavailableException
Constructs new RTP socket for the specified media type.

Specified by:
getRTPSocket in interface org.mobicents.media.server.spi.rtp.RtpManager
Returns:
the RTPSocketInstance.
Throws:
net.java.stun4j.StunException
java.io.IOException
java.net.SocketException
net.java.stun4j.StunException
java.io.IOException
org.mobicents.media.server.spi.ResourceUnavailableException


Copyright © 2010. All Rights Reserved.