Terminate the connection if video isn't received for 10 seconds

This commit is contained in:
Cameron Gutman
2020-05-01 19:25:24 -07:00
parent 413ea9bc8e
commit b46e06fcf1
3 changed files with 24 additions and 1 deletions

View File

@@ -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;
}