safehome.device.netcamera
Class CameraPacket

java.lang.Object
  extended by safehome.device.netcamera.CameraPacket
All Implemented Interfaces:
Serializable

public class CameraPacket
extends Object
implements Serializable

This class represents a network camera packet.

Network camera packets are used for communication between network cameras and a camera viewer. A camera packet consists of a control signal and a camera image. A control signal is pre-defined integer constant. A camera image is a byte array of BufferedImage in DeviceCamera. A camera packet instance is converted to byte array before socket communication.

Author:
yhkim
See Also:
Serialized Form

Field Summary
static int CONTROL_PAN_LEFT
           
static int CONTROL_PAN_RIGHT
           
static int CONTROL_SEND_IMAGE
           
static int CONTROL_ZOOM_IN
           
static int CONTROL_ZOOM_OUT
           
 
Constructor Summary
CameraPacket(int type)
          Constructs a camera packet for control transfer
CameraPacket(int type, BufferedImage img)
          Construnts a camera packet for image data transfer with a BufferedImage
CameraPacket(int type, byte[] serializedImage)
          Constructs a camera packet for image data transfer with a serialized image
 
Method Summary
 BufferedImage getBufferedImage()
          Returns an image of this camera packet
 int getType()
          Returns a control signal of this instances
 byte[] toBytes()
          Converts a camera packet instance to a serialized camera packet.
static CameraPacket toPacket(byte[] data)
          Converts a serialized camera packet to a camera packet instnace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTROL_SEND_IMAGE

public static final int CONTROL_SEND_IMAGE
See Also:
Constant Field Values

CONTROL_PAN_LEFT

public static final int CONTROL_PAN_LEFT
See Also:
Constant Field Values

CONTROL_PAN_RIGHT

public static final int CONTROL_PAN_RIGHT
See Also:
Constant Field Values

CONTROL_ZOOM_IN

public static final int CONTROL_ZOOM_IN
See Also:
Constant Field Values

CONTROL_ZOOM_OUT

public static final int CONTROL_ZOOM_OUT
See Also:
Constant Field Values
Constructor Detail

CameraPacket

public CameraPacket(int type)
Constructs a camera packet for control transfer

Parameters:
type - Control signal

CameraPacket

public CameraPacket(int type,
                    byte[] serializedImage)
Constructs a camera packet for image data transfer with a serialized image

Parameters:
type - Control signal
serializedImage - Serialized BufferedImage instance

CameraPacket

public CameraPacket(int type,
                    BufferedImage img)
Construnts a camera packet for image data transfer with a BufferedImage

Parameters:
type - Control sianel
img - BufferedImage instance to be serialized
Method Detail

getType

public int getType()
Returns a control signal of this instances

Returns:
Control signal of this instances

getBufferedImage

public BufferedImage getBufferedImage()
Returns an image of this camera packet

Returns:
BufferedImage instance of this camera packet

toBytes

public byte[] toBytes()
Converts a camera packet instance to a serialized camera packet. Serialized camera packets are byte arrays

Returns:
Serialized camera packet in the form of byte array

toPacket

public static CameraPacket toPacket(byte[] data)
Converts a serialized camera packet to a camera packet instnace

Parameters:
data - Serialized camera packet
Returns:
CameraPacket instance