|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.fmj.ejmf.toolkit.media.AbstractClock
net.sf.fmj.ejmf.toolkit.media.AbstractController
public abstract class AbstractController
The AbstractController class provides a basic implementation of a javax.media.Controller. Subclasses should implement the following abstract "do" methods to transition their Controller:
Follow these rules when implementing these methods:
Other abstact methods that should be implemented are:
From the book: Essential JMF, Gordon, Talley (ISBN 0130801046). Used with permission.
AbstractPlayer
Field Summary |
---|
Fields inherited from interface javax.media.Controller |
---|
LATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, Unrealized |
Fields inherited from interface javax.media.Clock |
---|
RESET |
Fields inherited from interface javax.media.Duration |
---|
DURATION_UNBOUNDED, DURATION_UNKNOWN |
Constructor Summary | |
---|---|
AbstractController()
Construct a AbstractController. |
Method Summary | |
---|---|
void |
addControl(Control newControl)
Add a Control to this Controller. |
void |
addControllerListener(ControllerListener listener)
Specify a ControllerListener to which this Controller will send events. |
void |
blockUntilStart(Time t)
For a given time-base start time, block until the AbstractController should be started. |
void |
close()
Close the Controller. |
void |
deallocate()
Deallocate Controller on current thread. |
abstract void |
doClose()
Close the Controller. |
abstract boolean |
doDeallocate()
Implement to deallocate the Controller. |
abstract boolean |
doPrefetch()
Implement to prefetch the Controller. |
abstract boolean |
doRealize()
Implement to realize the Controller. |
abstract void |
doSetMediaTime(Time t)
Override to provide implementation-specific functionality. |
abstract float |
doSetRate(float rate)
Override to provide implementation-specific functionality. |
abstract boolean |
doStop()
Implement to stop the Controller. |
abstract boolean |
doSyncStart(Time t)
Implement to start the Controller. |
protected void |
endOfMedia()
Indicates to the framework that the end of media has been reached. |
Control |
getControl(java.lang.String forName)
Get the Control that supports the class or interface specified. |
Control[] |
getControls()
Get a list of the Control objects that this Controller supports. |
Time |
getDuration()
Returns DURATION_UNKNOWN. |
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. |
int |
getPreviousState()
Get the previous state of this Controller. |
Time |
getStartLatency()
Returns LATENCY_UNKNOWN. |
int |
getState()
Get the current state of this Controller. |
int |
getTargetState()
Get the target state of this Controller. |
protected ThreadQueue |
getThreadQueue()
Gets the ThreadQueue object for this AbstractController. |
TimeBase |
getTimeBase()
Get the TimeBase that this Controller is using. |
protected void |
postControllerClosedEvent()
Post a ControllerClosedEvent to the Media Event Queue. |
protected void |
postControllerErrorEvent(java.lang.String msg)
Post a ControllerClosedEvent to the Media Event Queue. |
protected void |
postDataStarvedEvent()
Post a DataStarvedEvent to the Media Event Queue. |
protected void |
postDeallocateEvent()
Post a DeallocateEvent to the Media Event Queue. |
protected void |
postEndOfMediaEvent()
Post a EndOfMediaEvent to the Media Event Queue. |
protected void |
postEvent(ControllerEvent event)
Post a ControllerEvent to the Media Event Queue |
protected void |
postPrefetchCompleteEvent()
Post a PrefetchCompleteEvent to the Media Event Queue. |
protected void |
postRealizeCompleteEvent()
Post a RealizeCompleteEvent to the Media Event Queue. |
protected void |
postRestartingEvent()
Post a RestartingEvent to the Media Event Queue. |
protected void |
postStartEvent()
Post a StartEvent to the Media Event Queue. |
protected void |
postStopAtTimeEvent()
Post a StopAtTimeEvent to the Media Event Queue. |
protected void |
postStopByRequestEvent()
Post a StopByRequestEvent to the Media Event Queue. |
protected void |
postStopEvent()
Post a StopEvent to the Media Event Queue. |
protected void |
postTransitionEvent()
Post a TransitionEvent to the Media Event Queue. |
void |
prefetch()
Prefetch Controller on new thread. |
void |
realize()
Realize Controller on new thread. |
void |
removeControl(Control oldControl)
Remove a Control from this Controller. |
void |
removeControllerListener(ControllerListener listener)
Remove the specified listener from this Controller's listener list. |
void |
setMediaTime(Time t)
Sets the media time. |
float |
setRate(float rate)
Set the temporal scale factor. |
protected void |
setState(int state)
Set the current state of this Controller. |
void |
setStopTime(Time mediaStopTime)
Sets the stop time for this AbstractController. |
protected void |
setTargetState(int state)
Set the targetState state of this Controller. |
void |
setTimeBase(TimeBase timebase)
Set the TimeBase for this Clock . |
void |
stop()
Stop Controller on current thread and post a StopByRequestEvent. |
protected void |
stopAtTime()
Stop Controller on current thread and post a StopAtTimeEvent. |
protected boolean |
stopController()
Stop the controller. |
protected void |
stopInRestart()
Stop Controller on current thread and post a RestartingEvent. |
protected void |
synchronousPrefetch()
Realize the AbstractController synchronously. |
protected void |
synchronousRealize()
Realize the AbstractController synchronously. |
protected void |
synchronousSyncStart(Time t)
SyncStart the AbstractController synchronously at the previously-specified time-base start time. |
void |
syncStart(Time t)
SyncStart Controller on new thread. |
Methods inherited from class net.sf.fmj.ejmf.toolkit.media.AbstractClock |
---|
getMediaNanoseconds, getMediaStartTime, getRate, getStopTime, getSyncTime, getTimeBaseStartTime, mapToTimeBase |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.media.Clock |
---|
getMediaNanoseconds, getRate, getStopTime, getSyncTime, mapToTimeBase |
Constructor Detail |
---|
public AbstractController()
Method Detail |
---|
public abstract boolean doRealize()
This method should not be called directly. Instead, call realize().
public abstract boolean doPrefetch()
This method should not be called directly. Instead, call prefetch().
public abstract boolean doSyncStart(Time t)
This method should not be called directly. Instead, call syncStart().
public abstract boolean doDeallocate()
This method should not be called directly. Instead, call prefetch().
public abstract boolean doStop()
This method should not be called directly. Instead, call stop().
public abstract void doClose()
This method should not be called directly. Instead, call close().
public abstract void doSetMediaTime(Time t)
This method should not be called directly. Instead, call setMediaTime().
t
- The media time to setpublic abstract float doSetRate(float rate)
This method should not be called directly. Instead, call setRate().
rate
- The requested rate to set
public void setTimeBase(TimeBase timebase) throws IncompatibleTimeBaseException
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)
.
setTimeBase
in interface Clock
setTimeBase
in class AbstractClock
timebase
- The new TimeBase
or
null
to reset the
Clock
to its default
TimeBase
.
IncompatibleTimeBaseException
- Thrown if the Clock
can't use the
specified TimeBase
.public TimeBase getTimeBase()
getTimeBase
in interface Clock
getTimeBase
in class AbstractClock
public void setStopTime(Time mediaStopTime)
setStopTime
in interface Clock
setStopTime
in class AbstractClock
mediaStopTime
- The time at which you want the
Clock
to stop, in media
time.
NotRealizedError
- If the Controller is not Realized.
ClockStartedError
- If the Controller is Started.public void setMediaTime(Time t)
setMediaTime
in interface Clock
setMediaTime
in class AbstractClock
t
- The media time to set
NotRealizedError
- If the Controller is not Realized.
ClockStartedError
- If the Controller is Started.public Time getMediaTime()
getMediaTime
in interface Clock
getMediaTime
in class AbstractClock
public float setRate(float rate)
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.
setRate
in interface Clock
setRate
in class AbstractClock
rate
- The temporal scale factor (rate) to set.
NotRealizedError
- If the Controller is not Realized.
ClockStartedError
- If the Controller is Started.public Time getDuration()
getDuration
in interface Duration
public final void realize()
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.
realize
in interface Controller
public final void prefetch()
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.
prefetch
in interface Controller
public final void syncStart(Time t)
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.
syncStart
in interface Clock
syncStart
in class AbstractClock
public final void deallocate()
Synchronous method -- return when transition complete
deallocate
in interface Controller
public final void stop()
stop
in interface Clock
stop
in class AbstractClock
protected void stopAtTime()
This method is usually only called (indirectly) by the StopTimeMonitor class.
Synchronous method -- return when transition complete
protected void stopInRestart()
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
protected boolean stopController()
Synchronous method -- return when transition complete
public final void close()
close
in interface Controller
public void addControl(Control newControl)
newControl
- The Control to add.public void removeControl(Control oldControl)
oldControl
- The Control to remove.public Control[] getControls()
getControls
in interface Controller
public Control getControl(java.lang.String forName)
getControl
in interface Controller
public void addControllerListener(ControllerListener listener)
addControllerListener
in interface Controller
listener
- The listener to which the Controller will post
events.public void removeControllerListener(ControllerListener listener)
removeControllerListener
in interface Controller
listener
- The listener that has been receiving events
from this Controller.public int getPreviousState()
protected void setState(int state)
public int getState()
getState
in interface Controller
protected void setTargetState(int state)
public int getTargetState()
getTargetState
in interface Controller
protected void endOfMedia() throws ClockStoppedException
ClockStoppedException
- If the AbstractController is not in the Started
state.protected void postEvent(ControllerEvent event)
event
- The ControllerEvent to post.protected void postTransitionEvent()
protected void postRealizeCompleteEvent()
protected void postPrefetchCompleteEvent()
protected void postDeallocateEvent()
protected void postStopEvent()
protected void postStopAtTimeEvent()
protected void postStartEvent()
protected void postDataStarvedEvent()
protected void postEndOfMediaEvent()
protected void postRestartingEvent()
protected void postStopByRequestEvent()
protected void postControllerClosedEvent()
protected void postControllerErrorEvent(java.lang.String msg)
protected ThreadQueue getThreadQueue()
protected void synchronousRealize()
This method should not be called directly. Instead, call realize().
Synchronous method -- return when transition complete
protected void synchronousPrefetch()
This method should not be called directly. Instead, call prefetch().
Synchronous method -- return when transition complete
public Time getStartLatency()
getStartLatency
in interface Controller
protected void synchronousSyncStart(Time t)
This method should not be called directly. Instead, call syncStart().
Synchronous method -- return when transition complete
public void blockUntilStart(Time t)
If the time-base time (t - l) has already passed, return immediately.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |