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

java.lang.Object
  extended by org.mobicents.media.server.impl.rtp.RtpSocket
All Implemented Interfaces:
java.lang.Runnable

public class RtpSocket
extends java.lang.Object
implements java.lang.Runnable

Author:
Oleg Kulikov

Field Summary
protected static int READ_PERIOD
           
protected  org.mobicents.media.server.spi.Timer timer
           
 
Constructor Summary
RtpSocket(org.mobicents.media.server.spi.Timer timer, java.util.Map<java.lang.Integer,org.mobicents.media.Format> rtpMap, RtpFactory rtpFactory)
          Creates a new instance of RtpSocket
 
Method Summary
 void close()
          Closes socket
 int getJitter()
          Gets the jitter for time of packet arrival
 RtpSocketListener getListener()
           
 java.lang.String getLocalAddress()
          Gets address to which this socked is bound.
 int getLocalPort()
          Returns port number to which this socked is bound.
protected  int getPayloadType(org.mobicents.media.Format format)
          Determines payload type for specified format.
 org.mobicents.media.MediaSource getReceiveStream()
          Gets receiver stream.
 java.util.HashMap<java.lang.Integer,org.mobicents.media.Format> getRtpMap()
          Gets relations between payload number and format used by this socket.
 SendStream getSendStream()
          (Non Java-doc).
 java.lang.String getStunAddress()
          Gets the address of stun server if present.
 int init(java.net.InetAddress localAddress, int lowPort, int highPort)
          (Non Java-doc).
 boolean isChannelOpen()
           
 void release()
           
 void resetRtpMap()
           
 void run()
           
 void send(org.mobicents.media.Buffer buffer)
          Sends media data to remote peer.
 void setJitter(int jitter)
          Assign new value of packet time arrival jitter.
 void setListener(RtpSocketListener listener)
           
 void setPeer(java.net.InetAddress address, int port)
          Assigns remote end.
 void setRtpMap(java.util.HashMap<java.lang.Integer,org.mobicents.media.Format> rtpMap)
           
 void setStunAddress(java.lang.String address)
          Assigns address of the STUN server.
protected  void startReceiver()
           
protected  void stopReceiver()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_PERIOD

protected static int READ_PERIOD

timer

protected org.mobicents.media.server.spi.Timer timer
Constructor Detail

RtpSocket

public RtpSocket(org.mobicents.media.server.spi.Timer timer,
                 java.util.Map<java.lang.Integer,org.mobicents.media.Format> rtpMap,
                 RtpFactory rtpFactory)
Creates a new instance of RtpSocket

Parameters:
timer - used to synchronize receiver stream.
rtpMap - RTP payloads list.
Method Detail

init

public int init(java.net.InetAddress localAddress,
                int lowPort,
                int highPort)
         throws java.net.SocketException,
                java.io.IOException,
                net.java.stun4j.StunException
(Non Java-doc).

Throws:
java.net.SocketException
java.io.IOException
net.java.stun4j.StunException
See Also:
org.mobicents.media.server.impl.rtp.RtpSocket#init(InetAddress, int);

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.

getLocalAddress

public java.lang.String getLocalAddress()
Gets address to which this socked is bound.

Returns:
either local address to which this socket is bound or public address in case of NAT translation.

getLocalPort

public int getLocalPort()
Returns port number to which this socked is bound.

Returns:
port number or -1 if socket not bound.

getJitter

public int getJitter()
Gets the jitter for time of packet arrival

Returns:
the value of jitter in milliseconds.

setJitter

public void setJitter(int jitter)
Assign new value of packet time arrival jitter.

Parameters:
jitter - the value of jitter in milliseconds.

getReceiveStream

public org.mobicents.media.MediaSource getReceiveStream()
Gets receiver stream.

Returns:
receiver stream instance.

startReceiver

protected void startReceiver()

stopReceiver

protected void stopReceiver()

release

public void release()

getListener

public RtpSocketListener getListener()

setListener

public void setListener(RtpSocketListener listener)

isChannelOpen

public boolean isChannelOpen()

close

public void close()
Closes socket


setPeer

public void setPeer(java.net.InetAddress address,
                    int port)
             throws java.io.IOException
Assigns remote end.

Parameters:
address - the address of the remote party.
port - the port number of the remote party.
Throws:
java.io.IOException

getRtpMap

public java.util.HashMap<java.lang.Integer,org.mobicents.media.Format> getRtpMap()
Gets relations between payload number and format used by this socket.

Returns:
the map where keya are payload number and object stored under key is Format object

setRtpMap

public void setRtpMap(java.util.HashMap<java.lang.Integer,org.mobicents.media.Format> rtpMap)

resetRtpMap

public void resetRtpMap()

getPayloadType

protected int getPayloadType(org.mobicents.media.Format format)
Determines payload type for specified format.

Parameters:
format - the object representing format.
Returns:
the integer identifier of the payload or -1 if specified format was not previously registered with addFormat().

getSendStream

public SendStream getSendStream()
(Non Java-doc).

See Also:
org.mobicents.media.server.impl.rtp.RtpSocket#startSendStream(PushBufferDataSource);

send

public void send(org.mobicents.media.Buffer buffer)
          throws java.io.IOException
Sends media data to remote peer. This method uses blocking sending to make sure that data is out in time.

Parameters:
buffer - the buffer which contains media data
Throws:
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable


Copyright © 2009. All Rights Reserved.