net.sf.fmj.media.rtp
Class SimpleSocketInputStream

java.lang.Object
  extended by java.lang.Thread
      extended by com.lti.utils.synchronization.CloseableThread
          extended by net.sf.fmj.media.rtp.SimpleSocketInputStream
All Implemented Interfaces:
java.lang.Runnable, Controls, PushSourceStream, SourceStream

public class SimpleSocketInputStream
extends CloseableThread
implements PushSourceStream

A DatagramSocket Input Stream Adapter

Version:
1-1-alpha3 TODO: changes to this class by kenlars99 basically make it similar to SocketInputStream, which is not currently used. Perhaps it is better to put SimpleSocketInputStream back the way it was, move this code to SocketInputStream, and use SocketInputStream instead of SimpleSocketInputStream.
Author:
Andrew G D Rowley, Ken Larson

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 com.lti.utils.synchronization.CloseableThread
closing
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
SimpleSocketInputStream(java.net.DatagramSocket socket)
          Creates a new SocketInputStream
 
Method Summary
 boolean endOfStream()
          Have we reached the end of stream?
 ContentDescriptor getContentDescriptor()
          Returns the content descriptor.
 long getContentLength()
          Returns the content's length.
 java.lang.Object getControl(java.lang.String controlType)
          DUMMY.
 java.lang.Object[] getControls()
          DUMMY.
 int getMinimumTransferSize()
          Returns the minimum transfer size.
 void kill()
          Stops the socket
 void notifyTransferHandlerAsync()
           
 int read(byte[] buffer, int offset, int length)
          Read a datagram packet and write it into the provided buffer.
 void run()
          Walk...
 void setTransferHandler(SourceTransferHandler transferHandler)
          Sets the transfer handler for this stream.
 
Methods inherited from class com.lti.utils.synchronization.CloseableThread
close, isClosed, isClosing, setClosed, setClosing, waitUntilClosed
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleSocketInputStream

public SimpleSocketInputStream(java.net.DatagramSocket socket)
Creates a new SocketInputStream

Parameters:
socket - The socket to handle
Method Detail

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Read a datagram packet and write it into the provided buffer.

Specified by:
read in interface PushSourceStream
Parameters:
buffer - the buffer to write the packets to
offset - offset after which we can write
length - total length
Returns:
the packet length or 0 if a problem occured
Throws:
java.io.IOException

getMinimumTransferSize

public int getMinimumTransferSize()
Returns the minimum transfer size.

Specified by:
getMinimumTransferSize in interface PushSourceStream
Returns:
2048 by default, since we've got no way to retrieve the MTU

setTransferHandler

public void setTransferHandler(SourceTransferHandler transferHandler)
Sets the transfer handler for this stream.

Specified by:
setTransferHandler in interface PushSourceStream
Parameters:
transferHandler - the transfer handler

notifyTransferHandlerAsync

public void notifyTransferHandlerAsync()
                                throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

getContentDescriptor

public ContentDescriptor getContentDescriptor()
Returns the content descriptor. DUMMY. Needed by JMF.

Specified by:
getContentDescriptor in interface SourceStream
Returns:
null

getContentLength

public long getContentLength()
Returns the content's length. Needed by JMF, always returns LENGTH_UNKNOWN in our case.

Specified by:
getContentLength in interface SourceStream
Returns:
LENGTH_UNKNOWN

endOfStream

public boolean endOfStream()
Have we reached the end of stream?

Specified by:
endOfStream in interface SourceStream
Returns:
true if we're finished with this stream

getControls

public java.lang.Object[] getControls()
DUMMY.

Specified by:
getControls in interface Controls
Returns:
EMPTY ARRAY

getControl

public java.lang.Object getControl(java.lang.String controlType)
DUMMY.

Specified by:
getControl in interface Controls
Parameters:
controlType - UNUSED.
Returns:
null

run

public void run()
Walk...

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

kill

public void kill()
Stops the socket