net.sf.fmj.media.rtp
Class SocketOutputStream

java.lang.Object
  extended by net.sf.fmj.media.rtp.SocketOutputStream
All Implemented Interfaces:
OutputDataStream

public class SocketOutputStream
extends java.lang.Object
implements OutputDataStream

An output Datagram Socket for JMF

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

Constructor Summary
SocketOutputStream(java.net.DatagramSocket sckt)
          Creates a new SocketOutputStream
 
Method Summary
 void addTarget(java.net.InetAddress remoteAddr, int remotePort)
          Add a target to stream targets list
 boolean removeTarget(java.net.InetAddress remoteAddr, int remotePort)
          Remove a target from stream targets list
 void removeTargets()
          Remove all stream targets from this session.
 int write(byte[] buffer, int offset, int length)
          Write a data buffer to all known remote targets.
 int writeToRemote(byte[] buffer, int offset, int length, java.net.InetAddress remoteAddr, int remotePort)
          Write a data buffer to one specific remote target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketOutputStream

public SocketOutputStream(java.net.DatagramSocket sckt)
Creates a new SocketOutputStream

Parameters:
socket - The datagram socket to adapt
sendAddress - The address to send packets to
sendPort - The port to send packets to
Method Detail

addTarget

public void addTarget(java.net.InetAddress remoteAddr,
                      int remotePort)
Add a target to stream targets list

Parameters:
remoteAddr - target ip address
remotePort - target port

removeTarget

public boolean removeTarget(java.net.InetAddress remoteAddr,
                            int remotePort)
Remove a target from stream targets list

Parameters:
remoteAddr - target ip address
remotePort - target port
Returns:
true if the target is in stream target list and can be removed false if not

removeTargets

public void removeTargets()
Remove all stream targets from this session.


write

public int write(byte[] buffer,
                 int offset,
                 int length)
Write a data buffer to all known remote targets. The methods loops over the vector of all known targets, builds, and sends datagram packet.

Specified by:
write in interface OutputDataStream
Parameters:
buffer - The byte array containing the data
offset - Offset into the byte array to get data from
length - Length in bytes of the data to send.

writeToRemote

public int writeToRemote(byte[] buffer,
                         int offset,
                         int length,
                         java.net.InetAddress remoteAddr,
                         int remotePort)
Write a data buffer to one specific remote target. The methods builds and sends datagram packet to a specified target. This is mostly used to send RTCP packet to a dedicated target, for example when removing a target.

Parameters:
buffer - The byte array containing the data
offset - Offset into the byte array to get data from
length - Length in bytes of the data to send
remoteAddr - The remote IP address of the target
remotePort - The port number of the target