public abstract class MediaController extends Object implements Controller, ControllerListener, Duration, EventListener
| Modifier and Type | Field and Description |
|---|---|
protected Controller |
parent |
protected int |
state |
LATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, UnrealizedDURATION_UNBOUNDED, DURATION_UNKNOWN| Constructor and Description |
|---|
MediaController()
constructs media controller.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
abortPrefetch()
Called when the prefetch() is aborted, i.e.
|
protected abstract void |
abortRealize()
Called when the realize() is aborted, i.e.
|
void |
addControllerListener(ControllerListener listener)
Add a listener to the listenerList.
|
protected void |
cleanup()
stops send and receive threads
|
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 |
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 |
controllerUpdate(ControllerEvent evt)
This get called when some Controller notifies this controller of
any event.
|
void |
deallocate()
Release the resouces held by the controller.
|
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 void |
doDeallocate()
Called by deallocate().
|
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 float |
doSetRate(float factor) |
protected abstract void |
doStart()
Start immediately.
|
protected void |
doStop()
Invoked from stop().
|
Control |
getControl(String forName)
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.
|
protected Time |
getMediaClockTime()
For subclasses to access to the theoretical clock time as computed
by MediaClock.
|
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()
Returns the start latency.
|
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()
Get the current time base.
|
Time |
mapToTimeBase(Time t)
Map the given media-time to time-base-time.
|
void |
prefetch()
Take the necessary steps to prefetch the controller.
|
protected void |
processEvent(ControllerEvent evt)
Process one event from another Controller which we are listening to.
|
void |
realize()
Take the necessary steps to realize the controller.
|
void |
removeControllerListener(ControllerListener listener)
Remove a listener from the list of listeners.
|
protected void |
sendEvent(ControllerEvent evt)
Send an event to the listeners listening to my events.
|
protected void |
setMediaLength(long t)
Set the duration of the media in nanoseconds.
|
void |
setMediaTime(Time now)
Set the media time.
|
float |
setRate(float factor)
Set the rate of presentation: 1.0: normal, 2.0: twice the speed.
|
void |
setStopTime(Time t)
Set the stop time.
|
protected void |
setTargetState(int state)
Set the target state.
|
void |
setTimeBase(TimeBase tb)
Set the timebase used by the controller.
|
void |
stop()
Stop the controller.
|
protected void |
stopAtTime()
Stop because stop time has been reached.
|
void |
syncStart(Time tbt)
Start the controller.
|
protected int state
protected Controller parent
public MediaController()
protected abstract boolean doRealize()
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.
protected abstract void abortRealize()
protected abstract boolean doPrefetch()
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.
protected abstract void abortPrefetch()
protected abstract void doStart()
protected void doStop()
public void close()
close in interface Controllerprotected void doClose()
protected final void cleanup()
public void setTimeBase(TimeBase tb) throws IncompatibleTimeBaseException
setTimeBase in interface Clocktb - the time base to set to.IncompatibleTimeBaseException - is thrown if the Controller
cannot accept the given time base.public Control[] getControls()
getControls in interface Controllerpublic Control getControl(String forName)
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.getControl in interface ControllerControl for the class or interface
name.public void syncStart(Time tbt)
public void stop()
protected void stopAtTime()
public void setStopTime(Time t)
setStopTime in interface Clockt - the time to stop.public Time getStopTime()
getStopTime in interface Clockpublic void setMediaTime(Time now)
setMediaTime in interface Clocknow - the media time to set to.public Time getMediaTime()
getMediaTime in interface Clockpublic long getMediaNanoseconds()
getMediaNanoseconds in interface Clockprotected final Time getMediaClockTime()
public Time getSyncTime()
getSyncTime in interface Clockpublic TimeBase getTimeBase()
getTimeBase in interface Clockpublic Time mapToTimeBase(Time t) throws ClockStoppedException
mapToTimeBase in interface Clockt - given media time.ClockStoppedException - thrown if the Controller has already
been stopped.public float setRate(float factor)
protected float doSetRate(float factor)
public float getRate()
public final int getState()
getState in interface Controllerprotected final void setTargetState(int state)
public final int getTargetState()
getTargetState in interface Controllerpublic Time getStartLatency()
getStartLatency in interface Controllerpublic Time getDuration()
getDuration in interface Durationprotected void setMediaLength(long t)
t - duration in nanoseconds.public final void realize()
realize in interface Controllerprotected void completeRealize()
protected void doFailedRealize()
public final void prefetch()
prefetch in interface Controllerprotected void completePrefetch()
protected void doFailedPrefetch()
public final void deallocate()
deallocate in interface Controllerprotected void doDeallocate()
public final void addControllerListener(ControllerListener listener)
addControllerListener in interface Controllerlistener - controller listener to be added to the list of listenerspublic final void removeControllerListener(ControllerListener listener)
removeControllerListener in interface Controllerlistener - listener to be removed from the list of listenersprotected final void sendEvent(ControllerEvent evt)
evt - event to be sentprotected final void dispatchEvent(ControllerEvent evt)
public final void controllerUpdate(ControllerEvent evt)
controllerUpdate in interface ControllerListenerevt - The event generated.protected void processEvent(ControllerEvent evt)
evt - controller event to be processedCopyright © 2012 code4tv.com. All Rights Reserved.