diff options
author | Benny Prijono <bennylp@teluu.com> | 2010-08-01 09:48:51 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2010-08-01 09:48:51 +0000 |
commit | 059d687249f0f95e0b30785c418e1aa47555615a (patch) | |
tree | 792e10acf82954faca0a2b7fe937064a1ecb81d8 /pjsip/src/pjsua-lib/pjsua_core.c | |
parent | 1426b8301e4d99837bd70ce73b350d03fafbfd45 (diff) |
Implemented core multipart support and support in the invite session (re #1070)
- incoming multipart message will be handled automatically
- for testing, enable HAVE_MULTIPART_TEST in pjsua_app.c
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3243 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib/pjsua_core.c')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_core.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c index 3d13f2eb..3150d977 100644 --- a/pjsip/src/pjsua-lib/pjsua_core.c +++ b/pjsip/src/pjsua-lib/pjsua_core.c @@ -142,6 +142,8 @@ PJ_DEF(void) pjsua_msg_data_init(pjsua_msg_data *msg_data) { pj_bzero(msg_data, sizeof(*msg_data)); pj_list_init(&msg_data->hdr_list); + pjsip_media_type_init(&msg_data->multipart_ctype, NULL, NULL); + pj_list_init(&msg_data->multipart_parts); } PJ_DEF(void) pjsua_transport_config_default(pjsua_transport_config *cfg) @@ -2225,6 +2227,37 @@ void pjsua_process_msg_data(pjsip_tx_data *tdata, &msg_data->msg_body); tdata->msg->body = body; } + + /* Multipart */ + if (!pj_list_empty(&msg_data->multipart_parts) && + msg_data->multipart_ctype.type.slen) + { + pjsip_msg_body *bodies; + pjsip_multipart_part *part; + pj_str_t *boundary = NULL; + + bodies = pjsip_multipart_create(tdata->pool, + &msg_data->multipart_ctype, + boundary); + part = msg_data->multipart_parts.next; + while (part != &msg_data->multipart_parts) { + pjsip_multipart_part *part_copy; + + part_copy = pjsip_multipart_clone_part(tdata->pool, part); + pjsip_multipart_add_part(tdata->pool, bodies, part_copy); + part = part->next; + } + + if (tdata->msg->body) { + part = pjsip_multipart_create_part(tdata->pool); + part->body = tdata->msg->body; + pjsip_multipart_add_part(tdata->pool, bodies, part); + + tdata->msg->body = NULL; + } + + tdata->msg->body = bodies; + } } |