From c162c0348d6be2778a81d35746ab455ed6fcefd6 Mon Sep 17 00:00:00 2001 From: Michal Hajek Date: Fri, 14 Jul 2023 14:00:31 +0200 Subject: [PATCH 1/2] Fix SRTPCheck testing on an unlimited number of calls #642 --- src/rtpstream.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rtpstream.cpp b/src/rtpstream.cpp index bf4ea3fe..5479aa94 100644 --- a/src/rtpstream.cpp +++ b/src/rtpstream.cpp @@ -2623,6 +2623,7 @@ void rtpstream_audioecho_thread(void* param) unsigned int host_ssrc = 0; bool abnormal_termination = false; ParamPass p; + quit_audioecho_thread = false; // inicialization tspec.tv_sec = 0; tspec.tv_nsec = 10000000; /* 10ms */ @@ -2712,6 +2713,7 @@ void rtpstream_audioecho_thread(void* param) payload_data.clear(); // DECRYPT + g_rxUASAudio.setSSRC(ntohl(((rtp_header_t*)audio_packet_in.data())->ssrc_id)); // set incoming SSRC id rc = g_rxUASAudio.processIncomingPacket(seq_num, audio_packet_in, rtp_header, payload_data); pthread_mutex_lock(&debugremutexaudio); if (debugrefileaudio != NULL) @@ -2754,6 +2756,7 @@ void rtpstream_audioecho_thread(void* param) memcpy(payload_data.data(), msg.get() + sizeof(rtp_header_t), g_txUASAudio.getSrtpPayloadSize()); // ENCRYPT + g_txUASAudio.setSSRC(ntohl(((rtp_header_t*)audio_packet_in.data())->ssrc_id)); // set incoming SSRC id rc = g_txUASAudio.processOutgoingPacket(seq_num, rtp_header, payload_data, audio_packet_out); pthread_mutex_lock(&debugremutexaudio); if (debugrefileaudio != NULL) @@ -2882,6 +2885,7 @@ void rtpstream_videoecho_thread(void* param) unsigned int host_ssrc = 0; bool abnormal_termination = false; ParamPass p; + quit_audioecho_thread = false; // inicialization tspec.tv_sec = 0; tspec.tv_nsec = 10000000; /* 10ms */ @@ -2970,6 +2974,7 @@ void rtpstream_videoecho_thread(void* param) rtp_header.clear(); payload_data.clear(); // DECRYPT + g_rxUASVideo.setSSRC(ntohl(((rtp_header_t*)video_packet_in.data())->ssrc_id)); // set incoming SSRC id rc = g_rxUASVideo.processIncomingPacket(seq_num, video_packet_in, rtp_header, payload_data); pthread_mutex_lock(&debugremutexvideo); if (debugrefilevideo != NULL) @@ -3012,6 +3017,7 @@ void rtpstream_videoecho_thread(void* param) memcpy(payload_data.data(), msg.get() + sizeof(rtp_header_t), g_txUASVideo.getSrtpPayloadSize()); // ENCRYPT + g_txUASVideo.setSSRC(ntohl(((rtp_header_t*)video_packet_in.data())->ssrc_id)); // set incoming SSRC id rc = g_txUASVideo.processOutgoingPacket(seq_num, rtp_header, payload_data, video_packet_out); pthread_mutex_lock(&debugremutexvideo); if (debugrefilevideo != NULL) From 965a36b3f98669ac65987db9557c9900440ead7e Mon Sep 17 00:00:00 2001 From: Michal Hajek Date: Fri, 14 Jul 2023 17:04:02 +0200 Subject: [PATCH 2/2] Reset file handler after fclose. Maybe run repeatedly --- src/rtpstream.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rtpstream.cpp b/src/rtpstream.cpp index 5479aa94..cbd82415 100644 --- a/src/rtpstream.cpp +++ b/src/rtpstream.cpp @@ -3282,6 +3282,7 @@ int rtpstream_rtpecho_stopaudio(rtpstream_callinfo_t* callinfo) if (debugrefileaudio) { fclose(debugrefileaudio); + debugrefileaudio = NULL; } } pthread_mutex_unlock(&debugremutexaudio); @@ -3454,6 +3455,8 @@ int rtpstream_rtpecho_stopvideo(rtpstream_callinfo_t* callinfo) if (debugrefilevideo) { fclose(debugrefilevideo); + debugrefilevideo = NULL; + } } pthread_mutex_unlock(&debugremutexvideo); @@ -3541,12 +3544,14 @@ int rtpstream_shutdown(std::unordered_map& threadIDs) rtpcheck_debug) { fclose(debugvfile); + debugvfile = NULL; } if (debugafile && rtpcheck_debug) { fclose(debugafile); + debugafile = NULL; } pthread_mutex_destroy(&debugamutex);