]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix cng
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 8 Jan 2013 18:59:02 +0000 (12:59 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 1 Apr 2013 02:27:17 +0000 (21:27 -0500)
src/include/switch_core_media.h
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_media.c
src/switch_rtp.c

index f8c5cf8f2eeb78ce72a6f4d1ff92d6c6490ad83f..5c6162a0911bd3bf2a430e8ce228c02872354cbb 100644 (file)
@@ -142,6 +142,7 @@ typedef struct switch_core_media_params_s {
     int num_codecs;
        int hold_laps;
        switch_core_media_dtmf_t dtmf_type;
+       switch_payload_t cng_pt;
 
 } switch_core_media_params_t;
 
index edda7ccecc5f5250ca64a075db9a315dc0ae8992..66c7904c04d96100f9dec8a7d6ae12a8898f3ca2 100644 (file)
@@ -161,7 +161,7 @@ void sofia_glue_attach_private(switch_core_session_t *session, sofia_profile_t *
        tech_pvt->mparams.rtcp_audio_interval_msec = profile->rtcp_audio_interval_msec;
        tech_pvt->mparams.rtcp_video_interval_msec = profile->rtcp_video_interval_msec;
        tech_pvt->mparams.sdp_username = profile->sdp_username;
-
+       tech_pvt->mparams.cng_pt = tech_pvt->cng_pt;
 
        switch_media_handle_create(&tech_pvt->media_handle, session, &tech_pvt->mparams);
        switch_media_handle_set_media_flags(tech_pvt->media_handle, tech_pvt->profile->media_flags);
index 6fb16745768d677e5985f742dc03e73fe9439f13..d859f282e24ff0892173128da571c67d80b20c31 100644 (file)
@@ -140,7 +140,7 @@ struct switch_media_handle_s {
        int payload_space;
        char *origin;
 
-       switch_payload_t cng_pt;
+
 
        const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
        int num_negotiated_codecs;
@@ -2119,7 +2119,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                                        cng_pt = (switch_payload_t) map->rm_pt;
                                        if (a_engine->rtp_session) {
                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt);
-                                               switch_rtp_set_cng_pt(a_engine->rtp_session, smh->cng_pt);
+                                               switch_rtp_set_cng_pt(a_engine->rtp_session, smh->mparams->cng_pt);
                                        }
                                }
 
@@ -2461,7 +2461,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                sdp_parser_free(parser);
        }
 
-       smh->cng_pt = cng_pt;
+       smh->mparams->cng_pt = cng_pt;
 
        return match;
 }
@@ -3082,8 +3082,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
        }
 
        if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) {
-               smh->cng_pt = 0;
-       } else if (smh->cng_pt) {
+               smh->mparams->cng_pt = 0;
+       } else if (smh->mparams->cng_pt) {
                flags[SWITCH_RTP_FLAG_AUTO_CNG]++;
        }
 
@@ -3423,7 +3423,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
                if (switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) ||
                        ((val = switch_channel_get_variable(session->channel, "supress_cng")) && switch_true(val)) ||
                        ((val = switch_channel_get_variable(session->channel, "suppress_cng")) && switch_true(val))) {
-                       smh->cng_pt = 0;
+                       smh->mparams->cng_pt = 0;
                }
 
                if (((val = switch_channel_get_variable(session->channel, "rtp_digit_delay")))) {
@@ -3440,9 +3440,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_activate_rtp(switch_core_sessi
                        
                }
 
-               if (smh->cng_pt && !switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) {
-                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", smh->cng_pt);
-                       switch_rtp_set_cng_pt(a_engine->rtp_session, smh->cng_pt);
+               if (smh->mparams->cng_pt && !switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG)) {
+                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", smh->mparams->cng_pt);
+                       switch_rtp_set_cng_pt(a_engine->rtp_session, smh->mparams->cng_pt);
                }
 
                switch_core_session_apply_crypto(session, SWITCH_MEDIA_TYPE_AUDIO, "rtp_secure_media_confirmed");
@@ -4018,7 +4018,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                ((val = switch_channel_get_variable(session->channel, "supress_cng")) && switch_true(val)) ||
                ((val = switch_channel_get_variable(session->channel, "suppress_cng")) && switch_true(val))) {
                use_cng = 0;
-               smh->cng_pt = 0;
+               smh->mparams->cng_pt = 0;
        }
 
        if (!smh->payload_space) {
@@ -4036,7 +4036,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                                        smh->payload_space++;
                                }
                                if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) &&
