]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5682 --resolve new syntax <action application="set" data="sip_multipart=applicatio...
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 8 Aug 2013 17:55:04 +0000 (22:55 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 8 Aug 2013 17:55:13 +0000 (22:55 +0500)
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_media.c

index da0cd3deac2a45bc6138630f64e25e31ebbb3325..db11faa40ebd4053fbf6ba5c0371bed0d5f15c7a 100644 (file)
@@ -8436,16 +8436,8 @@ void sofia_handle_sip_i_invite(switch_core_session_t *session, nua_t *nua, sofia
                
                for (mp = sip->sip_multipart; mp; mp = mp->mp_next) {
                        if (mp->mp_payload && mp->mp_payload->pl_data && mp->mp_content_type && mp->mp_content_type->c_type) {
-                               char *name = switch_core_session_strdup(session, mp->mp_content_type->c_type);
-                               char *p;
-
-                               for (p = name; p && *p; p++) {
-                                       if (*p == '/') {
-                                               *p = '_';
-                                       }
-                               }
-                               
-                               switch_channel_set_variable_name_printf(channel, mp->mp_payload->pl_data, SOFIA_MULTIPART_PREFIX "%s", name);
+                               char *val = switch_core_session_sprintf(session, "%s:%s", mp->mp_content_type->c_type, mp->mp_payload->pl_data);
+                               switch_channel_add_variable_var_check(channel, "sip_multipart", val, SWITCH_FALSE, SWITCH_STACK_PUSH);
                        }
                }
        }
index ea403e7d3831095c041a76059102eb45b86030fb..620d4e5d0bedbe619fae3625410419669e2aa4cc 100644 (file)
@@ -1205,7 +1205,7 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
                tech_pvt->nh->nh_has_invite = 1;
        }
 
-       if ((mp = sofia_media_get_multipart(session, SOFIA_MULTIPART_PREFIX, tech_pvt->mparams.local_sdp_str, &mp_type))) {
+       if ((mp = sofia_media_get_multipart(session, "sip_multipart", tech_pvt->mparams.local_sdp_str, &mp_type))) {
                sofia_clear_flag(tech_pvt, TFLAG_ENABLE_SOA);
        }
 
index 87a4dc7eb589e615725e2ea9ab9a7a4093ded8b0..363da93dfc459c5dff01c459592a6a546909af51 100644 (file)
@@ -97,6 +97,19 @@ switch_status_t sofia_media_tech_media(private_object_t *tech_pvt, const char *r
        return SWITCH_STATUS_FALSE;
 }
 
+static void process_mp(switch_core_session_t *session, switch_stream_handle_t *stream, const char *boundary, const char *str) {
+       char *dname = switch_core_session_strdup(session, str);
+       char *dval;
+
+       if ((dval = strchr(dname, ':'))) {
+               *dval++ = '\0';
+               if (*dval == '~') {
+                       stream->write_function(stream, "--%s\nContent-Type: %s\nContent-Length: %d\n%s\n", boundary, dname, strlen(dval), dval + 1);
+               } else {
+                       stream->write_function(stream, "--%s\nContent-Type: %s\nContent-Length: %d\n\n%s\n", boundary, dname, strlen(dval) + 1, dval);
+               }                                                       
+       }
+}
 
 char *sofia_media_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type)
 {
@@ -113,14 +126,18 @@ char *sofia_media_get_multipart(switch_core_session_t *session, const char *pref
                        const char *name = (char *) hi->name;
                        char *value = (char *) hi->value;
 
-                       if (!strncasecmp(name, prefix, strlen(prefix))) {
-                               const char *hname = name + strlen(prefix);
-                               if (*value == '~') {
-                                       stream.write_function(&stream, "--%s\nContent-Type: %s\nContent-Length: %d\n%s\n", boundary, hname, strlen(value), value + 1);
+                       if (!strcasecmp(name, prefix)) {
+                               if (hi->idx > 0) {
+                                       int i = 0;
+
+                                       for(i = 0; i < hi->idx; i++) {
+                                               process_mp(session, &stream, boundary, hi->array[i]);
+                                               x++;
+                                       }
                                } else {
-                                       stream.write_function(&stream, "--%s\nContent-Type: %s\nContent-Length: %d\n\n%s\n", boundary, hname, strlen(value) + 1, value);
+                                       process_mp(session, &stream, boundary, value);
+                                       x++;
                                }
-                               x++;
                        }
                }
                switch_channel_variable_last(channel);