Changeset 5972 for pjproject/trunk/pjsip/src/pjsua2/call.cpp
- Timestamp:
- Apr 23, 2019 10:49:56 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/call.cpp
r5969 r5972 152 152 ////////////////////////////////////////////////////////////////////////////// 153 153 154 /* Call Audio Media. */155 class CallAudioMedia : public AudioMedia156 {157 public:158 /*159 * Set the conference port identification associated with the160 * call audio media.161 */162 void setPortId(int id);163 164 /**165 * Destructor166 */167 virtual ~CallAudioMedia();168 };169 170 171 void CallAudioMedia::setPortId(int pid)172 {173 this->id = pid;174 }175 176 CallAudioMedia::~CallAudioMedia()177 {178 id = PJSUA_INVALID_ID;179 }180 181 154 CallOpParam::CallOpParam(bool useDefaultCallSetting) 182 155 : statusCode(pjsip_status_code(0)), reason(""), options(0) … … 271 244 272 245 CallMediaInfo::CallMediaInfo() 273 : videoWindow(PJSUA_INVALID_ID) 246 : audioConfSlot(PJSUA_INVALID_ID), 247 videoWindow(PJSUA_INVALID_ID), 248 videoIncomingWindowId(PJSUA_INVALID_ID), 249 videoCapDev(PJMEDIA_VID_INVALID_DEV) 274 250 { 275 251 } … … 522 498 } 523 499 524 AudioMedia Call::getAudioMedia(unsigned med_idx) const throw(Error) 525 { 526 CallAudioMedia cam; 527 CallInfo ci = getInfo(); 528 529 if (med_idx < ci.media.size() && 530 ci.media[med_idx].type == PJMEDIA_TYPE_AUDIO) 531 { 532 cam.setPortId(ci.media[med_idx].audioConfSlot); 533 } 534 return cam; 500 AudioMedia Call::getAudioMedia(int med_idx) const throw(Error) 501 { 502 pjsua_call_info pj_ci; 503 pjsua_call_get_info(id, &pj_ci); 504 505 if (med_idx < 0) { 506 for (unsigned i = 0; i < pj_ci.media_cnt; ++i) { 507 if (pj_ci.media[med_idx].type == PJMEDIA_TYPE_AUDIO && 508 pj_ci.media[med_idx].stream.aud.conf_slot != PJSUA_INVALID_ID) 509 { 510 med_idx = i; 511 break; 512 } 513 } 514 if (med_idx < 0) { 515 PJSUA2_RAISE_ERROR3(PJ_ENOTFOUND, "getAudioMedia()", 516 "no active audio media"); 517 } 518 } 519 520 if (med_idx >= (int)pj_ci.media_cnt) { 521 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getAudioMedia()", 522 "invalid media index"); 523 } 524 if (pj_ci.media[med_idx].type != PJMEDIA_TYPE_AUDIO) { 525 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getAudioMedia()", 526 "media is not audio"); 527 } 528 if (pj_ci.media[med_idx].stream.aud.conf_slot == PJSUA_INVALID_ID) { 529 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getAudioMedia()", 530 "no audio slot (inactive?)"); 531 } 532 533 AudioMediaHelper am; 534 am.setPortId(pj_ci.media[med_idx].stream.aud.conf_slot); 535 return am; 536 } 537 538 VideoMedia Call::getEncodingVideoMedia(int med_idx) const throw(Error) 539 { 540 pjsua_call_info pj_ci; 541 pjsua_call_get_info(id, &pj_ci); 542 543 if (med_idx < 0) { 544 for (unsigned i = 0; i < pj_ci.media_cnt; ++i) { 545 if (pj_ci.media[med_idx].type == PJMEDIA_TYPE_VIDEO && 546 pj_ci.media[med_idx].stream.vid.enc_slot != PJSUA_INVALID_ID) 547 { 548 med_idx = i; 549 break; 550 } 551 } 552 if (med_idx < 0) { 553 PJSUA2_RAISE_ERROR3(PJ_ENOTFOUND, "getEncodingVideoMedia()", 554 "no active encoding video media"); 555 } 556 } 557 558 if (med_idx >= (int)pj_ci.media_cnt) { 559 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getEncodingVideoMedia()", 560 "invalid media index"); 561 } 562 if (pj_ci.media[med_idx].type != PJMEDIA_TYPE_VIDEO) { 563 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getEncodingVideoMedia()", 564 "media is not video"); 565 } 566 if (pj_ci.media[med_idx].stream.vid.enc_slot == PJSUA_INVALID_ID) { 567 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getEncodingVideoMedia()", 568 "no encoding slot (recvonly?)"); 569 } 570 571 VideoMediaHelper vm; 572 vm.setPortId(pj_ci.media[med_idx].stream.vid.enc_slot); 573 return vm; 574 } 575 576 VideoMedia Call::getDecodingVideoMedia(int med_idx) const throw(Error) 577 { 578 pjsua_call_info pj_ci; 579 pjsua_call_get_info(id, &pj_ci); 580 581 if (med_idx < 0) { 582 for (unsigned i = 0; i < pj_ci.media_cnt; ++i) { 583 if (pj_ci.media[med_idx].type == PJMEDIA_TYPE_VIDEO && 584 pj_ci.media[med_idx].stream.vid.dec_slot != PJSUA_INVALID_ID) 585 { 586 med_idx = i; 587 break; 588 } 589 } 590 if (med_idx < 0) { 591 PJSUA2_RAISE_ERROR3(PJ_ENOTFOUND, "getDecodingVideoMedia()", 592 "no active decoding video media"); 593 } 594 } 595 596 if (med_idx >= (int)pj_ci.media_cnt) { 597 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getDecodingVideoMedia()", 598 "invalid media index"); 599 } 600 if (pj_ci.media[med_idx].type != PJMEDIA_TYPE_VIDEO) { 601 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getDecodingVideoMedia()", 602 "media is not video"); 603 } 604 if (pj_ci.media[med_idx].stream.vid.dec_slot == PJSUA_INVALID_ID) { 605 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "getDecodingVideoMedia()", 606 "no decoding slot (sendonly?)"); 607 } 608 609 VideoMediaHelper vm; 610 vm.setPortId(pj_ci.media[med_idx].stream.vid.dec_slot); 611 return vm; 535 612 } 536 613 … … 791 868 if (mi >= medias.size()) { 792 869 if (pj_ci.media[mi].type == PJMEDIA_TYPE_AUDIO) { 793 medias.push_back(new CallAudioMedia);870 medias.push_back(new AudioMediaHelper); 794 871 } else { 795 872 medias.push_back(NULL); … … 798 875 799 876 if (pj_ci.media[mi].type == PJMEDIA_TYPE_AUDIO) { 800 CallAudioMedia *aud_med = (CallAudioMedia *)medias[mi]; 801 877 AudioMediaHelper *aud_med = (AudioMediaHelper*)medias[mi]; 802 878 aud_med->setPortId(pj_ci.media[mi].stream.aud.conf_slot); 803 /* Add media if the conference slot ID is valid. */ 879 880 /* Add media if the conference slot ID is valid. */ 804 881 if (pj_ci.media[mi].stream.aud.conf_slot != PJSUA_INVALID_ID) 805 882 { … … 808 885 Endpoint::instance().mediaRemove((AudioMedia &)*aud_med); 809 886 } 810 887 } 811 888 } 812 889 }
Note: See TracChangeset
for help on using the changeset viewer.