|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdlife.vision.server.VideoFrame
public class VideoFrame
A VideoFrame constructs is useful in two different ways. The first use is to construct a series of DatagramPacket objects for a image frame stored within a ByteBuffer. The image is broken up into DatagramPackets of size 65535 (the max size which can be sent via UDP). The first 10 bytes of each DatagramPacket will contain header information useful for reconstructing the frame. The first 8 bytes are a long which is the frame number. The next two bytes are the sequence number followed by the total number of DatagramPackets for the VideoFrame. A VideoFrame can also be constructed using these broken up DatagramPackets to create a buffered image. The frame number is assigned when the new VideoFrame is created or by using the frame number from the provided DatagramPacket.
| Field Summary | |
|---|---|
static int |
MAX_PACKET_SIZE
The maximum packet size that will be sent over UDP. |
static int |
PACKET_HEADER_SIZE
The size of the header information on each DatagramPacket. |
| Constructor Summary | |
|---|---|
VideoFrame(ByteBuffer bb)
Construct a VideoFrame using the image information in the given ByteBuffer. |
|
VideoFrame(DatagramPacket dgp)
Construct a VideoFrame with the initial DatagramPacket. |
|
| Method Summary | |
|---|---|
void |
addPacket(DatagramPacket dgp)
Add a DatagramPacket if we do not already have all the DatagramPackets and if the DatagramPacket belongs to the same frame number as this VideoFrame. |
boolean |
frameReady()
Checks if the frame is ready to be constructed. |
DatagramPacket[] |
getDatagrams(InetAddress address,
int port)
Get an array of DatagramPackets with the information in the provided ByteBuffer. |
BufferedImage |
getFrame()
Get the BufferedImage for this video frame if the frame is ready to be constructed. |
long |
getFrameNumber()
Get the frame number for this VideoFrame. |
static long |
getFrameNumber(DatagramPacket dgp)
Get the frame number encoded in the header of a DatagramPacket created by the VideoFrame class. |
static byte |
getSequenceNumber(DatagramPacket dgp)
Get the sequence number encoded in the header of a DatagramPacket created by the VideoFrame class. |
static byte |
getTotalPackets(DatagramPacket dgp)
Get the total number of packets encoded in the header of a DatagramPacket created by the VideoFrame class. |
static void |
resetFrameCount()
Reset the frame count to 0. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_PACKET_SIZE
public static final int PACKET_HEADER_SIZE
| Constructor Detail |
|---|
public VideoFrame(ByteBuffer bb)
bb - the ByteBuffer which contains the image datapublic VideoFrame(DatagramPacket dgp)
dgp - the initial DatagramPacket| Method Detail |
|---|
public long getFrameNumber()
public DatagramPacket[] getDatagrams(InetAddress address,
int port)
address - the address the DatagramPackets will be sent toport - the port the DatagramPackets will be sent to
public void addPacket(DatagramPacket dgp)
dgp - the packet to add to this VideoFrame
InvalidParameterException - thrown if the DatagramPacket belongs to a different frame or
if we already have a DatagramPacket with that sequence numberpublic boolean frameReady()
public BufferedImage getFrame()
throws IOException
IOException - thrown if there is a problem reading the image data from the
DatagramPacketspublic static void resetFrameCount()
public static byte getTotalPackets(DatagramPacket dgp)
dgp - the DatagramPacket to get the total number of packets that
create a full VideoFrame object.
public static byte getSequenceNumber(DatagramPacket dgp)
dgp - the DatagramPacket to get the sequence number
public static long getFrameNumber(DatagramPacket dgp)
dgp - the DatagramPacket to get the frame number
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||