com.sun.media
类 BasicController

java.lang.Object
  继承者 com.sun.media.BasicController
所有已实现的接口:
Clock, Controller, Duration
直接已知子类:
BasicPlayer, PlaybackEngine

public abstract class BasicController
extends java.lang.Object
implements Controller, Duration

Media Controller implements the basic functionalities of a java.media.Controller. These include:<


字段摘要
protected  java.lang.String processError
           
protected  int state
           
protected  boolean stopThreadEnabled
           
 
从接口 javax.media.Controller 继承的字段
LATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, Unrealized
 
从接口 javax.media.Clock 继承的字段
RESET
 
从接口 javax.media.Duration 继承的字段
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
构造方法摘要
BasicController()
           
 
方法摘要
protected  void abortConfigure()
          Called when the configure() is aborted, i.e. deallocate() was called while realizing.
protected abstract  void abortPrefetch()
          Called when the prefetch() is aborted, i.e. deallocate() was called while prefetching.
protected abstract  void abortRealize()
          Called when the realize() is aborted, i.e. deallocate() was called while realizing.
 void addControllerListener(ControllerListener listener)
          Add a listener to the listenerList.
 void close()
          A subclass of this implement close to stop all threads to make it "finalizable", i.e., ready to be garbage collected.
protected  void completeConfigure()
          Called when the controller is realized and when all the ConfigureCompleteEvents from down stream Controllers have been received.
protected  void completePrefetch()
          Called when the controller is prefetched and when all the PrefetchCompleteEvents from down stream nodes have been received.
protected  void completeRealize()
          Called when the controller is realized and when all the RealizeCompleteEvents from down stream Controllers have been received.
 void configure()
           
 void deallocate()
          Aborts the current operation and cease any activity that consumes system resources.
protected  void dispatchEvent(ControllerEvent evt)
          An internal function to notify the listeners on the listener list the given event.
protected  void doClose()
          Invoked by close() to cleanup the Controller.
protected  boolean doConfigure()
          The stub function to perform the steps to configure the controller.
protected  void doDeallocate()
          Called by deallocate().
protected  void doFailedConfigure()
          Called when realize() has failed.
protected  void doFailedPrefetch()
          Called when the prefetch() has failed.
protected  void doFailedRealize()
          Called when realize() has failed.
protected abstract  boolean doPrefetch()
          The stub function to perform the steps to prefetch the controller.
protected abstract  boolean doRealize()
          The stub function to perform the steps to realize the controller.
protected  void doSetMediaTime(Time when)
           
protected  float doSetRate(float factor)
           
protected abstract  void doStart()
          Start immediately.
protected  void doStop()
          Invoked from stop().
protected  Clock getClock()
           
 Control getControl(java.lang.String type)
          Get the Control that supports the class or interface specified.
 Control[] getControls()
          Return a list of Control objects this Controller supports.
 Time getDuration()
          Return the duration of the media.
 long getMediaNanoseconds()
          Get the current media time in nanoseconds.
 Time getMediaTime()
          Return the current media time.
 float getRate()
          Get the current presentation speed.
 Time getStartLatency()
          Gets the Controller's start latency in nanoseconds.
 int getState()
          Get the current state of the controller.
 Time getStopTime()
          Get the preset stop time.
 Time getSyncTime()
          Return the Sync Time.
 int getTargetState()
          Get the current target state.
 TimeBase getTimeBase()
          Gets the TimeBase that this Clock is using.
protected  void interrupt()
          Interrupt the process.
protected abstract  boolean isConfigurable()
          Subclass should define this.
protected  boolean isInterrupted()
          Return true if the process is interrupted.
 Time mapToTimeBase(Time t)
          Map the given media-time to time-base-time.
 void prefetch()
          Take the necessary steps to prefetch the controller.
 void realize()
          Take the necessary steps to realize the controller.
 void removeControllerListener(ControllerListener listener)
          Remove a listener from the listener list.
protected  void resetInterrupt()
          Reset the interrupted flag.
protected  void sendEvent(ControllerEvent evt)
          Send an event to the listeners listening to my events.
protected  void setClock(Clock c)
          Subclass can use this to switch to a different default clock.
protected  void setMediaLength(long t)
           
 void setMediaTime(Time when)
          Sets the Clock's media time.
 float setRate(float factor)
          Sets the temporal scale factor.
 void setStopTime(Time t)
          Sets the media time at which you want the Clock to stop.
protected  void setTargetState(int state)
          Set the target state.
 void setTimeBase(TimeBase tb)
          Sets the TimeBase for this Clock.
 void stop()
          Stop the controller.
