FS-5682 --resolve new syntax <action application="set" data="sip_multipart=application/pidf+xml:1234"/> use push instead of set to add more to the same channel

This commit is contained in:
Anthony Minessale 2013-08-08 22:55:34 +05:00
parent 1ba3cc0d3e
commit 4296b5e257
2 changed files with 26 additions and 17 deletions

View File

@ -8349,16 +8349,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) { 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) { 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 *val = switch_core_session_sprintf(session, "%s:%s", mp->mp_content_type->c_type, mp->mp_payload->pl_data);
char *p; switch_channel_add_variable_var_check(channel, "sip_multipart", val, SWITCH_FALSE, SWITCH_STACK_PUSH);
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);
} }
} }
} }

View File

@ -1969,6 +1969,20 @@ void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_s
switch_mutex_unlock(tech_pvt->flag_mutex); switch_mutex_unlock(tech_pvt->flag_mutex);
} }
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_glue_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type) char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefix, const char *sdp, char **mp_type)
{ {
char *extra_headers = NULL; char *extra_headers = NULL;
@ -1984,15 +1998,19 @@ char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefi
const char *name = (char *) hi->name; const char *name = (char *) hi->name;
char *value = (char *) hi->value; char *value = (char *) hi->value;
if (!strncasecmp(name, prefix, strlen(prefix))) { if (!strcasecmp(name, prefix)) {
const char *hname = name + strlen(prefix); if (hi->idx > 0) {
if (*value == '~') { int i = 0;
stream.write_function(&stream, "--%s\nContent-Type: %s\nContent-Length: %d\n%s\n", boundary, hname, strlen(value), value + 1);
} else { for(i = 0; i < hi->idx; i++) {
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, hi->array[i]);
}
x++; x++;
} }
} else {
process_mp(session, &stream, boundary, value);
x++;
}
}
} }
switch_channel_variable_last(channel); switch_channel_variable_last(channel);
} }
@ -2014,7 +2032,6 @@ char *sofia_glue_get_multipart(switch_core_session_t *session, const char *prefi
return extra_headers; return extra_headers;
} }
char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix) char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix)
{ {
char *extra_headers = NULL; char *extra_headers = NULL;