Changeset 4655
- Timestamp:
- Nov 23, 2013 3:54:03 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/siptypes.hpp
r4644 r4655 449 449 /** Media subtype. */ 450 450 string subType; 451 452 /** 453 * Construct from PJSIP's pjsip_media_type 454 */ 455 void fromPj(const pjsip_media_type &prm); 456 457 /** 458 * Convert to PJSIP's pjsip_media_type. 459 */ 460 pjsip_media_type toPj() const; 451 461 }; 452 462 … … 504 514 */ 505 515 string body; 516 517 /** 518 * Initiaize from PJSIP's pjsip_multipart_part. 519 */ 520 void fromPj(const pjsip_multipart_part &prm) throw(Error); 521 522 /** 523 * Convert to PJSIP's pjsip_multipart_part. 524 */ 525 pjsip_multipart_part& toPj() const; 526 527 private: 528 /** Interal buffer for conversion to PJSIP pjsip_multipart_part */ 529 mutable pjsip_multipart_part pjMpp; 530 mutable pjsip_msg_body pjMsgBody; 506 531 }; 507 532 … … 555 580 SipMultipartPartVector multipartParts; 556 581 557 }; 582 /** 583 * Initiaize from PJSUA's pjsua_msg_data. 584 */ 585 void fromPj(const pjsua_msg_data &prm) throw(Error); 586 587 /** 588 * Convert to PJSUA's pjsua_msg_data. 589 */ 590 void toPj(pjsua_msg_data &msg_data) const; 591 }; 592 558 593 559 594 /* Utilities */ -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/siptypes.cpp
r4645 r4655 332 332 /////////////////////////////////////////////////////////////////////////////// 333 333 334 void SipMediaType::fromPj(const pjsip_media_type &prm) 335 { 336 type = pj2Str(prm.type); 337 subType = pj2Str(prm.subtype); 338 } 339 340 pjsip_media_type SipMediaType::toPj() const 341 { 342 pjsip_media_type pj_mt; 343 pj_bzero(&pj_mt, sizeof(pj_mt)); 344 pj_mt.type = str2Pj(type); 345 pj_mt.subtype = str2Pj(subType); 346 return pj_mt; 347 } 348 349 /////////////////////////////////////////////////////////////////////////////// 350 334 351 void SipHeader::fromPj(const pjsip_hdr *hdr) throw(Error) 335 352 { … … 365 382 return pjHdr; 366 383 } 384 385 /////////////////////////////////////////////////////////////////////////////// 386 387 void SipMultipartPart::fromPj(const pjsip_multipart_part &prm) throw(Error) 388 { 389 headers.clear(); 390 pjsip_hdr* pj_hdr = prm.hdr.next; 391 while (pj_hdr != &prm.hdr) { 392 SipHeader sh; 393 sh.fromPj(pj_hdr); 394 headers.push_back(sh); 395 pj_hdr = pj_hdr->next; 396 } 397 398 if (!prm.body) 399 PJSUA2_RAISE_ERROR(PJ_EINVAL); 400 401 contentType.fromPj(prm.body->content_type); 402 body = string((char*)prm.body->data, prm.body->len); 403 } 404 405 pjsip_multipart_part& SipMultipartPart::toPj() const 406 { 407 pj_list_init(&pjMpp.hdr); 408 for (unsigned i = 0; i < headers.size(); i++) { 409 pjsip_generic_string_hdr& pj_hdr = headers[i].toPj(); 410 pj_list_push_back(&pjMpp.hdr, &pj_hdr); 411 } 412 413 pj_bzero(&pjMsgBody, sizeof(pjMsgBody)); 414 pjMsgBody.content_type = contentType.toPj(); 415 pjMsgBody.print_body = &pjsip_print_text_body; 416 pjMsgBody.clone_data = &pjsip_clone_text_data; 417 pjMsgBody.data = (void*)body.c_str(); 418 pjMsgBody.len = body.size(); 419 pjMpp.body = &pjMsgBody; 420 421 return pjMpp; 422 } 423 424 /////////////////////////////////////////////////////////////////////////////// 425 426 void SipTxOption::fromPj(const pjsua_msg_data &prm) throw(Error) 427 { 428 targetUri = pj2Str(prm.target_uri); 429 430 headers.clear(); 431 pjsip_hdr* pj_hdr = prm.hdr_list.next; 432 while (pj_hdr != &prm.hdr_list) { 433 SipHeader sh; 434 sh.fromPj(pj_hdr); 435 headers.push_back(sh); 436 pj_hdr = pj_hdr->next; 437 } 438 439 contentType = pj2Str(prm.content_type); 440 msgBody = pj2Str(prm.msg_body); 441 multipartContentType.fromPj(prm.multipart_ctype); 442 443 multipartParts.clear(); 444 pjsip_multipart_part* pj_mp = prm.multipart_parts.next; 445 while (pj_mp != &prm.multipart_parts) { 446 SipMultipartPart smp; 447 smp.fromPj(*pj_mp); 448 multipartParts.push_back(smp); 449 pj_mp = pj_mp->next; 450 } 451 } 452 453 void SipTxOption::toPj(pjsua_msg_data &msg_data) const 454 { 455 unsigned i; 456 457 pjsua_msg_data_init(&msg_data); 458 459 msg_data.target_uri = str2Pj(targetUri); 460 461 pj_list_init(&msg_data.hdr_list); 462 for (i = 0; i < headers.size(); i++) { 463 pjsip_generic_string_hdr& pj_hdr = headers[i].toPj(); 464 pj_list_push_back(&msg_data.hdr_list, &pj_hdr); 465 } 466 467 msg_data.content_type = str2Pj(contentType); 468 msg_data.msg_body = str2Pj(msgBody); 469 msg_data.multipart_ctype = multipartContentType.toPj(); 470 471 pj_list_init(&msg_data.multipart_parts); 472 for (i = 0; i < multipartParts.size(); i++) { 473 pjsip_multipart_part& pj_part = multipartParts[i].toPj(); 474 pj_list_push_back(&msg_data.multipart_parts, &pj_part); 475 } 476 }
Note: See TracChangeset
for help on using the changeset viewer.