protected  void stopAtTime()
          Stop because stop time has been reached.
protected  void stopControllerOnly()
          Stop the controller.
 void syncStart(Time tbt)
          Synchronizes the current media time to the specified time-base time and start the Clock.
protected  boolean syncStartInProgress()
           
protected  void throwError(java.lang.Error e)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

state

protected int state

processError

protected java.lang.String processError

stopThreadEnabled

protected boolean stopThreadEnabled
构造方法详细信息

BasicController

public BasicController()
方法详细信息

isConfigurable

protected abstract boolean isConfigurable()
Subclass should define this. If this return true, the controller will go through the Configured state. For example, the Controller implementing the Processor should return true.


setClock

protected void setClock(Clock c)
Subclass can use this to switch to a different default clock.


getClock

protected Clock getClock()

interrupt

protected void interrupt()
Interrupt the process.


resetInterrupt

protected void resetInterrupt()
Reset the interrupted flag.


isInterrupted

protected boolean isInterrupted()
Return true if the process is interrupted.


doConfigure

protected boolean doConfigure()
The stub function to perform the steps to configure the controller. Call configure() for the public method.


abortConfigure

protected void abortConfigure()
Called when the configure() is aborted, i.e. deallocate() was called while realizing. Release all resources claimed previously by the configure() call. Override this to implement subclass behavior.


doRealize

protected abstract boolean doRealize()
The stub function to perform the steps to realize the controller. Call realize() for the public method. This is called from a separately running thread. So do take necessary precautions to protect shared resources. It's OK to put an empty stub function body here.

Return true if the realize is successful. Return false and set the processError string if failed.

This function is not declared synchronized because first it is already guaranteed by realize() not to be called more than once simultaneously. Secondly if this is synchronized, then other synchronized methods, deallocate() and processEvent() will be blocked since they are synchronized methods. Override this to implement subclass behavior.

返回:
true if successful.

abortRealize

protected abstract void abortRealize()
Called when the realize() is aborted, i.e. deallocate() was called while realizing. Release all resources claimed previously by the realize() call. Override this to implement subclass behavior.


doPrefetch

protected abstract boolean doPrefetch()
The stub function to perform the steps to prefetch the controller. Call prefetch for the public method. This is called from a separately running thread. So do take necessary precautions to protect shared resources. It's OK to put an empty stub function body here.

Return true if the prefetch is successful. Return false and set the processError string if failed.

This function is not declared synchronized because first it is already guaranteed by realize() not to be called more than once simultaneously. Secondly if this is synchronized, then other synchronized methods, deallocate() and processEvent() will be blocked since they are synchronized methods. Override this to implement subclass behavior.

返回:
true if successful.

abortPrefetch

protected abstract void abortPrefetch()
Called when the prefetch() is aborted, i.e. deallocate() was called while prefetching. Release all resources claimed previously by the prefetch call. Override this to implement subclass behavior.


doStart

protected abstract void doStart()
Start immediately. Invoked from start(tbt) when the scheduled start time is reached. Use the public start(tbt) method for the public interface. Override this to implement subclass behavior.


doStop

protected void doStop()
Invoked from stop(). Override this to implement subclass behavior.


close

public final void close()
A subclass of this implement close to stop all threads to make it "finalizable", i.e., ready to be garbage collected.

指定者:
接口 Controller 中的 close

doClose

protected void doClose()
Invoked by close() to cleanup the Controller. Override this to implement subclass behavior.


setTimeBase

public void setTimeBase(TimeBase tb)
                 throws IncompatibleTimeBaseException
从接口 Clock 复制的描述
Sets the TimeBase for this Clock. This method can only be called on a Stopped Clock. A ClockStartedError is thrown if setTimeBase is called on a Started  Clock.

A Clock has a default TimeBase that is determined by the implementation. To reset a Clock to its default TimeBase, call setTimeBase(null).

指定者:
接口 Clock 中的 setTimeBase
参数:
tb - The new TimeBase or null to reset the Clock to its default TimeBase.
抛出:
IncompatibleTimeBaseException - Thrown if the Clock can't use the specified TimeBase.

getControls

public Control[] getControls()
Return a list of Control objects this Controller supports. If there are no controls, then an array of length zero is returned.

指定者:
接口 Controller 中的 getControls
返回:
list of Controller controls.

getControl

public Control getControl(java.lang.String type)
Get the Control that supports the class or interface specified. The full class or interface name should be specified. Null is returned if the Control is not supported.

指定者:
接口 Controller 中的 getControl
返回:
Control for the class or interface name.

syncStart

