]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
alter implementation of renegotiate codec on hold feature to still take other sdp...
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 8 Mar 2011 16:37:16 +0000 (10:37 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 8 Mar 2011 16:37:16 +0000 (10:37 -0600)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia_glue.c

index 373601683df561260b194d94659760e51a0e2116..c46e6395a0d8de807394d8e6db524d96f033969e 100644 (file)
@@ -599,6 +599,8 @@ struct private_object {
        int codec_order_last;
        const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
        int num_codecs;
+       const switch_codec_implementation_t *negotiated_codecs[SWITCH_MAX_CODECS];
+       int num_negotiated_codecs;
        switch_codec_t read_codec;
        switch_codec_t write_codec;
        uint32_t codec_ms;
index f66993ef6f02a882a4f025cc0aa2c1501624081a..8d7fb6bc57e6f443f32bd38e4694dc1e32ac33c0 100644 (file)
@@ -4171,6 +4171,14 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
        int scrooge = 0;
        sdp_parser_t *parser = NULL;
        sdp_session_t *sdp;
+       int reneg = 1;
+       const switch_codec_implementation_t **codec_array;
+       int total_codecs;
+
+
+       codec_array = tech_pvt->codecs;
+       total_codecs = tech_pvt->num_codecs;
+
 
        if (!(parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
                return 0;
@@ -4272,21 +4280,21 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                if (!tech_pvt->hold_laps) {
                        tech_pvt->hold_laps++;
                        if (sofia_glue_toggle_hold(tech_pvt, sendonly)) {
-                               int reneg = sofia_test_pflag(tech_pvt->profile, PFLAG_RENEG_ON_HOLD);
+                               reneg = sofia_test_pflag(tech_pvt->profile, PFLAG_RENEG_ON_HOLD);
                                
                                if ((val = switch_channel_get_variable(tech_pvt->channel, "sip_renegotiate_codec_on_hold"))) {
                                        reneg = switch_true(val);
                                }
-
-                               if (!reneg) {
-                                       match = 1;
-                                       goto done;
-                               }
                        }
                        
                }
        }
 
+       if (!reneg) {
+               codec_array = tech_pvt->negotiated_codecs;
+               total_codecs = tech_pvt->num_negotiated_codecs;
+       }
+
        for (m = sdp->sdp_media; m; m = m->m_next) {
                sdp_connection_t *connection;
                switch_core_session_t *other_session;
@@ -4380,6 +4388,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                        goto done;
                } else if (m->m_type == sdp_media_audio && m->m_port && !got_audio) {
                        sdp_rtpmap_t *map;
+
                        for (attr = m->m_attributes; attr; attr = attr->a_next) {
 
                                if (!strcasecmp(attr->a_name, "rtcp") && attr->a_value) {
@@ -4590,8 +4599,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                                        }
                                }
 
-                               for (i = first; i < last && i < tech_pvt->num_codecs; i++) {
-                                       const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
+                               
+                               for (i = first; i < last && i < total_codecs; i++) {
+                                       const switch_codec_implementation_t *imp = codec_array[i];
                                        uint32_t bit_rate = imp->bits_per_second;
                                        uint32_t codec_rate = imp->samples_per_second;
                                        if (imp->codec_type != SWITCH_CODEC_TYPE_AUDIO) {
@@ -4678,6 +4688,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                                        tech_pvt->rm_fmtp = switch_core_session_strdup(session, (char *) map->rm_fmtp);
                                        tech_pvt->remote_sdp_audio_port = (switch_port_t) m->m_port;
                                        tech_pvt->agreed_pt = (switch_payload_t) map->rm_pt;
+                                       tech_pvt->negotiated_codecs[tech_pvt->num_negotiated_codecs++] = mimp;
                                        switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_sdp_audio_port);
                                        switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE, tech_pvt->remote_sdp_audio_ip);
                                        switch_channel_set_variable(tech_pvt->channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE, tmp);
@@ -4719,7 +4730,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                        }
 
                        
-                       if (!match && greedy && mine < tech_pvt->num_codecs) {
+                       if (!match && greedy && mine < total_codecs) {
                                mine++;
                                skip = 0;
                                goto greed;
@@ -4758,8 +4769,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
                                        rm_encoding = "";
                                }
 
-                               for (i = 0; i < tech_pvt->num_codecs; i++) {
-                                       const switch_codec_implementation_t *imp = tech_pvt->codecs[i];
+                               for (i = 0; i < total_codecs; i++) {
+                                       const switch_codec_implementation_t *imp = codec_array[i];
 
                                        if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
                                                continue;
@@ -4821,8 +4832,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, const char *r_s
 
  done:
 
-       if (parser)
+       if (parser) {
                sdp_parser_free(parser);
+       }
 
        tech_pvt->cng_pt = cng_pt;
        sofia_set_flag_locked(tech_pvt, TFLAG_SDP);