-                                       smh->cng_pt && use_cng  && smh->cng_pt == smh->payload_space) {
+                                       smh->mparams->cng_pt && use_cng  && smh->mparams->cng_pt == smh->payload_space) {
                                        smh->payload_space++;
                                }
                                smh->ianacodes[i] = smh->payload_space++;
@@ -4136,8 +4136,8 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                        switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->mparams->te);
                }
                
-               if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->cng_pt && use_cng) {
-                       switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->cng_pt);
+               if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) {
+                       switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), " %d", smh->mparams->cng_pt);
                }
                
                switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "\n");
@@ -4158,10 +4158,10 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                        && smh->mparams->te > 95) {
                        switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d telephone-event/8000\na=fmtp:%d 0-16\n", smh->mparams->te, smh->mparams->te);
                }
-               if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->cng_pt && use_cng) {
-                       switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d CN/8000\n", smh->cng_pt);
+               if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) {
+                       switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=rtpmap:%d CN/8000\n", smh->mparams->cng_pt);
                        if (!a_engine->codec_params.rm_encoding) {
-                               smh->cng_pt = 0;
+                               smh->mparams->cng_pt = 0;
                        }
                } else {
                        switch_snprintf(buf + strlen(buf), SDPBUFLEN - strlen(buf), "a=silenceSupp:off - - - -\n");
@@ -4197,11 +4197,11 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
                int cur_ptime = 0, this_ptime = 0, cng_type = 0;
                const char *mult;
 
-               if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->cng_pt && use_cng) {
-                       cng_type = smh->cng_pt;
+               if (!switch_media_handle_test_media_flag(smh, SCMF_SUPPRESS_CNG) && smh->mparams->cng_pt && use_cng) {
+                       cng_type = smh->mparams->cng_pt;
 
                        if (!a_engine->codec_params.rm_encoding) {
-                               smh->cng_pt = 0;
+                               smh->mparams->cng_pt = 0;
                        }
                }
                
index 3481a2bef3da3d03c3bb5a3bf32dae0ebc4e0224..6c856986baa5377a949c09810249fcc615d86378 100644 (file)
@@ -992,7 +992,7 @@ static uint8_t get_next_write_ts(switch_rtp_t *rtp_session, uint32_t timestamp)
                if (rtp_session->ts <= rtp_session->last_write_ts && !(rtp_session->rtp_bugs & RTP_BUG_NEVER_SEND_MARKER)) {
                        m++;
                }
-       } else if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
+       } else if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
                rtp_session->ts = rtp_session->timer.samplecount;
 
                if (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->ts > 0) {
@@ -1025,7 +1025,7 @@ static int check_srtp_and_ice(switch_rtp_t *rtp_session)
                
                switch_rtp_write_manual(rtp_session, (void *) data, 2, 0, rtp_session->cng_pt, ntohl(rtp_session->send_msg.header.ts), &frame_flags);
                
-               if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
+               if (switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
                        rtp_session->last_write_samplecount = rtp_session->timer.samplecount;
                }
        }
@@ -4276,7 +4276,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
        }
 
        /* If the marker was set, and the timestamp seems to have started over - set a new SSRC, to indicate this is a new stream */
-       if (m && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) && 
+       if (m && !switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND) && (rtp_session->rtp_bugs & RTP_BUG_CHANGE_SSRC_ON_MARKER) && 
                (rtp_session->last_write_ts == RTP_TS_RESET || (rtp_session->ts <= rtp_session->last_write_ts && rtp_session->last_write_ts > 0))) {
                switch_rtp_set_ssrc(rtp_session, (uint32_t) ((intptr_t) rtp_session + (uint32_t) switch_epoch_time_now(NULL)));
        }