mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-20 11:33:06 +00:00
Store the timestamp of the first packet received in the decode unit
This commit is contained in:
parent
38423a9f37
commit
6c5ec3d2e9
@ -13,16 +13,16 @@ public class DecodeUnit {
|
|||||||
private int type;
|
private int type;
|
||||||
private List<ByteBufferDescriptor> bufferList;
|
private List<ByteBufferDescriptor> bufferList;
|
||||||
private int dataLength;
|
private int dataLength;
|
||||||
private int flags;
|
|
||||||
private int frameNumber;
|
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.type = type;
|
||||||
this.bufferList = bufferList;
|
this.bufferList = bufferList;
|
||||||
this.dataLength = dataLength;
|
this.dataLength = dataLength;
|
||||||
this.flags = flags;
|
|
||||||
this.frameNumber = frameNumber;
|
this.frameNumber = frameNumber;
|
||||||
|
this.receiveTimestamp = receiveTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType()
|
public int getType()
|
||||||
@ -30,9 +30,9 @@ public class DecodeUnit {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFlags()
|
public long getReceiveTimestamp()
|
||||||
{
|
{
|
||||||
return flags;
|
return receiveTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ByteBufferDescriptor> getBufferList()
|
public List<ByteBufferDescriptor> getBufferList()
|
||||||
|
@ -23,6 +23,7 @@ public class VideoDepacketizer {
|
|||||||
private int startFrameNumber = 1;
|
private int startFrameNumber = 1;
|
||||||
private boolean waitingForNextSuccessfulFrame;
|
private boolean waitingForNextSuccessfulFrame;
|
||||||
private boolean gotNextFrameStart;
|
private boolean gotNextFrameStart;
|
||||||
|
private long frameStartTime;
|
||||||
|
|
||||||
// Cached objects
|
// Cached objects
|
||||||
private ByteBufferDescriptor cachedDesc = new ByteBufferDescriptor(null, 0, 0);
|
private ByteBufferDescriptor cachedDesc = new ByteBufferDescriptor(null, 0, 0);
|
||||||
@ -47,25 +48,8 @@ public class VideoDepacketizer {
|
|||||||
{
|
{
|
||||||
// This is the start of a new frame
|
// This is the start of a new frame
|
||||||
if (avcFrameDataChain != null && avcFrameDataLength != 0) {
|
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
|
// 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)) {
|
if (!decodedUnits.offer(du)) {
|
||||||
LimeLog.warning("Video decoder is too slow! Forced to drop decode units");
|
LimeLog.warning("Video decoder is too slow! Forced to drop decode units");
|
||||||
|
|
||||||
@ -173,6 +157,7 @@ public class VideoDepacketizer {
|
|||||||
{
|
{
|
||||||
if (firstPacket) {
|
if (firstPacket) {
|
||||||
// Setup state for the new frame
|
// Setup state for the new frame
|
||||||
|
frameStartTime = System.currentTimeMillis();
|
||||||
avcFrameDataChain = new LinkedList<ByteBufferDescriptor>();
|
avcFrameDataChain = new LinkedList<ByteBufferDescriptor>();
|
||||||
avcFrameDataLength = 0;
|
avcFrameDataLength = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user