public void syncStart(Time tbt)
从接口 Clock 复制的描述
Synchronizes the current media time to the specified time-base time and start the Clock. The syncStart method sets the time-base start-time, and puts the Clock in the Started state. This method can only be called on a Stopped Clock. A ClockStartedError is thrown if setTimeBase is called on a Started  Clock.

指定者:
接口 Clock 中的 syncStart
参数:
tbt - The time-base time to equate with the current media time.

syncStartInProgress

protected boolean syncStartInProgress()

stop

public void stop()
Stop the controller. Invoke clock.stop() to maintain the clock states. The subclass should implement and further specialized this method to do the real work. But it should also invoke this method to maintain the correct states.

指定者:
接口 Clock 中的 stop

stopControllerOnly

protected void stopControllerOnly()
Stop the controller. Invoke clock.stop() to maintain the clock states. The subclass should implement and further specialized this method to do the real work. But it should also invoke this method to maintain the correct states.


stopAtTime

protected void stopAtTime()
Stop because stop time has been reached. Subclasses should override this method.


setStopTime

public void setStopTime(Time t)
从接口 Clock 复制的描述
Sets the media time at which you want the Clock to stop. The Clock will stop when its media time passes the stop-time. To clear the stop time, set it to: Clock.RESET.

You can always call setStopTime on a Stopped  Clock.

On a Started Clock, the stop-time can only be set once. A StopTimeSetError is thrown if setStopTime is called and the media stop-time has already been set.

指定者:
接口 Clock 中的 setStopTime
参数:
t - The time at which you want the Clock to stop, in media time.

getStopTime

public Time getStopTime()
Get the preset stop time.

指定者:
接口 Clock 中的 getStopTime
返回:
the preset stop time.

setMediaTime

public void setMediaTime(Time when)
从接口 Clock 复制的描述
Sets the Clock's media time. This method can only be called on a Stopped Clock. A ClockStartedError is thrown if setMediaTime is called on a Started  Clock.

指定者:
接口 Clock 中的 setMediaTime
参数:
when - The new media time.

doSetMediaTime

protected void doSetMediaTime(Time when)

getMediaTime

public Time getMediaTime()
Return the current media time. Uses the clock to do the computation. A subclass can override this method to do the right thing for itself.

指定者:
接口 Clock 中的 getMediaTime
返回:
the current media time.

getMediaNanoseconds

public long getMediaNanoseconds()
Get the current media time in nanoseconds.

指定者:
接口 Clock 中的 getMediaNanoseconds
返回:
the media time in nanoseconds.

getSyncTime

public Time getSyncTime()
Return the Sync Time. Not yet implementated.

指定者:
接口 Clock 中的 getSyncTime

getTimeBase

public TimeBase getTimeBase()
从接口 Clock 复制的描述
Gets the TimeBase that this Clock is using.

指定者:
接口 Clock 中的 getTimeBase

mapToTimeBase

public Time mapToTimeBase(Time t)
                   throws ClockStoppedException
Map the given media-time to time-base-time.

指定者:
接口 Clock 中的 mapToTimeBase
参数:
t - given media time.
返回:
timebase time.
抛出:
ClockStoppedException - thrown if the Controller has already been stopped.

setRate

public float setRate(float factor)
从接口 Clock 复制的描述
Sets the temporal scale factor. The argument suggests the scale factor to use.

The setRate method returns the actual rate set by the Clock. Clocks should set their rate as close to the requested value as possible, but are not required to set the rate to the exact value of any argument other than 1.0. A Clock is only guaranteed to set its rate exactly to 1.0.

You can only call this method on a Stopped Clock. A ClockStartedError is thrown if setRate is called on a Started Clock.

指定者:
接口 Clock 中的 setRate
参数:
factor - The temporal scale factor (rate) to set.
返回:
The actual rate set.

doSetRate

protected float doSetRate(float factor)

getRate

public float getRate()
Get the current presentation speed.

指定者:
接口 Clock 中的 getRate
返回:
the current presentation speed.

getState

public final int getState()
Get the current state of the controller.

指定者:
接口 Controller 中的 getState
返回:
the current state of the controller.

setTargetState

protected final void setTargetState(int state)
Set the target state.


getTargetState

public final int getTargetState()
Get the current target state.

指定者:
接口 Controller 中的 getTargetState
返回:
the current target state.

getStartLatency

public Time getStartLatency()
从接口 Controller 复制的描述
Gets the Controller's start latency in nanoseconds. The start latency represents a worst-case estimate of the amount of time it will take to present the first frame of data.

