Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.neomedia.jmfext.media.protocol
Class AbstractBufferStream

java.lang.Object
  extended by net.java.sip.communicator.impl.neomedia.control.AbstractControls
      extended by net.java.sip.communicator.impl.neomedia.jmfext.media.protocol.AbstractBufferStream
All Implemented Interfaces:
javax.media.Controls, javax.media.protocol.SourceStream
Direct Known Subclasses:
AbstractPullBufferStream, AbstractPushBufferStream

abstract class AbstractBufferStream
extends AbstractControls
implements javax.media.protocol.SourceStream

Provides a base implementation of SourceStream in order to facilitate implementers by taking care of boilerplate in the most common cases.

Author:
Lyubomir Marinov

Field Summary
protected  javax.media.protocol.DataSource dataSource
          The DataSource which has created this instance and which contains it as one of its streams.
protected  javax.media.control.FormatControl formatControl
          The FormatControl which gives access to the Format of the media data provided by this SourceStream and which, optionally, allows setting it.
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
protected AbstractBufferStream(javax.media.protocol.DataSource dataSource, javax.media.control.FormatControl formatControl)
          Initializes a new AbstractBufferStream instance which is to have its Format-related information abstracted by a specific FormatControl.
 
Method Summary
 void close()
          Releases the resources used by this instance throughout its existence and makes it available for garbage collection.
protected  javax.media.Format doGetFormat()
          Gets the Format of this AbstractBufferStream as directly known by it.
protected  javax.media.Format doSetFormat(javax.media.Format format)
          Attempts to set the Format of this AbstractBufferStream.
 boolean endOfStream()
          Determines whether the end of this SourceStream has been reached.
 javax.media.protocol.ContentDescriptor getContentDescriptor()
          Gets a ContentDescriptor which describes the type of the content made available by this SourceStream.
 long getContentLength()
          Gets the length in bytes of the content made available by this SourceStream.
 Object[] getControls()
          Implements Controls.getControls().
 javax.media.Format getFormat()
          Gets the Format of the media data made available by this AbstractBufferStream.
(package private)  javax.media.Format internalGetFormat()
          Gets the Format of this AbstractBufferStream as directly known by it.
(package private)  javax.media.Format internalSetFormat(javax.media.Format format)
          Attempts to set the Format of this AbstractBufferStream.
 void start()
          Starts the transfer of media data from this AbstractBufferStream.
 void stop()
          Stops the transfer of media data from this AbstractBufferStream.
 
Methods inherited from class net.java.sip.communicator.impl.neomedia.control.AbstractControls
getControl, getControl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.media.Controls
getControl
 

Field Detail

dataSource

protected final javax.media.protocol.DataSource dataSource
The DataSource which has created this instance and which contains it as one of its streams.


formatControl

protected final javax.media.control.FormatControl formatControl
The FormatControl which gives access to the Format of the media data provided by this SourceStream and which, optionally, allows setting it.

Constructor Detail

AbstractBufferStream

protected AbstractBufferStream(javax.media.protocol.DataSource dataSource,
                               javax.media.control.FormatControl formatControl)
Initializes a new AbstractBufferStream instance which is to have its Format-related information abstracted by a specific FormatControl.

Parameters:
dataSource - the DataSource which is creating the new instance so that it becomes one of its streams
formatControl - the FormatControl which is to abstract the Format-related information of the new instance
Method Detail

close

public void close()
Releases the resources used by this instance throughout its existence and makes it available for garbage collection. This instance is considered unusable after closing.


doGetFormat

protected javax.media.Format doGetFormat()
Gets the Format of this AbstractBufferStream as directly known by it. Allows extenders to override the Format known to the DataSource which created this instance and possibly provide more details on the currently set Format.

Returns:
the Format of this AbstractBufferStream as directly known by it or null if this AbstractBufferStream does not directly know its Format and it relies on the DataSource which created it to report its Format

doSetFormat

protected javax.media.Format doSetFormat(javax.media.Format format)
Attempts to set the Format of this AbstractBufferStream. Allows extenders to enable setting the Format of an existing AbstractBufferStream (in contract to setting it before the AbstractBufferStream is created by the DataSource which will provide it).

Parameters:
format - the Format to be set as the format of this AbstractBufferStream
Returns:
the Format of this AbstractBufferStream or null if the attempt to set the Format did not succeed and any last-known Format is to be left in effect

endOfStream

public boolean endOfStream()
Determines whether the end of this SourceStream has been reached. The AbstractBufferStream implementation always returns false.

Specified by:
endOfStream in interface javax.media.protocol.SourceStream
Returns:
true if the end of this SourceStream has been reached; otherwise, false

getContentDescriptor

public javax.media.protocol.ContentDescriptor getContentDescriptor()
Gets a ContentDescriptor which describes the type of the content made available by this SourceStream. The AbstractBufferStream implementation always returns a ContentDescriptor with content type equal to ContentDescriptor#RAW.

Specified by:
getContentDescriptor in interface javax.media.protocol.SourceStream
Returns:
a ContentDescriptor which describes the type of the content made available by this SourceStream

getContentLength

public long getContentLength()
Gets the length in bytes of the content made available by this SourceStream. The AbstractBufferStream implementation always returns LENGTH_UNKNOWN.

Specified by:
getContentLength in interface javax.media.protocol.SourceStream
Returns:
the length in bytes of the content made available by this SourceStream if it is known; otherwise, LENGTH_UKNOWN

getControls

public Object[] getControls()
Implements Controls.getControls(). Gets the controls available for this instance.

Specified by:
getControls in interface javax.media.Controls
Returns:
an array of Objects which represent the controls available for this instance

getFormat

public javax.media.Format getFormat()
Gets the Format of the media data made available by this AbstractBufferStream.

Returns:
the Format of the media data made available by this AbstractBufferStream

internalGetFormat

javax.media.Format internalGetFormat()
Gets the Format of this AbstractBufferStream as directly known by it.

Returns:
the Format of this AbstractBufferStream as directly known by it

internalSetFormat

javax.media.Format internalSetFormat(javax.media.Format format)
Attempts to set the Format of this AbstractBufferStream.

Parameters:
format - the Format to be set as the format of this AbstractBufferStream
Returns:
the Format of this AbstractBufferStream or null if the attempt to set the Format did not succeed and any last-known Format is to be left in effect

start

public void start()
           throws IOException
Starts the transfer of media data from this AbstractBufferStream.

Throws:
IOException - if anything goes wrong while starting the transfer of media data from this AbstractBufferStream

stop

public void stop()
          throws IOException
Stops the transfer of media data from this AbstractBufferStream.

Throws:
IOException - if anything goes wrong while stopping the transfer of media data from this AbstractBufferStream

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.