RTPDePacketizerpublic class RTPDePacketizer extends Object This codec is a JPEG RTP depacketizer. It receives individual RTP
buffers with a JPEG_RTP format. These buffers will be used to
reconstruct a complete frame in the JPEG format. Once a frame is
constructed, it is sent over to the next node i.e. a node capable of
handling the JPEG format. |
Fields Summary |
---|
private JPEGFrame | currentFrame | protected byte[] | frameBuffer | protected int | sequenceNumber | protected int | quality | protected int | type | byte[] | lastJFIFHeader | int | lastQuality | int | lastType | int | lastWidth | int | lastHeight |
Methods Summary |
---|
public int | getFragOffset(byte[] data, int doff)
// Fragment offset is the 2nd, 3rd & 4th byte of the JPEG Hdr.
int foff = 0;
foff |= (data[doff + 1] & 0xff) << 16;
foff |= (data[doff + 2] & 0xff) << 8;
foff |= (data[doff + 3] & 0xff);
return foff;
| public int | getQuality()
return quality;
| public int | getType()
return type;
| public int | process(javax.media.Buffer inBuffer, javax.media.Buffer outBuffer)This method will reconstruct a JPEG frame from individual RTP
packets. The reconstruction process waits till all the packtes of
a frame are received and send this over to the decoder only if
all the frames were received. If a the first packet of a frame is
not received, all other packets belonging to this frame are
discarded.
// If we've been decoding a frame and packets from another
// frame has arrived, then we are missing the a few packets
// for the current frame. We'll discard the current frame.
if (currentFrame != null &&
inBuffer.getTimeStamp() != currentFrame.rtptimestamp) {
currentFrame = null;
}
// Check if this is the first packet from a new frame.
// The first packet has a framgment offset of 0.
if (getFragOffset((byte[])inBuffer.getData(), inBuffer.getOffset()) == 0) {
currentFrame = new JPEGFrame(this, inBuffer, (byte[])outBuffer.getData());
} else if (currentFrame != null) {
// This is a new packet for the current frame.
currentFrame.add(inBuffer, 0);
} else {
// If we don't have a current frame, then we are missing the
// first packet for this frame. We'll discard the current packet.
return PlugIn.OUTPUT_BUFFER_NOT_FILLED;
}
// If this is the last packet from this frame, we'll need to
// check if all the packets from this frame has been received.
if ((inBuffer.getFlags() & Buffer.FLAG_RTP_MARKER) !=0) {
if (currentFrame.gotAllPackets(inBuffer.getSequenceNumber())) {
currentFrame.completeTransfer(inBuffer, outBuffer);
currentFrame = null;
return PlugIn.BUFFER_PROCESSED_OK;
} else {
currentFrame = null;
return PlugIn.OUTPUT_BUFFER_NOT_FILLED;
}
}
return PlugIn.OUTPUT_BUFFER_NOT_FILLED;
|
|