mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-11-29 01:04:41 +00:00
Add protocol extension for multi-client-compatible ping support
This commit is contained in:
1 parent
5e14dbc15e
commit
dc186082a7
6 files changed
+54
-19
No files matched your search
+15
-6
@@ -43,7 +43,7 @@ void destroyVideoStream(void) {
|
||||
|
||||
// UDP Ping proc
|
||||
static void VideoPingThreadProc(void* context) {
|
||||
char pingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
||||
char legacyPingData[] = { 0x50, 0x49, 0x4E, 0x47 };
|
||||
LC_SOCKADDR saddr;
|
||||
|
||||
LC_ASSERT(VideoPortNumber != 0);
|
||||
@@ -51,12 +51,21 @@ static void VideoPingThreadProc(void* context) {
|
||||
memcpy(&saddr, &RemoteAddr, sizeof(saddr));
|
||||
SET_PORT(&saddr, VideoPortNumber);
|
||||
|
||||
// We do not check for errors here. Socket errors will be handled
|
||||
// on the read-side in ReceiveThreadProc(). This avoids potential
|
||||
// issues related to receiving ICMP port unreachable messages due
|
||||
// to sending a packet prior to the host PC binding to that port.
|
||||
int pingCount = 0;
|
||||
while (!PltIsThreadInterrupted(&udpPingThread)) {
|
||||
// We do not check for errors here. Socket errors will be handled
|
||||
// on the read-side in ReceiveThreadProc(). This avoids potential
|
||||
// issues related to receiving ICMP port unreachable messages due
|
||||
// to sending a packet prior to the host PC binding to that port.
|
||||
sendto(rtpSocket, pingData, sizeof(pingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
||||
if (VideoPingPayload.payload[0] != 0) {
|
||||
pingCount++;
|
||||
VideoPingPayload.sequenceNumber = BE32(pingCount);
|
||||
|
||||
sendto(rtpSocket, (char*)&VideoPingPayload, sizeof(VideoPingPayload), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
||||
}
|
||||
else {
|
||||
sendto(rtpSocket, legacyPingData, sizeof(legacyPingData), 0, (struct sockaddr*)&saddr, RemoteAddrLen);
|
||||
}
|
||||
|
||||
PltSleepMsInterruptible(&udpPingThread, 500);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user