com.flagstone.transform
Class FSVideo

java.lang.Object
  extended by com.flagstone.transform.FSVideo
All Implemented Interfaces:
java.lang.Cloneable

public final class FSVideo
extends java.lang.Object
implements java.lang.Cloneable

FSVideo is a container class for the objects that represents the data structures in a Flash video file. It is very similar to the FSMovie class for flash (.swf) files and provides a simple API for decoding and encoding files and accessing the objects that represent the different data structures used for audio and video data.


Field Summary
static int Frame
          Indicates a frame is a normal frame (one displayed between key frames) in the video stream.
static int H263
          Indicates that the video data was encoded using the Sorenson modified H263 format.
static int KeyFrame
          Indicates a frame is a key frame in the video stream.
static int Optional
          Indicates a frame is an optional frame - one that may be deleted to maintain real-time display of the video stream.
static int ScreenVideo
          Indicates that the video data was encoded using Macromedia's ScreenVideo format.
 
Constructor Summary
FSVideo()
          Constructs an FSVideo object with no objects.
FSVideo(byte[] data)
          Constructs an FSVideo object and decodes the binary data presented in the byte array to generate an array of objects representing the Flash Video data.
FSVideo(java.lang.String fileName)
          Constructs an FSVideo object and decodes the contents of the specified file to generate an array of objects representing the video file.
 
Method Summary
 void add(java.util.ArrayList array)
          Adds the array of object to the Video.
 void add(FSVideoObject anObject)
          Adds the object to the Movie.
 void appendDescription(java.lang.StringBuffer buffer, int depth)
          AppendDescription is used to present a string description of the object including all nested objects up to a specified depth.
 java.lang.Object clone()
          Creates a deep copy of the entire video.
 void decodeFromData(byte[] bytes)
          Decodes the binary Flash Video data stored in the byte array.
 void decodeFromFile(java.lang.String fileName)
          Decodes the contents of the specified file.
 byte[] encode()
          Returns the encoded representation of the array of objects that this Video contains.
 void encodeToFile(java.lang.String fileName)
          Encodes the array of objects and writes the data to the specified file.
 boolean equals(java.lang.Object anObject)
          Returns true if anObject is equal to this one.
 java.util.ArrayList getObjects()
          Gets the array of video objects.
 int getVersion()
          Gets the number representing the version of Flash Video that the video represents.
 void setObjects(java.util.ArrayList anArray)
          Sets the array of objects contained in the Movie.
 void setVersion(int aNumber)
          Sets the Flash Video version.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

H263

public static final int H263
Indicates that the video data was encoded using the Sorenson modified H263 format.

See Also:
Constant Field Values

ScreenVideo

public static final int ScreenVideo
Indicates that the video data was encoded using Macromedia's ScreenVideo format.

See Also:
Constant Field Values

KeyFrame

public static final int KeyFrame
Indicates a frame is a key frame in the video stream.

See Also:
Constant Field Values

Frame

public static final int Frame
Indicates a frame is a normal frame (one displayed between key frames) in the video stream.

See Also:
Constant Field Values

Optional

public static final int Optional
Indicates a frame is an optional frame - one that may be deleted to maintain real-time display of the video stream. Used only with video encoded using the Sorenson modified H263 format.

See Also:
Constant Field Values
Constructor Detail

FSVideo

public FSVideo()
Constructs an FSVideo object with no objects.


FSVideo

public FSVideo(java.lang.String fileName)
        throws java.io.FileNotFoundException,
               java.io.IOException,
               java.util.zip.DataFormatException
Constructs an FSVideo object and decodes the contents of the specified file to generate an array of objects representing the video file. If an error occurs while reading and parsing the file then an exception is thrown.

Parameters:
fileName - the path to the Flash Video file that will be parsed.
Throws:
java.io.FileNotFoundException - - if an error occurs while reading the file.
java.util.zip.DataFormatException - - if the file does not contain Flash data.
java.io.IOException - - if an error occurs while reading and decoding the file.

