Commit efe5f9e2 authored by Ghislain MARY's avatar Ghislain MARY

Fix crash with rework of payload type change handling.

parent d3e68666
......@@ -103,15 +103,15 @@ static void on_dtmf_received(RtpSession *s, unsigned long dtmf, void * user_data
* more easily within the MSTicker API.
* return TRUE if the decoder was changed, FALSE otherwise.
*/
static bool_t audio_stream_payload_type_changed(AudioStream *stream, int payload) {
RtpSession *session = stream->ms.sessions.rtp_session;
static bool_t audio_stream_payload_type_changed(RtpSession *session, unsigned long data) {
AudioStream *stream = (AudioStream *)data;
RtpProfile *prof = rtp_session_get_profile(session);
int payload = rtp_session_get_recv_payload_type(stream->ms.sessions.rtp_session);
PayloadType *pt = rtp_profile_get_payload(prof, payload);
int payload_type = rtp_session_get_recv_payload_type(stream->ms.sessions.rtp_session);
int cn_pt = rtp_profile_find_payload_number(stream->ms.sessions.rtp_session->snd.profile, "CN", 8000, 1);
/* if new payload type is Comfort Noise(CN), just do nothing */
if (payload_type == cn_pt) {
if (payload == cn_pt) {
ms_message("Ignore paylaod type change to CN");
return FALSE;
}
......@@ -710,7 +710,7 @@ int audio_stream_start_full(AudioStream *stream, RtpProfile *profile, const char
else
stream->dtmfgen=NULL;
rtp_session_signal_connect(rtps,"telephone-event",(RtpCallback)on_dtmf_received,stream);
rtp_session_signal_connect(rtps,"payload_type_changed",(RtpCallback)audio_stream_payload_type_changed,&stream->ms);
rtp_session_signal_connect(rtps,"payload_type_changed",(RtpCallback)audio_stream_payload_type_changed,stream);
if (stream->ms.state==MSStreamPreparing){
/*we were using the dummy preload graph, destroy it but keep sound filters unless no soundcard is given*/
......
......@@ -338,6 +338,7 @@ static void codec_change_for_audio_stream(void) {
RtpProfile *profile = rtp_profile_new("default profile");
char* hello_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_file_root(), HELLO_8K_1S_FILE);
char* recorded_file = ms_strdup_printf("%s/%s", mediastreamer2_tester_get_writable_dir(), RECORDED_8K_1S_FILE);
uint64_t marielle_rtp_sent = 0;
int dummy=0;
reset_stats(&marielle_stats);
......@@ -364,10 +365,12 @@ static void codec_change_for_audio_stream(void) {
/* No packet loss is assumed */
CU_ASSERT_EQUAL(marielle_stats.rtp.sent, margaux_stats.rtp.recv);
marielle_rtp_sent = marielle_stats.rtp.sent;
audio_stream_stop(marielle);
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT);
CU_ASSERT_EQUAL(audio_stream_start_full(marielle, profile, MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_IP, MARGAUX_RTCP_PORT,
8, 50, hello_file, NULL, NULL, NULL, 0), 0);
......@@ -382,7 +385,7 @@ static void codec_change_for_audio_stream(void) {
audio_stream_get_local_rtp_stats(margaux, &margaux_stats.rtp);
/* No packet loss is assumed */
CU_ASSERT_EQUAL(marielle_stats.rtp.sent, margaux_stats.rtp.recv);
CU_ASSERT_EQUAL(marielle_stats.rtp.sent + marielle_rtp_sent, margaux_stats.rtp.recv);
audio_stream_stop(marielle);
audio_stream_stop(margaux);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment