]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6880 #resolve #comment I would think that in real life once the call agreed on...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 1 Oct 2014 18:03:50 +0000 (13:03 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 1 Oct 2014 18:03:50 +0000 (13:03 -0500)
src/include/switch_core_media.h
src/mod/endpoints/mod_sofia/sofia.c
src/switch_channel.c
src/switch_core_media.c

index e956905e601c2221cc31da55299df2805198a85e..2256814d0141f846333db173803902ad5dc3add7 100644 (file)
@@ -276,7 +276,7 @@ SWITCH_DECLARE(switch_rtp_crypto_key_type_t) switch_core_media_crypto_str2type(c
 SWITCH_DECLARE(const char *) switch_core_media_crypto_type2str(switch_rtp_crypto_key_type_t type);
 SWITCH_DECLARE(int) switch_core_media_crypto_keylen(switch_rtp_crypto_key_type_t type);
 SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp, const char *cmd, const char *arg);
-
+SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session);
 SWITCH_END_EXTERN_C
 #endif
 /* For Emacs:
index 5550e78d9ed97ac5219a2dd5ad0384cd279cd01b..dcf485de729d0a8081eca382990d55ac9ae5b20e 100644 (file)
@@ -6348,6 +6348,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
        int is_dup_sdp = 0;
        switch_event_t *s_event = NULL;
        char *p;
+       char *patched_sdp = NULL;
 
        tl_gets(tags,
                        NUTAG_CALLSTATE_REF(ss_state),
@@ -6373,6 +6374,16 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                tech_pvt->mparams.last_sdp_str = NULL;
        }
 
+       if (r_sdp && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) {
+               const char *var;
+
+               if ((var = switch_channel_get_variable(channel, "bypass_media_sdp_filter"))) {
+                       if ((patched_sdp = switch_core_media_process_sdp_filter(r_sdp, var, session))) {
+                               r_sdp = patched_sdp;
+                       }
+               }
+       }
+
        if ((channel && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) ||
                (sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) {
 
@@ -7319,6 +7330,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
 
   done:
 
+       switch_safe_free(patched_sdp);
 
        if ((enum nua_callstate) ss_state == nua_callstate_ready && channel && session && tech_pvt) {
                sofia_set_flag(tech_pvt, TFLAG_SIMPLIFY);
index 0a34ab2a61740a4c6bdda5d58cfa44164017f789..eb38298e37e40efee191247c201d74a0e374a9c9 100644 (file)
@@ -5222,57 +5222,21 @@ SWITCH_DECLARE(switch_status_t) switch_channel_unbind_device_state_handler(switc
 
 SWITCH_DECLARE(switch_status_t) switch_channel_pass_sdp(switch_channel_t *from_channel, switch_channel_t *to_channel, const char *sdp)
 {
+       switch_status_t status = SWITCH_STATUS_FALSE;
        char *use_sdp = (char *) sdp;
        char *patched_sdp = NULL;
-       switch_status_t status = SWITCH_STATUS_FALSE;
 
        if (!switch_channel_get_variable(to_channel, SWITCH_B_SDP_VARIABLE)) {
                const char *var;
 
                if ((var = switch_channel_get_variable(from_channel, "bypass_media_sdp_filter"))) {
-                       char *cmd = switch_core_session_strdup(from_channel->session, var);
-                       int argc = 0;
-                       char *argv[50];
-                       int x = 0;
-
-                       argc = switch_split(cmd, '|', argv);
-
-                       for (x = 0; x < argc; x++) {
-                               char *command = argv[x];
-                               char *arg = strchr(command, '(');
-
-                               if (arg) {
-                                       char *e = switch_find_end_paren(arg, '(', ')');
-                                       *arg++ = '\0';
-                                       if (e) *e = '\0';
-                               }
-
-                               if (zstr(command) || zstr(arg)) {
-                                       switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(from_channel), SWITCH_LOG_WARNING, "%s SDP FILTER PARSE ERROR\n", from_channel->name);
-                               } else {
-                                       char *tmp_sdp = NULL;
-
-                                       if (patched_sdp) {
-                                               tmp_sdp = switch_core_media_filter_sdp(patched_sdp, command, arg);
-                                       } else {
-                                               tmp_sdp = switch_core_media_filter_sdp(use_sdp, command, arg);
-                                       }
-
-
-                                       switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(from_channel), SWITCH_LOG_DEBUG, 
-                                                                         "Filter command %s(%s)\nFROM:\n==========\n%s\nTO:\n==========\n%s\n\n", 
-                                                                         command, arg, patched_sdp ? patched_sdp : use_sdp, tmp_sdp);
-
 
-                                       if (tmp_sdp) {
-                                               switch_safe_free(patched_sdp);
-                                               patched_sdp = use_sdp = tmp_sdp;
-                                       }
-                               }
+                       if ((patched_sdp = switch_core_media_process_sdp_filter(use_sdp, var, from_channel->session))) {
+                               use_sdp = patched_sdp;
                        }
-               }
 
-               switch_channel_set_variable(to_channel, SWITCH_B_SDP_VARIABLE, use_sdp);
+                       switch_channel_set_variable(to_channel, SWITCH_B_SDP_VARIABLE, use_sdp);
+               }
        }
 
        switch_safe_free(patched_sdp);
index e4e810b6dde7a5ed1c0deffde97e60d206287426..ffb54a744889212879e2e2a94c7a6623bd8cfdc7 100644 (file)
@@ -9067,7 +9067,56 @@ SWITCH_DECLARE(char *) switch_core_media_filter_sdp(const char *sdp_str, const c
        return new_sdp;
 }
 
+SWITCH_DECLARE(char *) switch_core_media_process_sdp_filter(const char *sdp, const char *cmd_buf, switch_core_session_t *session)
+{
+       switch_channel_t *channel = switch_core_session_get_channel(session);
+       char *cmd = switch_core_session_strdup(session, cmd_buf);
+       int argc = 0;
+       char *argv[50];
+       int x = 0;
+       char *use_sdp = (char *) sdp;
+       char *patched_sdp = NULL;
+
+       argc = switch_split(cmd, '|', argv);
+
+       for (x = 0; x < argc; x++) {
+               char *command = argv[x];
+               char *arg = strchr(command, '(');
+
+               if (arg) {
+                       char *e = switch_find_end_paren(arg, '(', ')');
+                       *arg++ = '\0';
+                       if (e) *e = '\0';
+               }
+
+               if (zstr(command) || zstr(arg)) {
+                       switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_WARNING, "%s SDP FILTER PARSE ERROR\n", switch_channel_get_name(channel));
+               } else {
+                       char *tmp_sdp = NULL;
+
+                       if (patched_sdp) {
+                               tmp_sdp = switch_core_media_filter_sdp(patched_sdp, command, arg);
+                       } else {
+                               tmp_sdp = switch_core_media_filter_sdp(use_sdp, command, arg);
+                       }
+
+
+                       switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, 
+                                                         "%s Filter command %s(%s)\nFROM:\n==========\n%s\nTO:\n==========\n%s\n\n", 
+                                                         switch_channel_get_name(channel),
+                                                         command, arg, patched_sdp ? patched_sdp : use_sdp, tmp_sdp);
+
+
+                       if (tmp_sdp) {
+                               switch_safe_free(patched_sdp);
+                               patched_sdp = use_sdp = tmp_sdp;
+                       }
+               }
+       }
 
+       return patched_sdp;
+
+}
 
 /* For Emacs:
  * Local Variables: