org.ow2.clif.probe.rtp
Class RTPListener

java.lang.Object
  extended by java.lang.Thread
      extended by org.ow2.clif.probe.rtp.RTPListener
All Implemented Interfaces:
java.lang.Runnable

public class RTPListener
extends java.lang.Thread

Thread to open and listen UDP packets.

Author:
Rémi Druilhe

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
 void close()
          Close the listener and the sockets by stopping thread.
static RTPListener getInstance()
          Create or get the single instance of the thread
 java.util.LinkedList<RTPInformation> getPackets(java.lang.Integer timeout)
          This method return list of packets before cleaning it.
 void openSocket(java.net.InetAddress addr, java.util.ArrayList<java.lang.Integer> ports)
          Open sockets using java.nio
 void run()
           
 void sendPacket(byte[] data, java.net.InetAddress remoteAddress, int remotePort, int localPort)
          Send a RTP packet on the given local port to the remote client.
 void startListener()
          Start the thread of the singleton if it hasn't been started yet.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static RTPListener getInstance()
Create or get the single instance of the thread

Returns:
the single instance of the thread

openSocket

public void openSocket(java.net.InetAddress addr,
                       java.util.ArrayList<java.lang.Integer> ports)
Open sockets using java.nio

Parameters:
addr - : the address to open socket (can be null)
ports - : the ports to open

startListener

public void startListener()
Start the thread of the singleton if it hasn't been started yet.


run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
This method listen to the ports opened previously with openSocket. The size of RTP/RTCP packets must be less than 512 bytes.

getPackets

public java.util.LinkedList<RTPInformation> getPackets(java.lang.Integer timeout)
This method return list of packets before cleaning it.

Returns:
the list of packets.

sendPacket

public void sendPacket(byte[] data,
                       java.net.InetAddress remoteAddress,
                       int remotePort,
                       int localPort)
Send a RTP packet on the given local port to the remote client.

Parameters:
data - : the packet.
remoteAddress - : InetAddress of the remote client.
remotePort - : the port of the remote client.
localPort - : the port on which the packet is sent.

close

public void close()
Close the listener and the sockets by stopping thread.