com.sun.media
类 BasicSourceModule

java.lang.Object
  继承者 com.sun.media.BasicModule
      继承者 com.sun.media.BasicSourceModule
所有已实现的接口:
Module, StateTransistor, Controls, Duration, javax.media.protocol.Positionable

public class BasicSourceModule
extends BasicModule
implements Duration, javax.media.protocol.Positionable

MediaSource is a module which have OutputConnectors and no InputConnectors. It receives data from PullSourceStream and stream the data to the downstream modules (in case of PushSourceStream an adapter should be written Push2Pull such as the RTP "bucket" adapter).
MediaSource are typically not threaded and use Pull protocol (URL connection is really threaded but everything goes "under the hood" so we refer to it as unthreaded one).
This class support data caching in either memory or disk.
When an attemped read would block, the Player would Restart (in order to fetch data). We need the level 3 design for:


字段摘要
protected  long bitsRead
           
protected  java.lang.String[] connectorNames
           
protected  long currentSystemTime
           
 java.lang.String errMsg
           
protected  Time lastPositionSet
           
protected  long lastSystemTime
           
protected  com.sun.media.SourceThread[] loops
           
protected  long originSystemTime
           
protected  Demultiplexer parser
           
protected  javax.media.protocol.DataSource source
           
protected  boolean started
           
protected  SystemTimeBase systemTimeBase
           
protected  Track[] tracks
           
 
从类 com.sun.media.BasicModule 继承的字段
controller, inputConnectors, inputConnectorsArray, jmd, moduleListener, name, outputConnectors, outputConnectorsArray, prefetchFailed, protocol, resetted
 
从接口 javax.media.Duration 继承的字段
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
从接口 javax.media.protocol.Positionable 继承的字段
RoundDown, RoundNearest, RoundUp
 
构造方法摘要
protected BasicSourceModule(javax.media.protocol.DataSource ds, Demultiplexer demux)
           
 
方法摘要
 void abortPrefetch()
          Called when the prefetch() is aborted, i.e. deallocate() was called while prefetching.
 void abortRealize()
          Called when the realize() is aborted, i.e. deallocate() was called while realizing.
protected  boolean checkAllPaused()
           
 void checkLatency()
           
protected static Demultiplexer createDemultiplexer(javax.media.protocol.DataSource ds)
          Create a plugin parser based on the input DataSource.
static BasicSourceModule createModule(javax.media.protocol.DataSource ds)
           
 void doClose()
          This function performs the steps to close a module or Player.
 void doDealloc()
          This function performs the steps to deallocate a module or Player, and return to the realized state.
 void doFailedPrefetch()
          Called when prefetch fails.
 void doFailedRealize()
          Called when realize fails.
 boolean doPrefetch()
          This function performs the steps to prefetch a module or Player.
 boolean doRealize()
          Parsed in the input to get the track info.
 void doStart()
          This function performs the steps to start a module or Player.
 void doStop()
          This is a blocking pause.
 long getBitsRead()
           
 java.lang.Object getControl(java.lang.String s)
          Obtain the object that implements the specified Class or Interface The full class or interface name must be used.
 java.lang.Object[] getControls()
          Return a list of module controls.
 Demultiplexer getDemultiplexer()
           
 Time getDuration()
          Get the duration of the media represented by this object.
 java.lang.String[] getOutputConnectorNames()
          Return an array of strings containing this media module's output port names.
 boolean isPositionable()
           
 boolean isRandomAccess()
          Find out if this source can be repositioned to any point in the stream.
 void pause()
          This is essentially a non-blocking version of doStop.
 void process()
          function which does the real processing.
 void reset()
          reset this module only.
 void resetBitsRead()
           
 void setFormat(Connector connector, Format format)
          Selects a format for this Connector (the default is null).
 Time setPosition(Time when, int rounding)
          Set the position to the specified time.
 
从类 com.sun.media.BasicModule 继承的方法
canRun, connectorPushed, doSetMediaTime, doSetRate, error, getController, getInputConnector, getInputConnectorNames, getLatency, getMediaNanoseconds, getMediaTime, getName, getOutputConnector, getProtocol, getState, isInterrupted, isThreaded, prefetchFailed, registerInputConnector, registerOutputConnector, setController, setJMD, setModuleListener, setName, setProtocol, verifyBuffer
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

source

protected javax.media.protocol.DataSource source

parser

protected Demultiplexer parser

tracks

protected Track[] tracks

loops

protected com.sun.media.SourceThread[] loops

connectorNames

protected java.lang.String[] connectorNames

bitsRead

protected long bitsRead

started

protected boolean started

systemTimeBase

protected SystemTimeBase systemTimeBase

lastSystemTime

protected long lastSystemTime

originSystemTime

protected long originSystemTime

currentSystemTime

protected long currentSystemTime

lastPositionSet

protected Time lastPositionSet

errMsg

public java.lang.String errMsg
构造方法详细信息

BasicSourceModule

protected BasicSourceModule(javax.media.protocol.DataSource ds,
                            Demultiplexer demux)
方法详细信息

createModule

public static BasicSourceModule createModule(javax.media.protocol.DataSource ds)
                                      throws java.io.IOException,
                                             IncompatibleSourceException
抛出:
java.io.IOException
IncompatibleSourceException

createDemultiplexer

protected static Demultiplexer createDemultiplexer(javax.media.protocol.DataSource ds)
                                            throws java.io.IOException,
                                                   IncompatibleSourceException
Create a plugin parser based on the input DataSource.

抛出:
java.io.IOException
IncompatibleSourceException

doRealize

public boolean doRealize()
Parsed in the input to get the track info. This should be called in Player.realize() or Processor.connect().

