mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-17 14:21:30 +00:00
Fetch receive time only once per frame instead of once per packet
This commit is contained in:
+8
-1
@@ -44,7 +44,6 @@ 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;
|
||||||
|
|
||||||
@@ -266,6 +265,13 @@ static void submitCompletedFrame(PRTP_FEC_QUEUE queue) {
|
|||||||
removeEntry(queue, entry);
|
removeEntry(queue, entry);
|
||||||
entry->prev = entry->next = NULL;
|
entry->prev = entry->next = NULL;
|
||||||
|
|
||||||
|
// To avoid having to sample the system time for each packet, we cheat
|
||||||
|
// and use the first packet's receive time for all packets. This ends up
|
||||||
|
// actually being better for the measurements that the depacketizer does,
|
||||||
|
// since it properly handles out of order packets.
|
||||||
|
LC_ASSERT(queue->bufferFirstRecvTimeMs != 0);
|
||||||
|
entry->receiveTimeMs = queue->bufferFirstRecvTimeMs;
|
||||||
|
|
||||||
// Submit this packet for decoding. It will own freeing the entry now.
|
// Submit this packet for decoding. It will own freeing the entry now.
|
||||||
queueRtpPacket(entry);
|
queueRtpPacket(entry);
|
||||||
break;
|
break;
|
||||||
@@ -331,6 +337,7 @@ int RtpfAddPacket(PRTP_FEC_QUEUE queue, PRTP_PACKET packet, int length, PRTPFEC_
|
|||||||
queue->bufferTail = NULL;
|
queue->bufferTail = NULL;
|
||||||
queue->bufferSize = 0;
|
queue->bufferSize = 0;
|
||||||
|
|
||||||
|
queue->bufferFirstRecvTimeMs = PltGetMillis();
|
||||||
queue->bufferLowestSequenceNumber = U16(packet->sequenceNumber - fecIndex);
|
queue->bufferLowestSequenceNumber = U16(packet->sequenceNumber - fecIndex);
|
||||||
queue->nextContiguousSequenceNumber = queue->bufferLowestSequenceNumber;
|
queue->nextContiguousSequenceNumber = queue->bufferLowestSequenceNumber;
|
||||||
queue->receivedBufferDataPackets = 0;
|
queue->receivedBufferDataPackets = 0;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ typedef struct _RTPFEC_QUEUE_ENTRY {
|
|||||||
typedef struct _RTP_FEC_QUEUE {
|
typedef struct _RTP_FEC_QUEUE {
|
||||||
PRTPFEC_QUEUE_ENTRY bufferHead;
|
PRTPFEC_QUEUE_ENTRY bufferHead;
|
||||||
PRTPFEC_QUEUE_ENTRY bufferTail;
|
PRTPFEC_QUEUE_ENTRY bufferTail;
|
||||||
|
unsigned long long bufferFirstRecvTimeMs;
|
||||||
int bufferSize;
|
int bufferSize;
|
||||||
int bufferLowestSequenceNumber;
|
int bufferLowestSequenceNumber;
|
||||||
int bufferHighestSequenceNumber;
|
int bufferHighestSequenceNumber;
|
||||||
|
|||||||
@@ -669,6 +669,9 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, unsigned long l
|
|||||||
void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry) {
|
void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry) {
|
||||||
int dataOffset;
|
int dataOffset;
|
||||||
|
|
||||||
|
LC_ASSERT(!queueEntry->isParity);
|
||||||
|
LC_ASSERT(queueEntry->receiveTimeMs != 0);
|
||||||
|
|
||||||
dataOffset = sizeof(*queueEntry->packet);
|
dataOffset = sizeof(*queueEntry->packet);
|
||||||
if (queueEntry->packet->header & FLAG_EXTENSION) {
|
if (queueEntry->packet->header & FLAG_EXTENSION) {
|
||||||
dataOffset += 4; // 2 additional fields
|
dataOffset += 4; // 2 additional fields
|
||||||
|
|||||||
Reference in New Issue
Block a user