Package ptolemy.actor.lib.jmf
Class MovieWriter
- java.lang.Object
-
- All Implemented Interfaces:
java.lang.Cloneable,javax.media.ControllerListener,javax.media.datasink.DataSinkListener,Actor,Executable,FiringsRecordable,Initializable,TypedActor,Changeable,Debuggable,DebugListener,Derivable,Instantiable,ModelErrorHandler,MoMLExportable,Moveable,Nameable
public class MovieWriter extends Sink implements javax.media.ControllerListener, javax.media.datasink.DataSinkListener
This actor writes a video file (MPEG, AVI, or Quicktime). It receives JMFImageTokens at the input, and queues them up for writing.The file is specified by the fileName attribute using any form acceptable to FileParameter.
If the confirmOverwrite parameter has value false, then this actor will overwrite the specified file if it exists without asking. If true (the default), then if the file exists, then this actor will ask for confirmation before overwriting.
- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- James Yeh
- See Also:
FileParameter- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (cxh)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ptolemy.kernel.Entity
Entity.ContainedObjectsIterator
-
-
Field Summary
Fields Modifier and Type Field Description ParameterconfirmOverwriteIf false, then overwrite the specified file if it exists without asking.FileParameterfileOrURLThe file name or URL from which to read.StringAttributefileTypeThe type of file to write.-
Fields inherited from class ptolemy.actor.TypedAtomicActor
_typesValid
-
Fields inherited from class ptolemy.actor.AtomicActor
_actorFiringListeners, _initializables, _notifyingActorFiring, _stopRequested
-
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _deferChangeRequests, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
-
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
-
-
Constructor Summary
Constructors Constructor Description MovieWriter(CompositeEntity container, java.lang.String name)Construct an actor with the given container and name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean_waitForFileDone()Wait for the file to be written.protected boolean_waitForState(javax.media.Processor processor, int state)Block until the processor has transitioned to the given state.voidattributeChanged(Attribute attribute)An attempt is made to acquire the file name.java.lang.Objectclone(Workspace workspace)Clone the actor into the specified workspace.voidcontrollerUpdate(javax.media.ControllerEvent event)The controller listener.voiddataSinkUpdate(javax.media.datasink.DataSinkEvent event)The data sink listener.voidinitialize()Initialize this actor.booleanpostfire()Fire this actor.voidwrapup()Save the file.-
Methods inherited from class ptolemy.actor.TypedAtomicActor
_containedTypeConstraints, _customTypeConstraints, _defaultTypeConstraints, _fireAt, _fireAt, attributeTypeChanged, clone, isBackwardTypeInferenceEnabled, newPort, typeConstraintList, typeConstraints
-
Methods inherited from class ptolemy.actor.AtomicActor
_actorFiring, _actorFiring, _declareDelayDependency, addActorFiringListener, addInitializable, connectionsChanged, createReceivers, declareDelayDependency, fire, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, isFireFunctional, isStrict, iterate, newReceiver, outputPortList, prefire, preinitialize, pruneDependencies, recordFiring, removeActorFiringListener, removeDependency, removeInitializable, setContainer, stop, stopFire, terminate
-
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
_addPort, _description, _exportMoMLContents, _removePort, _validateSettables, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName
-
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition, isWithinClassDefinition
-
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _containedDecorators, _copyChangeRequestList, _debug, _debug, _debug, _debug, _debug, _executeChangeRequests, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _notifyHierarchyListenersAfterChange, _notifyHierarchyListenersBeforeChange, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, addHierarchyListener, attributeDeleted, attributeList, attributeList, decorators, 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, notifyOfNameChange, propagateValue, propagateValues, removeAttribute, removeChangeListener, removeDebugListener, removeHierarchyListener, 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
-
Methods inherited from interface ptolemy.actor.Actor
createReceivers, getCausalityInterface, getDirector, getExecutiveDirector, getManager, inputPortList, newReceiver, outputPortList
-
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
-
Methods inherited from interface ptolemy.actor.Executable
fire, isFireFunctional, isStrict, iterate, prefire, stop, stopFire, terminate
-
Methods inherited from interface ptolemy.actor.Initializable
addInitializable, preinitialize, removeInitializable
-
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getContainer, getDisplayName, getFullName, getName, getName, setName
-
-
-
-
Field Detail
-
confirmOverwrite
public Parameter confirmOverwrite
If false, then overwrite the specified file if it exists without asking. If true (the default), then if the file exists, ask for confirmation before overwriting.
-
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 initial default value is the string "$TMPDIR/movieOut.mov";- See Also:
FileParameter
-
fileType
public StringAttribute fileType
The type of file to write. There are three different file types that this actor can write. They are AVI, MPEG, and QUICKTIME.
-
-
Constructor Detail
-
MovieWriter
public MovieWriter(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.
-
-
Method Detail
-
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:
attributeChangedin classNamedObj- Parameters:
attribute- The attribute that changed.- Throws:
IllegalActionException- If the URL is null, or invalid.
-
clone
public java.lang.Object clone(Workspace workspace) throws java.lang.CloneNotSupportedException
Clone the actor into the specified workspace.- Overrides:
clonein classTypedAtomicActor- Parameters:
workspace- The workspace for the new attribute- Returns:
- A new director.
- Throws:
java.lang.CloneNotSupportedException- If a derived class contains an attribute that cannot be cloned.- See Also:
NamedObj.exportMoML(Writer, int, String),NamedObj.setDeferringChangeRequests(boolean)
-
controllerUpdate
public void controllerUpdate(javax.media.ControllerEvent event)
The controller listener. This method controls the initializing of the processor.- Specified by:
controllerUpdatein interfacejavax.media.ControllerListener- Parameters:
event- The controller event.
-
dataSinkUpdate
public void dataSinkUpdate(javax.media.datasink.DataSinkEvent event)
The data sink listener. This method controls the closing of the data sink. It closes the data sink when it detects that the stream has ended.- Specified by:
dataSinkUpdatein interfacejavax.media.datasink.DataSinkListener- Parameters:
event- The controller event.
-
initialize
public void initialize() throws IllegalActionExceptionInitialize this actor. Create a new ArrayList to store the Buffers that the incoming JMFImageTokens contain.- Specified by:
initializein interfaceInitializable- Overrides:
initializein classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If a contained method throws it.
-
postfire
public boolean postfire() throws IllegalActionExceptionFire this actor. Accept JMFImageTokens, and queue them up for saving.- Specified by:
postfirein interfaceExecutable- Overrides:
postfirein classAtomicActor<TypedIOPort>- Returns:
- true
- Throws:
IllegalActionException- If a contained method throws it, or if the buffer of the incoming JMFImageToken cannot be added to the queue.
-
wrapup
public void wrapup() throws IllegalActionExceptionSave the file.- Specified by:
wrapupin interfaceInitializable- Overrides:
wrapupin classAtomicActor<TypedIOPort>- Throws:
IllegalActionException- If a contained method throws it.
-
_waitForFileDone
protected boolean _waitForFileDone() throws IllegalActionExceptionWait for the file to be written.- Returns:
- true if the file was successfully written.
- Throws:
IllegalActionException- If there is a problem blocking the processor until the state transition is completed.
-
_waitForState
protected boolean _waitForState(javax.media.Processor processor, int state) throws IllegalActionExceptionBlock until the processor has transitioned to the given state.- Parameters:
processor- The processor .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.
-
-