指定者:
接口 StateTransistor 中的 doRealize
覆盖:
BasicModule 中的 doRealize
返回:
true if successful.

doFailedRealize

public void doFailedRealize()
从类 BasicModule 复制的描述
Called when realize fails.

指定者:
接口 StateTransistor 中的 doFailedRealize
覆盖:
BasicModule 中的 doFailedRealize

abortRealize

public void abortRealize()
从类 BasicModule 复制的描述
Called when the realize() is aborted, i.e. deallocate() was called while realizing. Release all resources claimed previously by the realize() call.

指定者:
接口 StateTransistor 中的 abortRealize
覆盖:
BasicModule 中的 abortRealize

doPrefetch

public boolean doPrefetch()
从类 BasicModule 复制的描述
This function performs the steps to prefetch a module or Player.

指定者:
接口 StateTransistor 中的 doPrefetch
覆盖:
BasicModule 中的 doPrefetch
返回:
true if successful.

doFailedPrefetch

public void doFailedPrefetch()
从类 BasicModule 复制的描述
Called when prefetch fails.

指定者:
接口 StateTransistor 中的 doFailedPrefetch
覆盖:
BasicModule 中的 doFailedPrefetch

abortPrefetch

public void abortPrefetch()
从类 BasicModule 复制的描述
Called when the prefetch() is aborted, i.e. deallocate() was called while prefetching. Release all resources claimed previously by the prefetch call.

指定者:
接口 StateTransistor 中的 abortPrefetch
覆盖:
BasicModule 中的 abortPrefetch

doStart

public void doStart()
从类 BasicModule 复制的描述
This function performs the steps to start a module or Player.

指定者:
接口 StateTransistor 中的 doStart
覆盖:
BasicModule 中的 doStart

doStop

public void doStop()
This is a blocking pause.

指定者:
接口 StateTransistor 中的 doStop
覆盖:
BasicModule 中的 doStop

pause

public void pause()
This is essentially a non-blocking version of doStop.


doDealloc

public void doDealloc()
从类 BasicModule 复制的描述
This function performs the steps to deallocate a module or Player, and return to the realized state.

指定者:
接口 StateTransistor 中的 doDealloc
覆盖:
BasicModule 中的 doDealloc

doClose

public void doClose()
从类 BasicModule 复制的描述
This function performs the steps to close a module or Player.

指定者:
接口 StateTransistor 中的 doClose
覆盖:
BasicModule 中的 doClose

reset

public void reset()
从类 BasicModule 复制的描述
reset this module only.
 if (state== Started)
    throw Exception()
 for (all connectors)
    connector.reset()
 
The resetted flag is falsified only when the module is later restarted.

指定者:
接口 Module 中的 reset
覆盖:
BasicModule 中的 reset

getOutputConnectorNames

public java.lang.String[] getOutputConnectorNames()
Return an array of strings containing this media module's output port names.

指定者:
接口 Module 中的 getOutputConnectorNames
覆盖:
BasicModule 中的 getOutputConnectorNames
返回:
list of output connectors as strings.

getDuration

public Time getDuration()
从接口 Duration 复制的描述
Get the duration of the media represented by this object. The value returned is the media's duration when played at the default rate. If the duration can't be determined (for example, the media object is presenting live video) getDuration returns DURATION_UNKNOWN.

指定者:
接口 Duration 中的 getDuration
返回:
A Time object representing the duration or DURATION_UNKNOWN.

setPosition

public Time setPosition(Time when,
                        int rounding)
从接口 javax.media.protocol.Positionable 复制的描述
Set the position to the specified time. Returns the rounded position that was actually set.

指定者:
接口 javax.media.protocol.Positionable 中的 setPosition
返回:
The actual position set.

isPositionable

public boolean isPositionable()

isRandomAccess

public boolean isRandomAccess()
从接口 javax.media.protocol.Positionable 复制的描述
Find out if this source can be repositioned to any point in the stream. If not, the source can only be repositioned to the beginning of the stream.

指定者:
接口 javax.media.protocol.Positionable 中的 isRandomAccess
返回:
Returns true if the source is random access; false if the source can only be reset to the beginning of the stream.

getControls

public java.lang.Object[] getControls()
从类 BasicModule 复制的描述
Return a list of module controls.

指定者:
接口 Controls 中的 getControls
覆盖:
BasicModule 中的 getControls
返回:
the collection of object controls

getControl

public java.lang.Object getControl(java.lang.String s)
从接口 Controls 复制的描述
Obtain the object that implements the specified Class or Interface The full class or interface name must be used.

If the control is not supported then null is returned.

指定者:
接口 Controls 中的 getControl
覆盖:
BasicModule 中的 getControl
返回:
the object that implements the control, or null.

getDemultiplexer

public Demultiplexer getDemultiplexer()

setFormat

public void setFormat(Connector connector,
                      Format format)
从类 BasicModule 复制的描述
Selects a format for this Connector (the default is null). The setFormat() method is typically called by the Manager as part of the Connector connection method call. Typically the connector would delegate this call to its owning Module.

指定者:
接口 Module 中的 setFormat
覆盖:
BasicModule 中的 setFormat

process

public void process()
从类 BasicModule 复制的描述
function which does the real processing.
 if canRun {
    for (all inputConnectors)
      ic.getValidBuffer()
    for (all outputConnectors)
      oc.getEmptyBuffer()
    
    for (all inputConnectors)
      ic.readReport()
    for (all outputConnectors)
      oc.writeReport()
 }
 

指定者:
BasicModule 中的 process

getBitsRead

public long getBitsRead()

resetBitsRead

public void resetBitsRead()

checkLatency

public void checkLatency()

checkAllPaused

protected boolean checkAllPaused()