]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
make sure bargers use the same codec as bargee to avoid transcoding delay
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 14 May 2012 15:03:35 +0000 (10:03 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 14 May 2012 15:03:35 +0000 (10:03 -0500)
src/include/private/switch_core_pvt.h
src/include/switch_core.h
src/mod/endpoints/mod_sofia/sofia.c
src/switch_core_codec.c

index 95e66f2f6dc2f387b3298954cfde6b764d2ac964..00050082521939efebe3dcb8023a55be88a35745 100644 (file)
@@ -120,6 +120,7 @@ struct switch_core_session {
        switch_codec_t *video_write_codec;
 
        switch_codec_implementation_t read_impl;
+       switch_codec_implementation_t real_read_impl;
        switch_codec_implementation_t write_impl;
        switch_codec_implementation_t video_read_impl;
        switch_codec_implementation_t video_write_impl;
index 624d491e1d13a4b508136e8fc4c9a70a95884b74..522ebec1f8a8a38ffceb248a541a690b97b0c3ff 100644 (file)
@@ -1500,6 +1500,7 @@ SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_sess
 
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
+SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
 SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
 SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
 SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
index 26fc3e26689e26407bf3e64817249ff3616b66af..441da03052f3ed9ce620d31d98cc63fd6916d6aa 100644 (file)
@@ -8464,12 +8464,33 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
                                bridge_uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE);
 
                                if (call_info) {
+                                       const char *olu;
+                                       switch_core_session_t *os;
+                                       switch_codec_implementation_t read_impl = { 0 };
+                                       char *codec_str = "";
+
+                                       if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) {
+                                               olu = bridge_uuid;
+                                       } else {
+                                               olu = b_private->uuid;
+                                       }
+                                       
+                                       if ((os = switch_core_session_locate(olu))) {
+                                               switch_core_session_get_real_read_impl(os, &read_impl);
+                                               switch_core_session_rwunlock(os);
+
+                                               codec_str = switch_core_session_sprintf(session, "set:absolute_codec_string=%s@%di,", read_impl.iananame, 
+                                                                                                                          read_impl.microseconds_per_packet / 1000);
+                                       }
+                                       
+
+
                                        if (!zstr(bridge_uuid) && switch_channel_test_flag(b_channel, CF_LEG_HOLDING)) {
                                                tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, 
-                                                                                                                                                                                  "answer,intercept:%s", bridge_uuid);
+                                                                                                                                                                                  "%sanswer,intercept:%s", codec_str, bridge_uuid);
                                        } else {
                                                tech_pvt->caller_profile->destination_number = switch_core_sprintf(tech_pvt->caller_profile->pool, 
-                                                                                                                                                                                  "answer,sofia_sla:%s", b_private->uuid);
+                                                                                                                                                                                  "%sanswer,sofia_sla:%s", codec_str, b_private->uuid);
                                        }
                                } else {
                                        if (!zstr(bridge_uuid)) {
index 28439c1b602c7bc1c1f45bfd362cf6b89dfffa66..6ea47fcf13b9b18e8d9d6cb80a4548ff1728b521 100644 (file)
@@ -206,6 +206,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
                        session->read_codec = session->real_read_codec = codec;
                        if (codec->implementation) {
                                session->read_impl = *codec->implementation;
+                               session->real_read_impl = *codec->implementation;
                        } else {
                                memset(&session->read_impl, 0, sizeof(session->read_impl));
                        }
@@ -319,6 +320,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_se
        return SWITCH_STATUS_FALSE;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_core_session_get_real_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
+{
+       if (session->real_read_impl.codec_id) {
+               *impp = session->real_read_impl;
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       return SWITCH_STATUS_FALSE;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
 {
        if (session->write_impl.codec_id) {