]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 27 Mar 2008 20:36:03 +0000 (20:36 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 27 Mar 2008 20:36:03 +0000 (20:36 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7972 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_conference/mod_conference.c
src/mod/endpoints/mod_sofia/mod_sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/switch_core_codec.c
src/switch_core_state_machine.c
src/switch_loadable_module.c

index 1a3cdf478d06e08a45010fac5e93aebf5e11c85c..80a8e5ef3c94ea978420aec820b9ed1503dfc816 100644 (file)
@@ -4140,6 +4140,12 @@ SWITCH_STANDARD_APP(conference_function)
        conf_xml_cfg_t xml_cfg = { 0 };
        switch_event_t *params = NULL;
 
+       /* Save the original read codec. */
+       if (!(read_codec = switch_core_session_get_read_codec(session))) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Channel has no media!\n");
+               return;
+       }
+       
 
        if (switch_strlen_zero(data)) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid arguments\n");
@@ -4376,9 +4382,7 @@ SWITCH_STANDARD_APP(conference_function)
                if (!switch_channel_test_flag(channel, CF_OUTBOUND))
                        switch_set_flag(conference, CFLAG_ANSWERED);
        }
-
-       /* Save the original read codec. */
-       read_codec = switch_core_session_get_read_codec(session);
+       
        member.orig_read_codec = read_codec;
        member.native_rate = read_codec->implementation->samples_per_second;
        member.pool = switch_core_session_get_pool(session);
index 14639f1026bee99e98b4d46b23bf7c6aaf69b9bb..43ce3fa9653f9edb194262ae0e53cb8b523159d7 100644 (file)
@@ -1043,7 +1043,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
                                } else {
                                        if (switch_test_flag(tech_pvt, TFLAG_LATE_NEGOTIATION)) {
                                                switch_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
-                                               
                                                if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
                                                        const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
 
index ded7bfcaaac0cd93743f11a0fae3d26b8495042f..dfd38d82005f2307c843a96d0d04792aef5f7a6d 100644 (file)
@@ -1961,6 +1961,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
 
                        for (map = m->m_rtpmaps; map; map = map->rm_next) {
                                int32_t i;
+                               uint32_t near_rate = 0;
                                const switch_codec_implementation_t *mimp = NULL, *near_match = NULL;
                                const char *rm_encoding;
                                
@@ -2018,8 +2019,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
                                                match = strcasecmp(rm_encoding, imp->iananame) ? 0 : 1;
                                        }
                                        
-                                       if (match && (map->rm_rate == codec_rate)) {
-                                               if (ptime && ptime * 1000 != imp->microseconds_per_frame) {
+                                       if (match) {
+                                               if ((ptime && ptime * 1000 != imp->microseconds_per_frame) || map->rm_rate != codec_rate) {
+                                                       near_rate = map->rm_rate;
                                                        near_match = imp;
                                                        match = 0;
                                                        continue;
@@ -2036,8 +2038,8 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
                                        char *prefs[1];
                                        char tmp[80];
                                        int num;
-
-                                       switch_snprintf(tmp, sizeof(tmp), "%s@%uk@%ui", near_match->iananame, near_match->samples_per_second, ptime);
+                                       
+                                       switch_snprintf(tmp, sizeof(tmp), "%s@%uk@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, ptime);
                                        
                                        prefs[0] = tmp;
                                        num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
@@ -2047,9 +2049,9 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
                                        } else {
                                                mimp = near_match;
                                        }
-
-                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ums\n",
-                                                                         mimp->iananame, mimp->microseconds_per_frame / 1000);
+                                       
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
+                                                                         mimp->iananame, mimp->microseconds_per_frame / 1000, mimp->samples_per_second);
                                        match = 1;
                                }
 
index 1b97958e6031c858fb4148442d6600ee4153b299..01f3fb3e0e43eb94dfeb4fe2c48f3145830bc09e 100644 (file)
@@ -41,6 +41,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
        switch_channel_t *channel = switch_core_session_get_channel(session);
        char tmp[30];
 
+       switch_assert(codec->implementation);
+       
        if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
                switch_channel_event_set_data(session->channel, event);
                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", "%s", codec->implementation->iananame);
@@ -75,6 +77,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_
        switch_channel_t *channel = switch_core_session_get_channel(session);
        char tmp[30];
 
+       switch_assert(codec->implementation);
+
        if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
                switch_channel_event_set_data(session->channel, event);
                switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", "%s", codec->implementation->iananame);
index dbf6accc3efe04cd5db53e8d49acd3ba17aa7c2f..ad5fb7d28f9779bec2f92e9fd1af9d1ff57b768b 100644 (file)
@@ -160,7 +160,10 @@ static void switch_core_standard_on_execute(switch_core_session_t *session)
                } else if (!switch_test_flag(application_interface, SAF_SUPPORT_NOMEDIA) && !switch_channel_media_ready(session->channel)) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Application %s Requires media! pre_answering channel %s\n",
                                                          extension->current_application->application_name, switch_channel_get_name(session->channel));
-                       switch_channel_pre_answer(session->channel);
+                       if (switch_channel_pre_answer(session->channel) != SWITCH_STATUS_SUCCESS) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Well, that didn't work very well did it? ...\n");
+                               return;
+                       }
                }
 
                if ((expanded =
index 699537b51228b26f49b59c99e3dfcdd522048520..3c750d547d1b968f1349ac2b810649d6d4b4dfd6 100644 (file)
@@ -1245,7 +1245,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
        
        for (x = 0; x < preflen; x++) {
                char *cur, *last = NULL, *next = NULL, *name, *p, buf[256];
-               uint32_t interval = 0, rate = 0;
+               uint32_t interval = 0, rate = 8000;
 
                switch_copy_string(buf, prefs[x], sizeof(buf));
                last = name = next = cur = buf;