FSVideo

public FSVideo(byte[] data)
        throws java.io.IOException,
               java.util.zip.DataFormatException
Constructs an FSVideo object and decodes the binary data presented in the byte array to generate an array of objects representing the Flash Video data. If an error occurs while parsing the data then an exception is thrown.

Parameters:
data - an array of bytes containing the Flash Video binary data.
Throws:
java.util.zip.DataFormatException - - if the file does not contain Flash data.
java.io.IOException - - if an error occurs while reading and decoding the data.
Method Detail

getVersion

public int getVersion()
Gets the number representing the version of Flash Video that the video represents.

Returns:
an integer defining the Flash Video version number for the coder.

setVersion

public void setVersion(int aNumber)
Sets the Flash Video version.

Parameters:
aNumber - the version of the Flash Video file format that this object utilises.

getObjects

public java.util.ArrayList getObjects()
Gets the array of video objects.

Returns:
the array of objects.

setObjects

public void setObjects(java.util.ArrayList anArray)
Sets the array of objects contained in the Movie.

Parameters:
anArray - the array of objects that describe a coder.

add

public void add(FSVideoObject anObject)
Adds the object to the Movie.

Parameters:
anObject - the object to be added to the coder.

add

public void add(java.util.ArrayList array)
Adds the array of object to the Video.

Parameters:
array - an array of FSVideoObjects that will be added to the video in the order they are in the array.

decodeFromFile

public void decodeFromFile(java.lang.String fileName)
                    throws java.io.FileNotFoundException,
                           java.util.zip.DataFormatException,
                           java.io.IOException
Decodes the contents of the specified file. An object for each tag decoded from the file is placed in the object array in the order they were read from the file. If an error occurs while reading and parsing the file then an exception is thrown.

Parameters:
fileName - the path to the Flash Video file that will be parsed.
Throws:
java.io.FileNotFoundException - - if an error occurs while reading the file.
java.util.zip.DataFormatException - - if the file does not contain Flash data.
java.io.IOException - - if an error occurs while reading and decoding the file.

decodeFromData

public void decodeFromData(byte[] bytes)
                    throws java.util.zip.DataFormatException,
                           java.io.IOException
Decodes the binary Flash Video data stored in the byte array. If an error occurs while the data is being decoded an exception is thrown.

Parameters:
bytes - an array of bytes that contain the encoded Flash Video objects.
Throws:
java.util.zip.DataFormatException - - if the file does not contain Flash data.
java.io.IOException - - if an error occurs while reading and decoding the file.

encodeToFile

public void encodeToFile(java.lang.String fileName)
                  throws java.io.FileNotFoundException,
                         java.io.IOException
Encodes the array of objects and writes the data to the specified file. If an error occurs while encoding the file then an exception is thrown.

Parameters:
fileName - the path to the file that the video will be encoded to.
Throws:
java.io.FileNotFoundException - - if an error occurs while reading the file.
java.io.IOException - - if an error occurs while encoding and writing the file.

encode

public byte[] encode()
              throws java.io.IOException
Returns the encoded representation of the array of objects that this Video contains. If an error occurs while encoding the file then an exception is thrown.

Returns:
the array of bytes representing the encoded objects.
Throws:
java.io.IOException - if an error occurs while the data is being decoded.

clone

public java.lang.Object clone()
Creates a deep copy of the entire video.

Overrides:
clone in class java.lang.Object
Returns:
a copy of the object.

equals

public boolean equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. The comparison is performed on all the objects contained in the video. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash Video file.

Overrides:
equals in class java.lang.Object
Returns:
true if this object would be identical to anObject when encoded.

appendDescription

public void appendDescription(java.lang.StringBuffer buffer,
                              int depth)
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

Parameters:
buffer - a StringBuffer to which the description of each object is appended.
depth - the maximum level of nesting up to which objects will be displayed.