- Timestamp:
- Dec 2, 2013 4:40:29 AM (11 years ago)
- Location:
- pjproject/branches/projects/pjsua2/pjsip
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/call.hpp
r4663 r4666 1089 1089 */ 1090 1090 bool hasMedia() const; 1091 1092 /** 1093 * Get media for the specified media index. 1094 * 1095 * @psaram med_idx Media index. 1096 * 1097 * @return The media or NULL if invalid or inactive. 1098 */ 1099 Media *getMedia(unsigned med_idx) const; 1091 1100 1092 1101 /** … … 1420 1429 MediaTransportInfo getMedTransportInfo(unsigned med_idx) const throw(Error); 1421 1430 1431 /** 1432 * Internal function (callled by Endpoint( to process update to call 1433 * medias when call media state changes. 1434 */ 1435 void processMediaUpdate(OnCallMediaStateParam &prm); 1436 1437 /** 1438 * Internal function (called by Endpoint) to process call state change. 1439 */ 1440 void processStateChange(OnCallStateParam &prm); 1441 1422 1442 public: 1423 1443 /* … … 1665 1685 {} 1666 1686 1667 protected:1668 friend class Endpoint;1669 1670 1687 private: 1671 1688 Account &acc; 1672 1689 pjsua_call_id id; 1673 1690 Token userData; 1691 std::vector<Media *> medias; 1674 1692 }; 1675 1693 -
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/media.hpp
r4663 r4666 142 142 virtual ~Media(); 143 143 144 /** 145 * Get type of the media. 146 * 147 * @return The media type. 148 */ 149 pjmedia_type getType() const; 150 144 151 protected: 145 152 /** 146 153 * Constructor. 147 154 */ 148 Media(); 155 Media(pjmedia_type med_type); 156 157 private: 158 /** 159 * Media type. 160 */ 161 pjmedia_type type; 149 162 }; 150 163 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/call.cpp
r4663 r4666 19 19 #include <pjsua2/account.hpp> 20 20 #include <pjsua2/call.hpp> 21 #include <pjsua2/endpoint.hpp> 21 22 #include <pj/ctype.h> 22 23 #include "util.hpp" … … 139 140 140 141 ////////////////////////////////////////////////////////////////////////////// 142 143 /* Call Audio Media. */ 144 class CallAudioMedia : public AudioMedia 145 { 146 public: 147 /* 148 * Set the conference port identification associated with the 149 * call audio media. 150 */ 151 void setPortId(int id); 152 }; 153 154 155 void CallAudioMedia::setPortId(int id) 156 { 157 this->id = id; 158 } 141 159 142 160 CallOpParam::CallOpParam(bool useDefaultCallSetting) … … 409 427 } 410 428 429 Media *Call::getMedia(unsigned med_idx) const 430 { 431 /* Check if the media index is valid and if the media has a valid port ID */ 432 if (med_idx >= medias.size() || 433 (medias[med_idx] && medias[med_idx]->getType() == PJMEDIA_TYPE_AUDIO && 434 ((AudioMedia *)medias[med_idx])->getPortId() == PJSUA_INVALID_ID)) 435 { 436 return NULL; 437 } 438 439 return medias[med_idx]; 440 } 441 411 442 pjsip_dialog_cap_status Call::remoteHasCap(int htype, 412 443 const string &hname, … … 563 594 int Call::vidGetStreamIdx() const 564 595 { 596 #if PJSUA_HAS_VIDEO 565 597 return pjsua_call_get_vid_stream_idx(id); 598 #else 599 return PJSUA_INVALID_ID; 600 #endif 566 601 } 567 602 568 603 bool Call::vidStreamIsRunning(int med_idx, pjmedia_dir dir) const 569 604 { 605 #if PJSUA_HAS_VIDEO 570 606 return pjsua_call_vid_stream_is_running(id, med_idx, dir); 607 #else 608 return false; 609 #endif 571 610 } 572 611 … … 574 613 const CallVidSetStreamParam ¶m) throw(Error) 575 614 { 615 #if PJSUA_HAS_VIDEO 576 616 pjsua_call_vid_strm_op_param prm; 577 617 … … 580 620 prm.cap_dev = param.capDev; 581 621 PJSUA2_CHECK_EXPR( pjsua_call_set_vid_strm(id, op, &prm) ); 622 #else 623 PJSUA2_RAISE_ERROR(PJ_EINVOP); 624 #endif 582 625 } 583 626 … … 613 656 return mti; 614 657 } 658 659 void Call::processMediaUpdate(OnCallMediaStateParam &prm) 660 { 661 pjsua_call_info pj_ci; 662 unsigned mi; 663 664 if (pjsua_call_get_info(id, &pj_ci) == PJ_SUCCESS) { 665 for (mi = 0; mi < pj_ci.media_cnt; mi++) { 666 if (mi >= medias.size()) { 667 if (pj_ci.media[mi].type == PJMEDIA_TYPE_AUDIO) { 668 medias.push_back(new CallAudioMedia); 669 } else { 670 medias.push_back(NULL); 671 } 672 } 673 674 if (pj_ci.media[mi].type == PJMEDIA_TYPE_AUDIO) { 675 CallAudioMedia *aud_med = (CallAudioMedia *)medias[mi]; 676 677 aud_med->setPortId(pj_ci.media[mi].stream.aud.conf_slot); 678 /* Add media if the conference slot ID is valid. */ 679 if (pj_ci.media[mi].stream.aud.conf_slot != PJSUA_INVALID_ID) 680 { 681 Endpoint::instance().addMedia((AudioMedia &)*aud_med); 682 } else { 683 Endpoint::instance().removeMedia((AudioMedia &)*aud_med); 684 } 685 } 686 } 687 } 688 689 /* Call media state callback. */ 690 onCallMediaState(prm); 691 } 692 693 void Call::processStateChange(OnCallStateParam &prm) 694 { 695 pjsua_call_info pj_ci; 696 unsigned mi; 697 698 if (pjsua_call_get_info(id, &pj_ci) == PJ_SUCCESS && 699 pj_ci.state == PJSIP_INV_STATE_DISCONNECTED) 700 { 701 /* Clear medias. */ 702 for (mi = 0; mi < medias.size(); mi++) { 703 if (medias[mi]) 704 delete medias[mi]; 705 } 706 medias.clear(); 707 } 708 709 onCallState(prm); 710 /* If the state is DISCONNECTED, this call may have already been deleted 711 * by the application in the callback, so do not access it anymore here. 712 */ 713 } -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp
r4663 r4666 709 709 prm.e.fromPj(*e); 710 710 711 call-> onCallState(prm);711 call->processStateChange(prm); 712 712 /* If the state is DISCONNECTED, call may have already been deleted 713 713 * by the application in the callback, so do not access it anymore here. … … 736 736 return; 737 737 } 738 738 739 739 OnCallMediaStateParam prm; 740 call-> onCallMediaState(prm);740 call->processMediaUpdate(prm); 741 741 } 742 742 -
pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/media.cpp
r4662 r4666 56 56 } 57 57 /////////////////////////////////////////////////////////////////////////////// 58 Media::Media() 58 Media::Media(pjmedia_type med_type) 59 : type(med_type) 59 60 { 60 61 … … 66 67 } 67 68 69 pjmedia_type Media::getType() const 70 { 71 return type; 72 } 73 68 74 /////////////////////////////////////////////////////////////////////////////// 69 75 AudioMedia::AudioMedia() 70 : id(PJSUA_INVALID_ID), mediaPool(NULL)76 : Media(PJMEDIA_TYPE_AUDIO), id(PJSUA_INVALID_ID), mediaPool(NULL) 71 77 { 72 78
Note: See TracChangeset
for help on using the changeset viewer.