mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-17 22:31:21 +00:00
Add receive time to decode unit
This commit is contained in:
@@ -45,7 +45,7 @@ int performRtspHandshake(void);
|
|||||||
|
|
||||||
void initializeVideoDepacketizer(int pktSize);
|
void initializeVideoDepacketizer(int pktSize);
|
||||||
void destroyVideoDepacketizer(void);
|
void destroyVideoDepacketizer(void);
|
||||||
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length);
|
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, unsigned long long receiveTimeMs);
|
||||||
void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry);
|
void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry);
|
||||||
void stopVideoDepacketizer(void);
|
void stopVideoDepacketizer(void);
|
||||||
void requestDecoderRefresh(void);
|
void requestDecoderRefresh(void);
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ typedef struct _DECODE_UNIT {
|
|||||||
// Frame number
|
// Frame number
|
||||||
int frameNumber;
|
int frameNumber;
|
||||||
|
|
||||||
|
// Receive time of first buffer
|
||||||
|
// NOTE: This will be populated from gettimeofday() if !HAVE_CLOCK_GETTIME and
|
||||||
|
// populated from clock_gettime(CLOCK_MONOTONIC) if HAVE_CLOCK_GETTIME
|
||||||
|
unsigned long long receiveTimeMs;
|
||||||
|
|
||||||
// Length of the entire buffer chain in bytes
|
// Length of the entire buffer chain in bytes
|
||||||
int fullLength;
|
int fullLength;
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ static int queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, int h
|
|||||||
newEntry->packet = packet;
|
newEntry->packet = packet;
|
||||||
newEntry->length = length;
|
newEntry->length = length;
|
||||||
newEntry->isParity = isParity;
|
newEntry->isParity = isParity;
|
||||||
|
newEntry->receiveTimeMs = PltGetMillis();
|
||||||
newEntry->prev = NULL;
|
newEntry->prev = NULL;
|
||||||
newEntry->next = NULL;
|
newEntry->next = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ typedef struct _RTPFEC_QUEUE_ENTRY {
|
|||||||
PRTP_PACKET packet;
|
PRTP_PACKET packet;
|
||||||
int length;
|
int length;
|
||||||
int isParity;
|
int isParity;
|
||||||
|
unsigned long long receiveTimeMs;
|
||||||
|
|
||||||
struct _RTPFEC_QUEUE_ENTRY* next;
|
struct _RTPFEC_QUEUE_ENTRY* next;
|
||||||
struct _RTPFEC_QUEUE_ENTRY* prev;
|
struct _RTPFEC_QUEUE_ENTRY* prev;
|
||||||
|
|||||||
@@ -7,20 +7,18 @@ static PLENTRY nalChainHead;
|
|||||||
static int nalChainDataLength;
|
static int nalChainDataLength;
|
||||||
|
|
||||||
static int nextFrameNumber;
|
static int nextFrameNumber;
|
||||||
static int nextPacketNumber;
|
|
||||||
static int startFrameNumber;
|
static int startFrameNumber;
|
||||||
static int waitingForNextSuccessfulFrame;
|
static int waitingForNextSuccessfulFrame;
|
||||||
static int waitingForIdrFrame;
|
static int waitingForIdrFrame;
|
||||||
static int gotNextFrameStart;
|
|
||||||
static int lastPacketInStream;
|
static int lastPacketInStream;
|
||||||
static int decodingFrame;
|
static int decodingFrame;
|
||||||
static int strictIdrFrameWait;
|
static int strictIdrFrameWait;
|
||||||
|
static unsigned long long firstPacketReceiveTime;
|
||||||
|
|
||||||
#define CONSECUTIVE_DROP_LIMIT 120
|
#define CONSECUTIVE_DROP_LIMIT 120
|
||||||
static int consecutiveFrameDrops;
|
static int consecutiveFrameDrops;
|
||||||
|
|
||||||
static LINKED_BLOCKING_QUEUE decodeUnitQueue;
|
static LINKED_BLOCKING_QUEUE decodeUnitQueue;
|
||||||
static unsigned int nominalPacketDataLength;
|
|
||||||
|
|
||||||
typedef struct _BUFFER_DESC {
|
typedef struct _BUFFER_DESC {
|
||||||
char* data;
|
char* data;
|
||||||
@@ -33,16 +31,14 @@ void initializeVideoDepacketizer(int pktSize) {
|
|||||||
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
|
||||||
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
|
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
|
||||||
}
|
}
|
||||||
nominalPacketDataLength = pktSize - sizeof(NV_VIDEO_PACKET);
|
|
||||||
|
|
||||||
nextFrameNumber = 1;
|
nextFrameNumber = 1;
|
||||||
nextPacketNumber = 0;
|
|
||||||
startFrameNumber = 0;
|
startFrameNumber = 0;
|
||||||
waitingForNextSuccessfulFrame = 0;
|
waitingForNextSuccessfulFrame = 0;
|
||||||
waitingForIdrFrame = 1;
|
waitingForIdrFrame = 1;
|
||||||
gotNextFrameStart = 0;
|
|
||||||
lastPacketInStream = -1;
|
lastPacketInStream = -1;
|
||||||
decodingFrame = 0;
|
decodingFrame = 0;
|
||||||
|
firstPacketReceiveTime = 0;
|
||||||
|
|
||||||
LC_ASSERT(NegotiatedVideoFormat != 0);
|
LC_ASSERT(NegotiatedVideoFormat != 0);
|
||||||
strictIdrFrameWait =
|
strictIdrFrameWait =
|
||||||
@@ -231,6 +227,7 @@ static void reassembleFrame(int frameNumber) {
|
|||||||
qdu->decodeUnit.bufferList = nalChainHead;
|
qdu->decodeUnit.bufferList = nalChainHead;
|
||||||
qdu->decodeUnit.fullLength = nalChainDataLength;
|
qdu->decodeUnit.fullLength = nalChainDataLength;
|
||||||
qdu->decodeUnit.frameNumber = frameNumber;
|
qdu->decodeUnit.frameNumber = frameNumber;
|
||||||
|
qdu->decodeUnit.receiveTimeMs = firstPacketReceiveTime;
|
||||||
|
|
||||||
nalChainHead = NULL;
|
nalChainHead = NULL;
|
||||||
nalChainDataLength = 0;
|
nalChainDataLength = 0;
|
||||||
@@ -401,7 +398,7 @@ static void processRtpPayloadFast(BUFFER_DESC location) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Process an RTP Payload
|
// Process an RTP Payload
|
||||||
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length) {
|
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, unsigned long long receiveTimeMs) {
|
||||||
BUFFER_DESC currentPos;
|
BUFFER_DESC currentPos;
|
||||||
int frameIndex;
|
int frameIndex;
|
||||||
char flags;
|
char flags;
|
||||||
@@ -450,6 +447,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length) {
|
|||||||
|
|
||||||
// We're now decoding a frame
|
// We're now decoding a frame
|
||||||
decodingFrame = 1;
|
decodingFrame = 1;
|
||||||
|
firstPacketReceiveTime = receiveTimeMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This must be the first packet in a frame or be contiguous with the last
|
// This must be the first packet in a frame or be contiguous with the last
|
||||||
@@ -536,5 +534,6 @@ void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processRtpPayload((PNV_VIDEO_PACKET)(((char*)queueEntry->packet) + dataOffset),
|
processRtpPayload((PNV_VIDEO_PACKET)(((char*)queueEntry->packet) + dataOffset),
|
||||||
queueEntry->length - dataOffset);
|
queueEntry->length - dataOffset,
|
||||||
|
queueEntry->receiveTimeMs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user