com.flagstone.transform.video
Class ScreenPacket

java.lang.Object
  extended by com.flagstone.transform.video.ScreenPacket
All Implemented Interfaces:
Copyable<ScreenPacket>

public final class ScreenPacket
extends Object
implements Copyable<ScreenPacket>

The ScreenVideoPacket class is used to encode or decode a frame of video data using Macromedia's ScreenVideo format.


Constructor Summary
ScreenPacket()
          Create a ScreenPacket with no image blocks.
ScreenPacket(boolean key, int imgWidth, int imgHeight, int blkWidth, int blkHeight, List<ImageBlock> blocks)
          Creates a ScreenVideoPacket.
ScreenPacket(byte[] data)
          Decode a screen packet from a block of data.
ScreenPacket(ScreenPacket object)
          Creates and initialises a ScreenPacket object using the values copied from another ScreenPacket object.
 
Method Summary
 ScreenPacket add(ImageBlock block)
          Add an image block to the array that make up the frame.
 ScreenPacket copy()
          Creates a complete copy of this object.
 byte[] encode()
          Encode this ScreenPacket.
 int getBlockHeight()
          Get the height of the blocks in pixels.
 int getBlockWidth()
          Get the width of the blocks in pixels.
 List<ImageBlock> getImageBlocks()
          Get the image blocks that have changed in this frame.
 int getImageHeight()
          Get the height of the frame in pixels.
 int getImageWidth()
          Get the width of the frame in pixels.
 boolean isKeyFrame()
          Does the packet contains a key frame.
 void setBlockHeight(int height)
          Sets the height of the image blocks.
 void setBlockWidth(int width)
          Sets the width of the image blocks.
 void setImageBlocks(List<ImageBlock> blocks)
          Set the image blocks that have changed in this frame.
 void setImageHeight(int height)
          Set the height of the frame in pixels.
 void setImageWidth(int width)
          Sets the width of the frame.
 void setKeyFrame(boolean key)
          Sets whether the frame is a key frame (true) or normal one (false).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenPacket

public ScreenPacket(byte[] data)
             throws IOException
Decode a screen packet from a block of data.

Parameters:
data - the encoded screen packet data.
Throws:
IOException - if the data cannot be decoded.

ScreenPacket

public ScreenPacket()
Create a ScreenPacket with no image blocks.


ScreenPacket

public ScreenPacket(boolean key,
                    int imgWidth,
                    int imgHeight,
                    int blkWidth,
                    int blkHeight,
                    List<ImageBlock> blocks)
Creates a ScreenVideoPacket.

Parameters:
key - indicates whether the packet contains a key frame.
imgWidth - the width of the frame.
imgHeight - the height of the frame.
blkWidth - the width of the blocks that make up the frame.
blkHeight - the height of the blocks that make up the frame.
blocks - the array of ImageBlocks that make up the frame.

ScreenPacket

public ScreenPacket(ScreenPacket object)
Creates and initialises a ScreenPacket object using the values copied from another ScreenPacket object.

Parameters:
object - a ScreenPacket object from which the values will be copied.
Method Detail

add

public ScreenPacket add(ImageBlock block)
Add an image block to the array that make up the frame.

Parameters:
block - an ImageBlock. Must not be null.
Returns:
this object.

isKeyFrame

public boolean isKeyFrame()
Does the packet contains a key frame.

Returns:
true if the packet is a key frame.

setKeyFrame

public void setKeyFrame(boolean key)
Sets whether the frame is a key frame (true) or normal one (false).

Parameters:
key - a boolean value indicating whether the frame is key (true) or normal (false.

getImageWidth

public int getImageWidth()
Get the width of the frame in pixels.

Returns:
the frame width.

setImageWidth

public void setImageWidth(int width)
Sets the width of the frame.

Parameters:
width - the width of the frame in pixels.

getImageHeight

public int getImageHeight()
Get the height of the frame in pixels.

Returns:
the image height.

setImageHeight

public void setImageHeight(int height)
Set the height of the frame in pixels.

Parameters:
height - the image height.

getBlockWidth

public int getBlockWidth()
Get the width of the blocks in pixels.

Returns:
the block width.

setBlockWidth

public void setBlockWidth(int width)
Sets the width of the image blocks.

Parameters:
width - the width of the blocks in pixels.

getBlockHeight

public int getBlockHeight()
Get the height of the blocks in pixels.

Returns:
the block width.

setBlockHeight

public void setBlockHeight(int height)
Sets the height of the image blocks.

Parameters:
height - the height of the blocks in pixels.

getImageBlocks

public List<ImageBlock> getImageBlocks()
Get the image blocks that have changed in this frame.

Returns:
the list of image blocks that make up the frame.

setImageBlocks

public void setImageBlocks(List<ImageBlock> blocks)
Set the image blocks that have changed in this frame. If this is a key frame then all image blocks are displayed.

Parameters:
blocks - the array of image blocks. Must not be null.

copy

public ScreenPacket copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<ScreenPacket>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

encode

public byte[] encode()
              throws IOException
Encode this ScreenPacket.

Returns:
the data representing the encoded image blocks.
Throws:
IOException - if there is an error encoding the blocks.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.