All Packages Class Hierarchy This Package Previous Next Index
Class ejmf.toolkit.media.AbstractController
java.lang.Object
|
+----ejmf.toolkit.media.AbstractClock
|
+----ejmf.toolkit.media.AbstractController
- public abstract class AbstractController
- extends AbstractClock
- implements Controller
The AbstractController class provides a basic implementation of a
javax.media.Controller. Subclasses should implement the
following abstract "do" methods to transition their Controller:
- doRealize()
- doPrefetch()
- doSyncStart()
- doDeallocate()
- doStop()
Follow these rules when implementing these methods:
- Do not return until the state change is complete. Once the
state change is complete, return ASAP.
- Do not call one another. They will be called in the correct
order at the correct time.
- Do not set the current or target states. They are set
automatically.
- Do not post any TransitionEvents. They are posted
automatically.
- Do not call any of the Clock routines. They will be called
automatically.
- Return true if successful. If unsuccessful, post an
appropriate ControllerErrorEvent and return false.
- When the end of the media has been reached, call endOfMedia().
This will post an EndOfMediaEvent and set the appropriate
states. Do not post an EndOfMediaEvent in any other way.
Other abstact methods that should be implemented are:
- doClose()
- doSetMediaTime()
- doSetRate()
- See Also:
- AbstractPlayer
-
AbstractController()
- Construct a AbstractController.
-
addControl(Control)
- Add a Control to this Controller.
-
addControllerListener(ControllerListener)
- Specify a ControllerListener to which this Controller will
send events.
-
blockUntilStart(Time)
- For a given time-base start time, block until the
AbstractController should be started.
-
close()
- Close the Controller.
-
deallocate()
- Deallocate Controller on current thread.
-
doClose()
- Close the Controller.
-
doDeallocate()
- Implement to deallocate the Controller.
-
doPrefetch()
- Implement to prefetch the Controller.
-
doRealize()
- Implement to realize the Controller.
-
doSetMediaTime(Time)
- Override to provide implementation-specific functionality.
-
doSetRate(float)
- Override to provide implementation-specific functionality.
-
doStop()
- Implement to stop the Controller.
-
doSyncStart(Time)
- Implement to start the Controller.
-
endOfMedia()
- Indicates to the framework that the end of media has been
reached.
-
getControl(String)
- Get the Control that supports the class or interface
specified.
-
getControls()
- Get a list of the Control objects that this Controller
supports.
-
getDuration()
- Returns DURATION_UNKNOWN.
-
getMediaTime()
- Calculates the current media time based on the current
time-base time, the time-base start time, the media start
time, and the rate.
-
getPreviousState()
- Get the previous state of this Controller.
-
getStartLatency()
- Returns LATENCY_UNKNOWN.
-
getState()
- Get the current state of this Controller.
-
getTargetState()
- Get the target state of this Controller.
-
getThreadQueue()
- Gets the ThreadQueue object for this AbstractController.
-
getTimeBase()
- Get the TimeBase that this Controller is using.
-
postControllerClosedEvent()
- Post a ControllerClosedEvent to the Media Event Queue.
-
postDataStarvedEvent()
- Post a DataStarvedEvent to the Media Event Queue.
-
postDeallocateEvent()
- Post a DeallocateEvent to the Media Event Queue.
-
postEndOfMediaEvent()
- Post a EndOfMediaEvent to the Media Event Queue.
-
postEvent(ControllerEvent)
- Post a ControllerEvent to the Media Event Queue
-
postPrefetchCompleteEvent()
- Post a PrefetchCompleteEvent to the Media Event Queue.
-
postRealizeCompleteEvent()
- Post a RealizeCompleteEvent to the Media Event Queue.
-
postRestartingEvent()
- Post a RestartingEvent to the Media Event Queue.
-
postStartEvent()
- Post a StartEvent to the Media Event Queue.
-
postStopAtTimeEvent()
- Post a StopAtTimeEvent to the Media Event Queue.
-
postStopByRequestEvent()
- Post a StopByRequestEvent to the Media Event Queue.
-
postStopEvent()
- Post a StopEvent to the Media Event Queue.
-
postTransitionEvent()
- Post a TransitionEvent to the Media Event Queue.
-
prefetch()
- Prefetch Controller on new thread.
-
realize()
- Realize Controller on new thread.
-
removeControl(Control)
- Remove a Control from this Controller.
-
removeControllerListener(ControllerListener)
- Remove the specified listener from this Controller's
listener list.
-
setMediaTime(Time)
- Sets the media time.
-
setRate(float)
- Set the temporal scale factor.
-
setState(int)
- Set the current state of this Controller.
-
setStopTime(Time)
- Sets the stop time for this AbstractController.
-
setTargetState(int)
- Set the targetState state of this Controller.
-
setTimeBase(TimeBase)
- Set the
TimeBase
for this Clock
.
-
stop()
- Stop Controller on current thread and post a
StopByRequestEvent.
-
stopAtTime()
- Stop Controller on current thread and post a
StopAtTimeEvent.
-
stopController()
- Stop the controller.
-
stopInRestart()
- Stop Controller on current thread and post a
RestartingEvent.
-
synchronousPrefetch()
- Realize the AbstractController synchronously.
-
synchronousRealize()
- Realize the AbstractController synchronously.
-
synchronousSyncStart(Time)
- SyncStart the AbstractController synchronously at the
previously-specified time-base start time.
-
syncStart(Time)
- SyncStart Controller on new thread.
AbstractController
public AbstractController()
- Construct a AbstractController.
doRealize
public abstract boolean doRealize()
- Implement to realize the Controller.
This method should not be called directly. Instead, call
realize().
- Returns:
- True if successful, false otherwise.
doPrefetch
public abstract boolean doPrefetch()
- Implement to prefetch the Controller.
This method should not be called directly. Instead, call
prefetch().
- Returns:
- True if successful, false otherwise.
doSyncStart
public abstract boolean doSyncStart(Time t)
- Implement to start the Controller.
This method should not be called directly. Instead, call
syncStart().
- Returns:
- True if successful, false otherwise.
doDeallocate
public abstract boolean doDeallocate()
- Implement to deallocate the Controller.
This method should not be called directly. Instead, call
prefetch().
- Returns:
- True if successful, false otherwise.
doStop
public abstract boolean doStop()
- Implement to stop the Controller.
This method should not be called directly. Instead, call
stop().
- Returns:
- True if successful, false otherwise.
doClose
public abstract void doClose()
- Close the Controller. Typically this method will release as
many resources as possible, especially those that may be
needed by other Controllers.
This method should not be called directly. Instead, call
close().
doSetMediaTime
public abstract void doSetMediaTime(Time t)
- Override to provide implementation-specific functionality.
When this method is called, it is guaranteed that the
Controller is Stopped and that the given time is within the
Controller's duration.
This method should not be called directly. Instead, call
setMediaTime().
- Parameters:
- t
- The media time to set
doSetRate
public abstract float doSetRate(float rate)
- Override to provide implementation-specific functionality.
When this method is called, it is guaranteed that the
Controller is Stopped.
This method should not be called directly. Instead, call
setRate().
- Parameters:
- rate
- The requested rate to set
- Returns:
- The actual rate that was set
setTimeBase
public synchronized void setTimeBase(TimeBase timebase) throws IncompatibleTimeBaseException
- Set 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)
.
- Parameters:
- timebase
- The new
TimeBase
or
null
to reset the
Clock
to its default
TimeBase
.
- Throws: IncompatibleTimeBaseException
- Thrown if the
Clock
can't use the
specified TimeBase
.
- Overrides:
- setTimeBase in class AbstractClock
getTimeBase
public synchronized TimeBase getTimeBase()
- Get the TimeBase that this Controller is using.
- Overrides:
- getTimeBase in class AbstractClock
setStopTime
public synchronized void setStopTime(Time mediaStopTime)
- Sets the stop time for this AbstractController. Posts a
StopTimeChangeEvent if the stop time given is different
than the current stop time.
- Parameters:
- mediaStopTime
- The time at which you want the
Clock
to stop, in media
time.
- Throws: NotRealizedError
- If the Controller is not Realized.
- Throws: ClockStartedError
- If the Controller is Started.
- Overrides:
- setStopTime in class AbstractClock
setMediaTime
public synchronized void setMediaTime(Time t)
- Sets the media time.
- Parameters:
- t
- The media time to set
- Throws: NotRealizedError
- If the Controller is not Realized.
- Throws: ClockStartedError
- If the Controller is Started.
- Overrides:
- setMediaTime in class AbstractClock
getMediaTime
public synchronized Time getMediaTime()
- Calculates the current media time based on the current
time-base time, the time-base start time, the media start
time, and the rate.
- Returns:
- The current media time
- Overrides:
- getMediaTime in class AbstractClock
setRate
public synchronized float setRate(float rate)
- Set 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.
- Parameters:
- rate
- The temporal scale factor (rate) to set.
- Returns:
- The actual rate set.
- Throws: NotRealizedError
- If the Controller is not Realized.
- Throws: ClockStartedError
- If the Controller is Started.
- Overrides:
- setRate in class AbstractClock
getDuration
public Time getDuration()
- Returns DURATION_UNKNOWN. This method should be
overridden to report a more precise duration.
realize
public final synchronized void realize()
- Realize Controller on new thread. Subclasses should
override doRealize() to do the actual work to transition
the Controller.
Checks for Controller state prerequisites and creates a
RealizeThread to realize the AbstractController. If there
is already a thread transitioning the AbstractController
forward, then the target state of the AbstractController is
set to Realized and the method returns.
Asynchronous method -- Start synchronous transition on
another thread and return ASAP.
prefetch
public final synchronized void prefetch()
- Prefetch Controller on new thread. Subclasses should
override doPrefetch() to do the actual work to transition
the Controller.
Checks for Controller state prerequisites and creates a
PrefetchThread to prefetch the AbstractController. If there
is already a thread transitioning the AbstractController
forward, then the target state of the AbstractController is
set to Prefetched and the method returns.
Asynchronous method -- Start synchronous transition on
another thread and return ASAP.
syncStart
public final synchronized void syncStart(Time t)
- SyncStart Controller on new thread. Subclasses should
override doSyncStart() to do the actual work to transition the
Controller.
Checks for Controller state prerequisites and creates a
SyncStartThread to syncstart the AbstractController. The
target state of the AbstractController is then set to
Started and the thread is started.
Asynchronous method -- Start synchronous transition on
another thread and return ASAP.
- Overrides:
- syncStart in class AbstractClock
deallocate
public final synchronized void deallocate()
- Deallocate Controller on current thread. Subclasses
should override doDeallocate() to do the actual work to
transition the Controller. After ensuring state
prerequisites, this method will call doDeallocate(). If
doDeallocate() returns true, then the Controller is placed
in the appropriate state and a DeallocateCompleteEvent is
posted. Otherwise, it is assumed that the controller has
posted a ControllerErrorEvent detailing the reasons for
it's failure.
Synchronous method -- return when transition complete
stop
public final void stop()
- Stop Controller on current thread and post a
StopByRequestEvent. Subclasses should override doStop()
to do the actual work to stop the Controller.
- Overrides:
- stop in class AbstractClock
stopAtTime
protected void stopAtTime()
- Stop Controller on current thread and post a
StopAtTimeEvent. Subclasses should override doStop() to
do the actual work to stop the Controller.
This method is usually only called (indirectly) by the
StopTimeMonitor class.
Synchronous method -- return when transition complete
stopInRestart
protected void stopInRestart()
- Stop Controller on current thread and post a
RestartingEvent. Subclasses should override doStop() to
do the actual work to stop the Controller.
This method is usually only called (indirectly) by
Player.setMediaTime() or Player.setRate() when a managed
Controller must be stopped before its media time and rate,
respectively, can be set.
Synchronous method -- return when transition complete
stopController
protected synchronized boolean stopController()
- Stop the controller. If the Controller is Realizing or
Prefetching, then the target state will be set to Realized
or Prefetched, respectively, and the Controller will stop
when it completes the transition. If the Controller is
Started, this method will call doStop(). If doStop()
returns true, then the Controller is placed in the
Prefetched state and a StopEvent is posted. If doStop()
returns false, it is assumed that the controller has
posted a ControllerErrorEvent detailing the reasons for
it's failure.
Synchronous method -- return when transition complete
- Returns:
- boolean indicating whether the
stop was successful.
close
public final synchronized void close()
- Close the Controller. Release resources held by this
Controller. Subclasses should implement doClose() to
add additional functionality.
addControl
public void addControl(Control newControl)
- Add a Control to this Controller.
- Parameters:
- newControl
- The Control to add.
removeControl
public void removeControl(Control oldControl)
- Remove a Control from this Controller.
- Parameters:
- oldControl
- The Control to remove.
getControls
public Control[] getControls()
- Get a list of the Control objects that this Controller
supports. If there are no controls, an array of length
zero is returned.
- Returns:
- A list of Controller Controls.
getControl
public Control getControl(String forName)
- 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.
- Returns:
- Control for the given class or interface
name, or null if no such Control is supported.
addControllerListener
public void addControllerListener(ControllerListener listener)
- Specify a ControllerListener to which this Controller will
send events.
- Parameters:
- listener
- The listener to which the Controller will post
events.
removeControllerListener
public void removeControllerListener(ControllerListener listener)
- Remove the specified listener from this Controller's
listener list.
- Parameters:
- listener
- The listener that has been receiving events
from this Controller.
getPreviousState
public int getPreviousState()
- Get the previous state of this Controller.
setState
protected synchronized void setState(int state)
- Set the current state of this Controller. This will
implicitly set the previous state as well.
getState
public int getState()
- Get the current state of this Controller.
setTargetState
protected void setTargetState(int state)
- Set the targetState state of this Controller.
getTargetState
public int getTargetState()
- Get the target state of this Controller.
endOfMedia
protected synchronized void endOfMedia() throws ClockStoppedException
- Indicates to the framework that the end of media has been
reached. Marks the media time, sets the current and target
states to Prefetched, and posts an EndOfMediaEvent.
- Throws: ClockStoppedException
- If the AbstractController is not in the Started
state.
postEvent
protected void postEvent(ControllerEvent event)
- Post a ControllerEvent to the Media Event Queue
- Parameters:
- event
- The ControllerEvent to post.
postTransitionEvent
protected void postTransitionEvent()
- Post a TransitionEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
and Target State properties of the TransitionEvent.
postRealizeCompleteEvent
protected void postRealizeCompleteEvent()
- Post a RealizeCompleteEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
and Target State properties of the RealizeCompleteEvent.
postPrefetchCompleteEvent
protected void postPrefetchCompleteEvent()
- Post a PrefetchCompleteEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
and Target State properties of the PrefetchCompleteEvent.
postDeallocateEvent
protected void postDeallocateEvent()
- Post a DeallocateEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
DeallocateEvent.
postStopEvent
protected void postStopEvent()
- Post a StopEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
StopEvent.
postStopAtTimeEvent
protected void postStopAtTimeEvent()
- Post a StopAtTimeEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
StopAtTimeEvent.
postStartEvent
protected void postStartEvent()
- Post a StartEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, Media Time, and Time-base Time properties of
the StartEvent.
postDataStarvedEvent
protected void postDataStarvedEvent()
- Post a DataStarvedEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
DataStarvedEvent.
postEndOfMediaEvent
protected void postEndOfMediaEvent()
- Post a EndOfMediaEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
EndOfMediaEvent.
postRestartingEvent
protected void postRestartingEvent()
- Post a RestartingEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
RestartingEvent.
postStopByRequestEvent
protected void postStopByRequestEvent()
- Post a StopByRequestEvent to the Media Event Queue.
Automatically fill in the Previous State, Current State,
Target State, and Media Time properties of the
StopByRequestEvent.
postControllerClosedEvent
protected void postControllerClosedEvent()
- Post a ControllerClosedEvent to the Media Event Queue.
getThreadQueue
protected ThreadQueue getThreadQueue()
- Gets the ThreadQueue object for this AbstractController.
synchronousRealize
protected void synchronousRealize()
- Realize the AbstractController synchronously.
This method should not be called directly. Instead, call
realize().
Synchronous method -- return when transition complete
synchronousPrefetch
protected void synchronousPrefetch()
- Realize the AbstractController synchronously.
This method should not be called directly. Instead, call
prefetch().
Synchronous method -- return when transition complete
getStartLatency
public Time getStartLatency()
- Returns LATENCY_UNKNOWN. This method should be
overridden to report a more precise start latency.
synchronousSyncStart
protected void synchronousSyncStart(Time t)
- SyncStart the AbstractController synchronously at the
previously-specified time-base start time.
This method should not be called directly. Instead, call
syncStart().
Synchronous method -- return when transition complete
blockUntilStart
public void blockUntilStart(Time t)
- For a given time-base start time, block until the
AbstractController should be started. For a given time-
base start time (t), this method will get the
AbstractController's start latency (l) and block until (t
- l). This method is useful for implementations of
doSyncStart().
If the time-base time (t - l) has already passed, return
immediately.
All Packages Class Hierarchy This Package Previous Next Index