Store the timestamp of the first packet received in the decode unit

This commit is contained in:
Cameron Gutman 2014-06-19 19:09:00 -07:00
parent 38423a9f37
commit 6c5ec3d2e9
2 changed files with 8 additions and 23 deletions

View File

@ -13,16 +13,16 @@ public class DecodeUnit {
private int type;
private List<ByteBufferDescriptor> bufferList;
private int dataLength;
private int flags;
private int frameNumber;
private long receiveTimestamp;
public DecodeUnit(int type, List<ByteBufferDescriptor> bufferList, int dataLength, int flags, int frameNumber)
public DecodeUnit(int type, List<ByteBufferDescriptor> bufferList, int dataLength, int frameNumber, long receiveTimestamp)
{
this.type = type;
this.bufferList = bufferList;
this.dataLength = dataLength;
this.flags = flags;
this.frameNumber = frameNumber;
this.receiveTimestamp = receiveTimestamp;
}
public int getType()
@ -30,9 +30,9 @@ public class DecodeUnit {
return type;
}
public int getFlags()
public long getReceiveTimestamp()
{
return flags;
return receiveTimestamp;
}
public List<ByteBufferDescriptor> getBufferList()

View File

@ -23,6 +23,7 @@ public class VideoDepacketizer {
private int startFrameNumber = 1;
private boolean waitingForNextSuccessfulFrame;
private boolean gotNextFrameStart;
private long frameStartTime;
// Cached objects
private ByteBufferDescriptor cachedDesc = new ByteBufferDescriptor(null, 0, 0);
@ -47,25 +48,8 @@ public class VideoDepacketizer {
{
// This is the start of a new frame
if (avcFrameDataChain != null && avcFrameDataLength != 0) {
int flags = 0;
ByteBufferDescriptor firstBuffer = avcFrameDataChain.getFirst();
if (NAL.getSpecialSequenceDescriptor(firstBuffer, cachedDesc) && NAL.isAvcFrameStart(cachedDesc)) {
switch (cachedDesc.data[cachedDesc.offset+cachedDesc.length]) {
case 0x67:
case 0x68:
flags |= DecodeUnit.DU_FLAG_CODEC_CONFIG;
break;
case 0x65:
flags |= DecodeUnit.DU_FLAG_SYNC_FRAME;
break;
}
}
// Construct the H264 decode unit
DecodeUnit du = new DecodeUnit(DecodeUnit.TYPE_H264, avcFrameDataChain, avcFrameDataLength, flags, frameNumber);
DecodeUnit du = new DecodeUnit(DecodeUnit.TYPE_H264, avcFrameDataChain, avcFrameDataLength, frameNumber, frameStartTime);
if (!decodedUnits.offer(du)) {
LimeLog.warning("Video decoder is too slow! Forced to drop decode units");
@ -173,6 +157,7 @@ public class VideoDepacketizer {
{
if (firstPacket) {
// Setup state for the new frame
frameStartTime = System.currentTimeMillis();
avcFrameDataChain = new LinkedList<ByteBufferDescriptor>();
avcFrameDataLength = 0;
}