From 4fbe93e62dc429f3913a77fb4f50cae5407d1810 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 26 Feb 2014 01:00:17 -0500 Subject: [PATCH] Set flags on the decode units that indicate what type of data the frame contains --- .../com/limelight/nvstream/av/DecodeUnit.java | 3 +++ .../nvstream/av/video/VideoDepacketizer.java | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java b/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java index 369de8da..b09ffbf5 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java +++ b/moonlight-common/src/com/limelight/nvstream/av/DecodeUnit.java @@ -7,6 +7,9 @@ public class DecodeUnit { public static final int TYPE_H264 = 1; public static final int TYPE_OPUS = 2; + public static final int DU_FLAG_CODEC_CONFIG = 0x1; + public static final int DU_FLAG_SYNC_FRAME = 0x2; + private int type; private List bufferList; private int dataLength; 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 7a8a867a..c1ef5dd4 100644 --- a/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java +++ b/moonlight-common/src/com/limelight/nvstream/av/video/VideoDepacketizer.java @@ -46,8 +46,25 @@ 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, 0, frameNumber); + DecodeUnit du = new DecodeUnit(DecodeUnit.TYPE_H264, avcFrameDataChain, avcFrameDataLength, flags, frameNumber); if (directSubmitDr != null) { // Submit directly to the decoder directSubmitDr.submitDecodeUnit(du);