Index: /pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp
===================================================================
--- /pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp	(revision 4654)
+++ /pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp	(revision 4655)
@@ -449,4 +449,14 @@
     /** Media subtype. */
     string		subType;
+
+    /**
+     * Construct from PJSIP's pjsip_media_type
+     */
+    void fromPj(const pjsip_media_type &prm);
+
+    /**
+     * Convert to PJSIP's pjsip_media_type.
+     */
+    pjsip_media_type toPj() const;
 };
 
@@ -504,4 +514,19 @@
      */
     string		body;
+
+    /**
+     * Initiaize from PJSIP's pjsip_multipart_part.
+     */
+    void fromPj(const pjsip_multipart_part &prm) throw(Error);
+
+    /**
+     * Convert to PJSIP's pjsip_multipart_part.
+     */
+    pjsip_multipart_part& toPj() const;
+
+private:
+    /** Interal buffer for conversion to PJSIP pjsip_multipart_part */
+    mutable pjsip_multipart_part	pjMpp;
+    mutable pjsip_msg_body		pjMsgBody;
 };
 
@@ -555,5 +580,15 @@
     SipMultipartPartVector	multipartParts;
 
-};
+    /**
+     * Initiaize from PJSUA's pjsua_msg_data.
+     */
+    void fromPj(const pjsua_msg_data &prm) throw(Error);
+
+    /**
+     * Convert to PJSUA's pjsua_msg_data.
+     */
+    void toPj(pjsua_msg_data &msg_data) const;
+};
+
 
 /* Utilities */
Index: /pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp
===================================================================
--- /pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp	(revision 4654)
+++ /pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp	(revision 4655)
@@ -332,4 +332,21 @@
 ///////////////////////////////////////////////////////////////////////////////
 
+void SipMediaType::fromPj(const pjsip_media_type &prm)
+{
+    type	= pj2Str(prm.type);
+    subType	= pj2Str(prm.subtype);
+}
+
+pjsip_media_type SipMediaType::toPj() const
+{
+    pjsip_media_type pj_mt;
+    pj_bzero(&pj_mt, sizeof(pj_mt));
+    pj_mt.type	    = str2Pj(type);
+    pj_mt.subtype   = str2Pj(subType);
+    return pj_mt;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
 void SipHeader::fromPj(const pjsip_hdr *hdr) throw(Error)
 {
@@ -365,2 +382,95 @@
     return pjHdr;
 }
+
+///////////////////////////////////////////////////////////////////////////////
+
+void SipMultipartPart::fromPj(const pjsip_multipart_part &prm) throw(Error)
+{
+    headers.clear();
+    pjsip_hdr* pj_hdr = prm.hdr.next;
+    while (pj_hdr != &prm.hdr) {
+	SipHeader sh;
+	sh.fromPj(pj_hdr);
+	headers.push_back(sh);
+	pj_hdr = pj_hdr->next;
+    }
+
+    if (!prm.body)
+	PJSUA2_RAISE_ERROR(PJ_EINVAL);
+    
+    contentType.fromPj(prm.body->content_type);
+    body = string((char*)prm.body->data, prm.body->len);
+}
+
+pjsip_multipart_part& SipMultipartPart::toPj() const
+{
+    pj_list_init(&pjMpp.hdr);
+    for (unsigned i = 0; i < headers.size(); i++) {
+	pjsip_generic_string_hdr& pj_hdr = headers[i].toPj();
+	pj_list_push_back(&pjMpp.hdr, &pj_hdr);
+    }
+
+    pj_bzero(&pjMsgBody, sizeof(pjMsgBody));
+    pjMsgBody.content_type  = contentType.toPj();
+    pjMsgBody.print_body    = &pjsip_print_text_body;
+    pjMsgBody.clone_data    = &pjsip_clone_text_data;
+    pjMsgBody.data	    = (void*)body.c_str();
+    pjMsgBody.len	    = body.size();
+    pjMpp.body = &pjMsgBody;
+
+    return pjMpp;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void SipTxOption::fromPj(const pjsua_msg_data &prm) throw(Error)
+{
+    targetUri = pj2Str(prm.target_uri);
+
+    headers.clear();
+    pjsip_hdr* pj_hdr = prm.hdr_list.next;
+    while (pj_hdr != &prm.hdr_list) {
+	SipHeader sh;
+	sh.fromPj(pj_hdr);
+	headers.push_back(sh);
+	pj_hdr = pj_hdr->next;
+    }
+
+    contentType = pj2Str(prm.content_type);
+    msgBody = pj2Str(prm.msg_body);
+    multipartContentType.fromPj(prm.multipart_ctype);
+
+    multipartParts.clear();
+    pjsip_multipart_part* pj_mp = prm.multipart_parts.next;
+    while (pj_mp != &prm.multipart_parts) {
+	SipMultipartPart smp;
+	smp.fromPj(*pj_mp);
+	multipartParts.push_back(smp);
+	pj_mp = pj_mp->next;
+    }
+}
+
+void SipTxOption::toPj(pjsua_msg_data &msg_data) const
+{
+    unsigned i;
+
+    pjsua_msg_data_init(&msg_data);
+
+    msg_data.target_uri = str2Pj(targetUri);
+
+    pj_list_init(&msg_data.hdr_list);
+    for (i = 0; i < headers.size(); i++) {
+	pjsip_generic_string_hdr& pj_hdr = headers[i].toPj();
+	pj_list_push_back(&msg_data.hdr_list, &pj_hdr);
+    }
+
+    msg_data.content_type = str2Pj(contentType);
+    msg_data.msg_body = str2Pj(msgBody);
+    msg_data.multipart_ctype = multipartContentType.toPj();
+
+    pj_list_init(&msg_data.multipart_parts);
+    for (i = 0; i < multipartParts.size(); i++) {
+	pjsip_multipart_part& pj_part = multipartParts[i].toPj();
+	pj_list_push_back(&msg_data.multipart_parts, &pj_part);
+    }
+}
