ptolemy.actor.lib.jmf
Class MovieReader
java.lang.Object
ptolemy.kernel.util.NamedObj
ptolemy.kernel.InstantiableNamedObj
ptolemy.kernel.Entity
ptolemy.kernel.ComponentEntity
ptolemy.actor.AtomicActor
ptolemy.actor.TypedAtomicActor
ptolemy.actor.lib.Source
ptolemy.actor.lib.jmf.MovieReader
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, javax.media.ControllerListener, Actor, Executable, FiringsRecordable, Initializable, TypedActor, Changeable, Debuggable, DebugListener, Derivable, Instantiable, ModelErrorHandler, MoMLExportable, Moveable, Nameable
public class MovieReader
- extends Source
- implements javax.media.ControllerListener
This actor loads a video file (MPEG, AVI, or Quicktime files only), and
outputs each frame as a JMFImageToken.
Note that not all formats are supported, for details, see the JMF faq at:
http://java.sun.com/products/java-media/jmf/reference/faqs/index.html
- Since:
- Ptolemy II 4.0
- Version:
- $Id: MovieReader.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- James Yeh
- See Also:
- Serialized Form
- Accepted Rating:
- Proposed Rating:
Fields inherited from class ptolemy.kernel.util.NamedObj |
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS |
Constructor Summary |
MovieReader(CompositeEntity container,
java.lang.String name)
Construct an actor with the given container and name. |
Method Summary |
private java.lang.String |
_controlNames()
|
protected boolean |
_waitForState(int state)
Block until the processor has transitioned to the given state. |
void |
attributeChanged(Attribute attribute)
An attempt is made to acquire the file name. |
void |
controllerUpdate(javax.media.ControllerEvent event)
The controller listener. |
void |
fire()
Send a JMFImageToken out through the output port. |
void |
initialize()
An attempt is made to acquire both the frame grabbing and
frame positioning controls. |
boolean |
postfire()
If the player is no longer open, then disconnect the
datasource. |
Methods inherited from class ptolemy.actor.AtomicActor |
_actorFiring, _actorFiring, addActorFiringListener, addInitializable, clone, connectionsChanged, createReceivers, declareDelayDependency, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate, wrapup |
Methods inherited from class ptolemy.kernel.ComponentEntity |
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, setName |
Methods inherited from class ptolemy.kernel.Entity |
_description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName |
Methods inherited from class ptolemy.kernel.util.NamedObj |
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttributes, getChangeListeners, getClassName, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setPersistent, setSource, sortContainedObjects, toplevel, toString, validateSettables, workspace |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
fileOrURL
public FileParameter fileOrURL
- The file name or URL from which to read. This is a string with
any form accepted by File Attribute. The default value
is the string "file:///C:/program%20files/quicktime/Sample.mov".
- See Also:
FileParameter
_dataSource
private javax.media.protocol.DataSource _dataSource
_frame
private javax.media.Buffer _frame
_frameGrabbingControl
private javax.media.control.FrameGrabbingControl _frameGrabbingControl
_framePositioningControl
private javax.media.control.FramePositioningControl _framePositioningControl
_player
private javax.media.Player _player
_playerOpen
private boolean _playerOpen
_stateTransitionEvent
private javax.media.ControllerEvent _stateTransitionEvent
_stateTransitionOK
private boolean _stateTransitionOK
_waitSync
private java.lang.Object _waitSync
MovieReader
public MovieReader(CompositeEntity container,
java.lang.String name)
throws IllegalActionException,
NameDuplicationException
- Construct an actor with the given container and name.
- Parameters:
container
- The container.name
- The name of this actor.
- Throws:
IllegalActionException
- If the actor cannot be contained
by the proposed container.
NameDuplicationException
- If the container already has an
actor with this name.
attributeChanged
public void attributeChanged(Attribute attribute)
throws IllegalActionException
- An attempt is made to acquire the file name. If it is
successful, create the DataSource that encapsulates the file.
- Overrides:
attributeChanged
in class NamedObj
- Parameters:
attribute
- The attribute that changed.
- Throws:
IllegalActionException
- If the URL is null, or
invalid.
controllerUpdate
public void controllerUpdate(javax.media.ControllerEvent event)
- The controller listener. This method controls the
initializing of the player. It also senses when the
file is done playing, in which case it closes the
player.
- Specified by:
controllerUpdate
in interface javax.media.ControllerListener
- Parameters:
event
- The controller event.
fire
public void fire()
throws IllegalActionException
- Send a JMFImageToken out through the output port.
- Specified by:
fire
in interface Executable
- Overrides:
fire
in class Source
- Throws:
IllegalActionException
- If there's no director.
initialize
public void initialize()
throws IllegalActionException
- An attempt is made to acquire both the frame grabbing and
frame positioning controls. If both succeed, the first
frame is acquired.
- Specified by:
initialize
in interface Initializable
- Overrides:
initialize
in class AtomicActor
- Throws:
IllegalActionException
- If the either frame
grabbing control or frame positioning control cannot
be acquired, or if a contained method throws it.
postfire
public boolean postfire()
throws IllegalActionException
- If the player is no longer open, then disconnect the
datasource. If the player is still open, acquire the next
frame.
- Specified by:
postfire
in interface Executable
- Overrides:
postfire
in class AtomicActor
- Returns:
- false if the player is no longer open, otherwise
return super.postfire().
- Throws:
IllegalActionException
- If thrown by the super class.
_waitForState
protected boolean _waitForState(int state)
throws IllegalActionException
- Block until the processor has transitioned to the given state.
- Parameters:
state
- The state.
- Returns:
- false if the transition failed.
- Throws:
IllegalActionException
- If there is a problem blocking
the processor until the state transition is completed.
_controlNames
private java.lang.String _controlNames()