From 6c5ec3d2e92004f00e16fe84a4a127bf0a7d3164 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 19 Jun 2014 19:09:00 -0700 Subject: [PATCH] Store the timestamp of the first packet received in the decode unit --- .../com/limelight/nvstream/av/DecodeUnit.java | 10 ++++----- .../nvstream/av/video/VideoDepacketizer.java | 21 +++---------------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java b/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java index b09ffbf5..3de796ca 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java +++ b/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java @@ -13,16 +13,16 @@ public class DecodeUnit { private int type; private List bufferList; private int dataLength; - private int flags; private int frameNumber; + private long receiveTimestamp; - public DecodeUnit(int type, List bufferList, int dataLength, int flags, int frameNumber) + public DecodeUnit(int type, List 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 getBufferList() diff --git a/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java b/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java index 647afe9a..9cf2ee0d 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java +++ b/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java @@ -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(); avcFrameDataLength = 0; }