From e6788964043367f34fbdeadfd76a77e8a35abb80 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 7 Mar 2007 20:06:15 +0000 Subject: [PATCH] sigh git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4467 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/codecs/mod_g729/mod_g729.c | 8 ++++---- src/mod/endpoints/mod_sofia/mod_sofia.c | 23 +++++++++++++---------- src/switch_rtp.c | 4 ++++ 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/mod/codecs/mod_g729/mod_g729.c b/src/mod/codecs/mod_g729/mod_g729.c index 12ec94f9ce..d28e42dc53 100644 --- a/src/mod/codecs/mod_g729/mod_g729.c +++ b/src/mod/codecs/mod_g729/mod_g729.c @@ -214,10 +214,10 @@ static switch_status_t switch_g729_decode(switch_codec_t *codec, } } - } //else { - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len); - //return SWITCH_STATUS_FALSE; - //} + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "yo this frame is an odd size [%d]\n", encoded_data_len); + return SWITCH_STATUS_FALSE; + } return SWITCH_STATUS_SUCCESS; #endif } diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index 8ebc5a0c1d..5d366f32af 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -750,10 +750,6 @@ static void set_local_sdp(private_object_t *tech_pvt, char *ip, uint32_t port, c snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->te); } - if (tech_pvt->read_codec.implementation->samples_per_second == 8000) { - tech_pvt->cng_pt = SWITCH_RTP_CNG_PAYLOAD; - } - if (tech_pvt->cng_pt) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->cng_pt); } @@ -880,13 +876,13 @@ static void attach_private(switch_core_session_t *session, tech_pvt->profile = profile; if (tech_pvt->bte) { tech_pvt->te = tech_pvt->bte; - } else { + } else if (!tech_pvt->te) { tech_pvt->te = profile->te; } if (tech_pvt->bcng_pt) { tech_pvt->cng_pt = tech_pvt->bcng_pt; - } else { + } else if (!tech_pvt->cng_pt) { tech_pvt->cng_pt = profile->cng_pt; } @@ -1629,6 +1625,7 @@ static switch_status_t activate_rtp(private_object_t *tech_pvt) switch_rtp_set_telephony_event(tech_pvt->rtp_session, tech_pvt->te); if (tech_pvt->cng_pt) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "WTF %d", tech_pvt->cng_pt); switch_rtp_set_cng_pt(tech_pvt->rtp_session, tech_pvt->cng_pt); } @@ -1829,7 +1826,7 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f if (tech_pvt->read_frame.datalen > 0) { size_t bytes = 0; int frames = 1; - //tech_pvt->last_read = switch_time_now(); + if (!switch_test_flag((&tech_pvt->read_frame), SFF_CNG)) { if ((bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame)) { frames = (tech_pvt->read_frame.datalen / bytes); @@ -2390,7 +2387,7 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp) { uint8_t match = 0; - switch_payload_t te = 0; + switch_payload_t te = 0, cng_pt = 0; private_object_t *tech_pvt; sdp_media_t *m; sdp_attribute_t *a; @@ -2449,10 +2446,16 @@ static uint8_t negotiate_sdp(switch_core_session_t *session, sdp_session_t *sdp) if (!te && !strcasecmp(map->rm_encoding, "telephone-event")) { te = tech_pvt->te = (switch_payload_t)map->rm_pt; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set 2833 dtmf payload to %u\n", te); } + if (!cng_pt && !strcasecmp(map->rm_encoding, "CN")) { + cng_pt = tech_pvt->cng_pt = (switch_payload_t)map->rm_pt; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set comfort noise payload to %u\n", cng_pt); + } + if (match) { - if (te) { + if (te && cng_pt) { break; } continue; @@ -5305,7 +5308,7 @@ static switch_status_t config_sofia(int reload) } if (!profile->cng_pt) { - profile->cng_pt = 127; + profile->cng_pt = SWITCH_RTP_CNG_PAYLOAD; } if (!profile->sipip) { diff --git a/src/switch_rtp.c b/src/switch_rtp.c index b1d3a9fc94..a93c5f514c 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -779,6 +779,10 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ switch_core_timer_step(&rtp_session->timer); } + if (rtp_session->recv_msg.header.pt == rtp_session->cng_pt) { + *flags |= SFF_CNG; + } + if (!bytes && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK)) { switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);