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

java.lang.Object
  extended by org.mobicents.media.server.impl.rtp.RtpSocket

public class RtpSocket
extends java.lang.Object

Author:
Oleg Kulikov

Field Summary
protected  java.util.Collection<org.mobicents.media.server.spi.dsp.Codec> codecs
           
protected  org.mobicents.media.server.spi.MediaType media
           
protected  boolean registered
           
protected  java.net.InetSocketAddress remoteAddress
           
protected  org.mobicents.media.server.spi.clock.Timer timer
           
 
Constructor Summary
RtpSocket(RtpFactory factory, java.util.Collection<org.mobicents.media.server.spi.dsp.Codec> codecs, org.mobicents.media.server.spi.MediaType media)
          Creates a new instance of RtpSocket
 
Method Summary
 void bind()
           
 AVProfile getAVProfile()
           
 long getBytesReceived()
           
 long getBytesSent()
           
 RtpClock getClock()
          Gets current RTP clock instance.
 java.util.Collection<org.mobicents.media.server.spi.dsp.Codec> getCodecs()
           
 java.net.DatagramSocket getDatagramSocket()
           
 org.mobicents.media.Format getFormat()
           
 int getJitter()
          Gets the jitter for time of packet arrival
 RtpSocketListener getListener()
          Gets the currently assigned listener.
 java.lang.String getLocalAddress()
          Gets address to which this socked is bound.
 int getLocalPort()
          Returns port number to which this socked is bound.
 int getPacketsReceived()
          Gets the number of received packets
 int getPacketsSent()
          Gets the number of sent packets
 int getPeriod()
           
 ReceiveStream getReceiveStream()
          Gets receiver stream.
 SendStream getSendStream()
          (Non Java-doc).
protected  org.mobicents.media.server.spi.clock.Timer getTimer()
           
 boolean isClosed()
           
 boolean isConnected()
           
protected  void notify(java.lang.Exception e)
           
 void receive(RtpPacket rtpPacket)
          This method is called when rtp socket receives new rtp frame.
protected  void register(java.nio.channels.Selector selector)
           
 void release()
          Closes this socket and resets its streams;
 void send(byte[] packet)
          Sends rtp packet to the remote peer.
 void send(RtpPacket packet)
          Sends media data to remote peer.
 void setClock(RtpClock clock)
          Assign RTP clock implementation.
 void setDtmfPayload(int dtmf)
           
 void setFormat(int payloadId, org.mobicents.media.Format format)
          Specifies format and payload id which will be used by this socket for transmission This methods should be used by other components which are responsible for SDP negotiation.
 void setJitter(int jitter)
          Assign new value of packet time arrival jitter.
 void setListener(RtpSocketListener listener)
          Assigns listener which will receive notifications.
 void setPeer(java.net.InetAddress address, int port)
          Assigns remote end.
 void setPeriod(int period)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

media

protected org.mobicents.media.server.spi.MediaType media

remoteAddress

protected java.net.InetSocketAddress remoteAddress

timer

protected org.mobicents.media.server.spi.clock.Timer timer

codecs

protected java.util.Collection<org.mobicents.media.server.spi.dsp.Codec> codecs

registered

protected boolean registered
Constructor Detail

RtpSocket

public RtpSocket(RtpFactory factory,
                 java.util.Collection<org.mobicents.media.server.spi.dsp.Codec> codecs,
                 org.mobicents.media.server.spi.MediaType media)
          throws java.io.IOException,
                 org.mobicents.media.server.spi.ResourceUnavailableException
Creates a new instance of RtpSocket

Parameters:
timer - used to synchronize receiver stream.
rtpMap - RTP payloads list.
Throws:
java.io.IOException
org.mobicents.media.server.spi.ResourceUnavailableException
Method Detail

bind

public void bind()
          throws java.io.IOException,
                 org.mobicents.media.server.spi.ResourceUnavailableException
Throws:
java.io.IOException
org.mobicents.media.server.spi.ResourceUnavailableException

register

protected void register(java.nio.channels.Selector selector)
                 throws java.nio.channels.ClosedChannelException
Throws:
java.nio.channels.ClosedChannelException

getDatagramSocket

public java.net.DatagramSocket getDatagramSocket()

isConnected

public boolean isConnected()

getTimer

protected org.mobicents.media.server.spi.clock.Timer getTimer()

getFormat

public org.mobicents.media.Format getFormat()

setPeriod

public void setPeriod(int period)

getPeriod

public int getPeriod()

getCodecs

public java.util.Collection<org.mobicents.media.server.spi.dsp.Codec> getCodecs()

setFormat

public void setFormat(int payloadId,
                      org.mobicents.media.Format format)
Specifies format and payload id which will be used by this socket for transmission This methods should be used by other components which are responsible for SDP negotiation. The socket itself can not negotiate SDP.

Parameters:
payloadId - rtp payload number
format - the format object.

setDtmfPayload

public void setDtmfPayload(int dtmf)

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.

setClock

public void setClock(RtpClock clock)
Assign RTP clock implementation.

Parameters:
clock - the RTP clock instance;

getClock

public RtpClock getClock()
Gets current RTP clock instance.

Returns:
the RTP clock instance.

getReceiveStream

public ReceiveStream getReceiveStream()
Gets receiver stream.

Returns:
receiver stream instance.

getAVProfile

public AVProfile getAVProfile()

getPacketsReceived

public int getPacketsReceived()
Gets the number of received packets

Returns:
the number of packets received

getPacketsSent

public int getPacketsSent()
Gets the number of sent packets

Returns:
the number of sent packets.

release

public void release()
Closes this socket and resets its streams;


isClosed

public boolean isClosed()

getListener

public RtpSocketListener getListener()
Gets the currently assigned listener.

Returns:
the listener instance.

setListener

public void setListener(RtpSocketListener listener)
Assigns listener which will receive notifications.

Parameters:
listener - the listener instance.

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

getSendStream

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

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

send

public void send(RtpPacket packet)
          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:
RtpPacket - - the packet which contains media data and rtp header
Throws:
java.io.IOException

send

public void send(byte[] packet)
          throws java.io.IOException
Sends rtp packet to the remote peer.

Parameters:
packet - the rtp packet as binary arrary
Throws:
java.io.IOException

receive

public void receive(RtpPacket rtpPacket)
This method is called when rtp socket receives new rtp frame.

Parameters:
rtpPacket -

notify

protected void notify(java.lang.Exception e)

getBytesReceived

public long getBytesReceived()

getBytesSent

public long getBytesSent()


Copyright © 2010. All Rights Reserved.