This method is useful for determining how far in advance the syncStart method must be invoked to ensure that media will be rendered at the specified start time.

For a Controller that has a variable start latency, the value returned represents the maximum possible start latency. If you call getStartLatency on a Controller that isn't Prefetched and getStartLatency returns LATENCY_UNKNOWN, calling prefetch and then calling getStartLatency again after the Controller posts a PrefetchCompleteEvent might return a more accurate estimate. If getStartLatency still returns LATENCY_UNKNOWN, the start latency is indeterminate and you might not be able to use syncStart to synchronize the Controller with other Controllers.

Note: In most cases, the value returned by getStartLatency will change once the Controller is Prefetched.

指定者:
接口 Controller 中的 getStartLatency
返回:
The time it will take before the first frame of media can be presented.

getDuration

public Time getDuration()
Return the duration of the media. It's unknown until we implement a particular node.

指定者:
接口 Duration 中的 getDuration
返回:
the duration of the media.

setMediaLength

protected void setMediaLength(long t)

configure

public void configure()

completeConfigure

protected void completeConfigure()
Called when the controller is realized and when all the ConfigureCompleteEvents from down stream Controllers have been received. If a subclass wants to override this method, it should still invoke this to ensure the correct events being sent to the upstream Controllers.


doFailedConfigure

protected void doFailedConfigure()
Called when realize() has failed.


realize

public final void realize()
Take the necessary steps to realize the controller. This is a non-blocking call. It starts a work thread to do the real work. The actual code to do the realizing should be written in doRealize(). The thread is also responsible for catching all the RealizeCompleteEvents from the down stream nodes. When the steps to realize the controller are completed and when all the RealizeCompleteEvents from down stream nodes have been received, the completeRealize() call will be invoked.

指定者:
接口 Controller 中的 realize

completeRealize

protected void completeRealize()
Called when the controller is realized and when all the RealizeCompleteEvents from down stream Controllers have been received. If a subclass wants to override this method, it should still invoke this to ensure the correct events being sent to the upstream Controllers.


doFailedRealize

protected void doFailedRealize()
Called when realize() has failed.


prefetch

public final void prefetch()
Take the necessary steps to prefetch the controller. This is a non-blocking call. It starts a work thread to do the real work. The actual code to do the realizing should be written in doPrefetch(). The thread is also responsible for catching all the PrefetchCompleteEvents from the down stream nodes. When the steps to prefetch the controller are completed and when all the PrefetchCompleteEvents from down stream nodes have been received, the completePrefetch() call will be invoked.

指定者:
接口 Controller 中的 prefetch

completePrefetch

protected void completePrefetch()
Called when the controller is prefetched and when all the PrefetchCompleteEvents from down stream nodes have been received. If a subclass wants to override this method, it should still invoke this to ensure the correct events being sent to the upstream Controllers.


doFailedPrefetch

protected void doFailedPrefetch()
Called when the prefetch() has failed.


deallocate

public final void deallocate()
从接口 Controller 复制的描述
Aborts the current operation and cease any activity that consumes system resources. If a Controller is not yet Realized, it returns to the Unrealized state. Otherwise, the Controller returns to the Realized state.

It is illegal to call deallocate on a Started Controller. A ClockStartedError is thrown if deallocate is called and the Controller is in the Started state.

指定者:
接口 Controller 中的 deallocate

doDeallocate

protected void doDeallocate()
Called by deallocate(). Subclasses should implement this for its specific behavior.


addControllerListener

public final void addControllerListener(ControllerListener listener)
Add a listener to the listenerList. This listener will be notified of this controller's event. This needs to be a synchronized method so as to maintain the integrity of the listenerList.

指定者:
接口 Controller 中的 addControllerListener
参数:
listener - The listener to which the Controller will post events.

removeControllerListener

public final void removeControllerListener(ControllerListener listener)
Remove a listener from the listener list. The listener will stop receiving notification from this controller. This needs to be a synchronized method so as to maintain the integrity of the listenerList.

指定者:
接口 Controller 中的 removeControllerListener
参数:
listener - The listener that has been receiving events from this Controller.

sendEvent

protected final void sendEvent(ControllerEvent evt)
Send an event to the listeners listening to my events. The event is Queued in the sendEvtQueue which runs in a separate thread. This way, sendEvent() won't be blocked.


dispatchEvent

protected final void dispatchEvent(ControllerEvent evt)
An internal function to notify the listeners on the listener list the given event. This gets called by the sendEvtQueue's processEvent() callback. This method updates a lock on the Vector listenerList before enumerating it.


throwError

protected void throwError(java.lang.Error e)