Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fclose fix #644

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/rtpstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -3276,6 +3282,7 @@ int rtpstream_rtpecho_stopaudio(rtpstream_callinfo_t* callinfo)
if (debugrefileaudio)
{
fclose(debugrefileaudio);
debugrefileaudio = NULL;
}
}
pthread_mutex_unlock(&debugremutexaudio);
Expand Down Expand Up @@ -3448,6 +3455,8 @@ int rtpstream_rtpecho_stopvideo(rtpstream_callinfo_t* callinfo)
if (debugrefilevideo)
{
fclose(debugrefilevideo);
debugrefilevideo = NULL;

}
}
pthread_mutex_unlock(&debugremutexvideo);
Expand Down Expand Up @@ -3535,12 +3544,14 @@ int rtpstream_shutdown(std::unordered_map<pthread_t, std::string>& threadIDs)
rtpcheck_debug)
{
fclose(debugvfile);
debugvfile = NULL;
}

if (debugafile &&
rtpcheck_debug)
{
fclose(debugafile);
debugafile = NULL;
}

pthread_mutex_destroy(&debugamutex);
Expand Down