mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-24 13:41:23 +00:00
Synthesize a PTS for hosts that don't send one
This commit is contained in:
@@ -15,6 +15,7 @@ static bool waitingForRefInvalFrame;
|
|||||||
static unsigned int lastPacketInStream;
|
static unsigned int lastPacketInStream;
|
||||||
static bool decodingFrame;
|
static bool decodingFrame;
|
||||||
static bool strictIdrFrameWait;
|
static bool strictIdrFrameWait;
|
||||||
|
static uint64_t syntheticPtsBase;
|
||||||
static uint64_t firstPacketReceiveTime;
|
static uint64_t firstPacketReceiveTime;
|
||||||
static unsigned int firstPacketPresentationTime;
|
static unsigned int firstPacketPresentationTime;
|
||||||
static bool dropStatePending;
|
static bool dropStatePending;
|
||||||
@@ -62,6 +63,7 @@ void initializeVideoDepacketizer(int pktSize) {
|
|||||||
waitingForRefInvalFrame = false;
|
waitingForRefInvalFrame = false;
|
||||||
lastPacketInStream = UINT32_MAX;
|
lastPacketInStream = UINT32_MAX;
|
||||||
decodingFrame = false;
|
decodingFrame = false;
|
||||||
|
syntheticPtsBase = 0;
|
||||||
firstPacketReceiveTime = 0;
|
firstPacketReceiveTime = 0;
|
||||||
firstPacketPresentationTime = 0;
|
firstPacketPresentationTime = 0;
|
||||||
dropStatePending = false;
|
dropStatePending = false;
|
||||||
@@ -757,8 +759,20 @@ static void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length,
|
|||||||
// We're now decoding a frame
|
// We're now decoding a frame
|
||||||
decodingFrame = true;
|
decodingFrame = true;
|
||||||
firstPacketReceiveTime = receiveTimeMs;
|
firstPacketReceiveTime = receiveTimeMs;
|
||||||
|
|
||||||
|
// Some versions of Sunshine don't send a valid PTS, so we will
|
||||||
|
// synthesize one using the receive time as the time base.
|
||||||
|
if (!syntheticPtsBase) {
|
||||||
|
syntheticPtsBase = receiveTimeMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!presentationTimeMs && frameIndex > 0) {
|
||||||
|
firstPacketPresentationTime = receiveTimeMs - syntheticPtsBase;
|
||||||
|
}
|
||||||
|
else {
|
||||||
firstPacketPresentationTime = presentationTimeMs;
|
firstPacketPresentationTime = presentationTimeMs;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lastPacketInStream = streamPacketIndex;
|
lastPacketInStream = streamPacketIndex;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user