mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-04-16 13:20:48 +00:00
Terminate the connection if video isn't received for 10 seconds
This commit is contained in:
@@ -75,6 +75,7 @@ static void ReceiveThreadProc(void* context) {
|
||||
char* buffer;
|
||||
int queueStatus;
|
||||
int useSelect;
|
||||
int waitingForVideoMs;
|
||||
|
||||
receiveSize = StreamConfig.packetSize + MAX_RTP_HEADER_SIZE;
|
||||
bufferSize = receiveSize + sizeof(RTPFEC_QUEUE_ENTRY);
|
||||
@@ -89,6 +90,7 @@ static void ReceiveThreadProc(void* context) {
|
||||
useSelect = 0;
|
||||
}
|
||||
|
||||
waitingForVideoMs = 0;
|
||||
while (!PltIsThreadInterrupted(&receiveThread)) {
|
||||
PRTP_PACKET packet;
|
||||
|
||||
@@ -108,6 +110,16 @@ static void ReceiveThreadProc(void* context) {
|
||||
break;
|
||||
}
|
||||
else if (err == 0) {
|
||||
if (!receivedDataFromPeer) {
|
||||
// If we wait many seconds without ever receiving a video packet,
|
||||
// assume something is broken and terminate the connection.
|
||||
waitingForVideoMs += UDP_RECV_POLL_TIMEOUT_MS;
|
||||
if (waitingForVideoMs >= FIRST_FRAME_TIMEOUT_SEC * 1000) {
|
||||
ListenerCallbacks.connectionTerminated(ML_ERROR_NO_VIDEO_TRAFFIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Receive timed out; try again
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user