net.sf.fmj.media.rtp
Class RTPDataStream

java.lang.Object
  extended by net.sf.fmj.media.rtp.RTPDataStream
All Implemented Interfaces:
Control, Controls, PushBufferStream, SourceStream, RTPControl
Direct Known Subclasses:
RTPAudioDataStream, RTPVideoDataStream

public abstract class RTPDataStream
extends java.lang.Object
implements PushBufferStream, RTPControl

A generic RTP Data Stream

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

Field Summary
protected  int bitsPerSecond
           
protected  int bytesProcessed
           
protected  double clockRate
           
protected  java.lang.Object[] controls
           
protected  Format format
           
protected  BufferTransferHandler handler
           
protected  RTPBuffer itsRTPBuffer
           
protected  long jitter
           
protected  long lastTimestamp
           
protected  int packetSize
           
protected  RTPReceptionStats receptionStats
           
protected  int rtpbufferlen
           
protected  long rtpbufferlenMS
           
protected  long ssrc
           
protected  long threshold
           
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
RTPDataStream(long ssrc, Format format)
          Creates a new RTPDataStream
 
Method Summary
 void addFormat(Format fmt, int payload)
          Add the specified format as corresponding to the specified payload.
protected abstract  void addPacket(RTPHeader header, byte[] data, int offset, int length)
          Add an RTP packet to this datastream.
protected  void calculateJitter(long rtpTimestamp)
          Performs jitter calculations (Conforming to RFC-3550 6.4.1)
 boolean endOfStream()
          Indicates if we're reached the end of stream.
 ContentDescriptor getContentDescriptor()
          Returns the content descriptor of this stream.
 long getContentLength()
          Returns the content's length.
 java.lang.Object getControl(java.lang.String controlType)
          Returns the control specific to this content type.
 java.awt.Component getControlComponent()
          Returns the control component.
 java.lang.Object[] getControls()
          Returns all the possible controls of this datastream.
 Format getFormat()
          Returns the format carried by this datastream.
 Format getFormat(int payload)
          Returns the format corresponding to this payload type.
 Format[] getFormatList()
          Returns the list of formats supported.
 GlobalReceptionStats getGlobalStats()
          Returns the global stats.
 long getJitter()
          Returns the current jitter calculated.
 long getJitterBufferItemCount()
           
 long getJitterBufferSize()
           
 ReceptionStats getReceptionStats()
          Returns the reception stats.
abstract  void read(Buffer buffer)
          Reads the data available into the buffer.
 void setTransferHandler(BufferTransferHandler transferHandler)
          Sets the handler responsible for treating the incoming data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

format

protected Format format

clockRate

protected double clockRate

packetSize

protected int packetSize

handler

protected BufferTransferHandler handler

ssrc

protected long ssrc

threshold

protected long threshold

controls

protected java.lang.Object[] controls

receptionStats

protected RTPReceptionStats receptionStats

jitter

protected long jitter

itsRTPBuffer

protected RTPBuffer itsRTPBuffer

rtpbufferlen

protected int rtpbufferlen

rtpbufferlenMS

protected long rtpbufferlenMS

lastTimestamp

protected long lastTimestamp

bytesProcessed

protected int bytesProcessed

bitsPerSecond

protected int bitsPerSecond
Constructor Detail

RTPDataStream

public RTPDataStream(long ssrc,
                     Format format)
Creates a new RTPDataStream

Parameters:
ssrc - the SSRC associated with this datastream
format - The format of the stream
Method Detail

addPacket

protected abstract void addPacket(RTPHeader header,
                                  byte[] data,
                                  int offset,
                                  int length)
Add an RTP packet to this datastream.

Parameters:
header - the RTP header
data - the data
offset - the offset
length - the length

getFormat

public Format getFormat()
Returns the format carried by this datastream.

Specified by:
getFormat in interface PushBufferStream
Specified by:
getFormat in interface RTPControl
Returns:
the format of this datastream

setTransferHandler

public void setTransferHandler(BufferTransferHandler transferHandler)
Sets the handler responsible for treating the incoming data.

Specified by:
setTransferHandler in interface PushBufferStream
Parameters:
transferHandler - the object handling the data

getContentDescriptor

public ContentDescriptor getContentDescriptor()
Returns the content descriptor of this stream.

Specified by:
getContentDescriptor in interface SourceStream
Returns:
the content descriptor of this stream - the RAW_RTP content descriptor

getContentLength

public long getContentLength()
Returns the content's length.

Specified by:
getContentLength in interface SourceStream
Returns:
the content's length

endOfStream

public boolean endOfStream()
Indicates if we're reached the end of stream.

Specified by:
endOfStream in interface SourceStream
Returns:
FALSE

getControls

public java.lang.Object[] getControls()
Returns all the possible controls of this datastream.

Specified by:
getControls in interface Controls
Returns:
all the possible controls of this datastream

getControl

public java.lang.Object getControl(java.lang.String controlType)
Returns the control specific to this content type.

Specified by:
getControl in interface Controls
Parameters:
controlType - the control type
Returns:
the control (this stream for RTPControl, else null)

read

public abstract void read(Buffer buffer)
                   throws java.io.IOException
Reads the data available into the buffer.

Specified by:
read in interface PushBufferStream
Parameters:
buffer - the buffer in which to put the read data
Throws:
java.io.IOException - I/O Exception

addFormat

public void addFormat(Format fmt,
                      int payload)
Add the specified format as corresponding to the specified payload. DOES NOTHING

Specified by:
addFormat in interface RTPControl
Parameters:
fmt - format
payload - payload type

getReceptionStats

public ReceptionStats getReceptionStats()
Returns the reception stats.

Specified by:
getReceptionStats in interface RTPControl
Returns:
the reception stats

getGlobalStats

public GlobalReceptionStats getGlobalStats()
Returns the global stats.

Specified by:
getGlobalStats in interface RTPControl
Returns:
the global stats

getFormatList

public Format[] getFormatList()
Returns the list of formats supported.

Specified by:
getFormatList in interface RTPControl
Returns:
the list of formats supported

getFormat

public Format getFormat(int payload)
Returns the format corresponding to this payload type.

Specified by:
getFormat in interface RTPControl
Parameters:
payload - the payload type
Returns:
the format corresponding to this payload type

getControlComponent

public java.awt.Component getControlComponent()
Returns the control component. NULL

Specified by:
getControlComponent in interface Control
Returns:
null

calculateJitter

protected void calculateJitter(long rtpTimestamp)
Performs jitter calculations (Conforming to RFC-3550 6.4.1)

Parameters:
rtpTimestamp - the RTP timestamp present in the packet

getJitter

public long getJitter()
Returns the current jitter calculated.

Returns:
the current jitter calculated

getJitterBufferSize

public long getJitterBufferSize()

getJitterBufferItemCount

public long getJitterBufferItemCount()