Changeset 5969
- Timestamp:
- Apr 15, 2019 10:52:16 AM (6 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/swig/java/android/app/src/main/java/org/pjsip/pjsua2/app/MyApp.java
r5952 r5969 98 98 pjsua_call_media_status.PJSUA_CALL_MEDIA_REMOTE_HOLD)) 99 99 { 100 // unfortunately, on Java too, the returned Media cannot be101 // downcasted to AudioMedia102 Media m = getMedia(i);103 AudioMedia am = AudioMedia.typecastFromMedia(m);104 105 100 // connect ports 106 101 try { 102 AudioMedia am = getAudioMedia(i); 107 103 MyApp.ep.audDevManager().getCaptureDevMedia(). 108 104 startTransmit(am); … … 110 106 getPlaybackDevMedia()); 111 107 } catch (Exception e) { 108 System.out.println("Failed connecting media ports" + 109 e.getMessage()); 112 110 continue; 113 111 } -
pjproject/trunk/pjsip-apps/src/swig/pjsua2.i
r5775 r5969 106 106 %template(SipMultipartPartVector) std::vector<pj::SipMultipartPart>; 107 107 %template(BuddyVector) std::vector<pj::Buddy*>; 108 %template(BuddyVector2) std::vector<pj::Buddy>; 108 109 %template(AudioMediaVector) std::vector<pj::AudioMedia*>; 110 %template(AudioMediaVector2) std::vector<pj::AudioMedia>; 109 111 %template(ToneDescVector) std::vector<pj::ToneDesc>; 110 112 %template(ToneDigitVector) std::vector<pj::ToneDigit>; 111 113 %template(ToneDigitMapVector) std::vector<pj::ToneDigitMapDigit>; 112 %template(MediaFormatVector) std::vector<pj::MediaFormat*>;113 114 %template(AudioDevInfoVector) std::vector<pj::AudioDevInfo*>; 115 %template(AudioDevInfoVector2) std::vector<pj::AudioDevInfo>; 114 116 %template(CodecInfoVector) std::vector<pj::CodecInfo*>; 117 %template(CodecInfoVector2) std::vector<pj::CodecInfo>; 115 118 %template(VideoDevInfoVector) std::vector<pj::VideoDevInfo*>; 119 %template(VideoDevInfoVector2) std::vector<pj::VideoDevInfo>; 116 120 %template(CodecFmtpVector) std::vector<pj::CodecFmtp>; 121 %template(MediaFormatAudioVector) std::vector<pj::MediaFormatAudio>; 122 %template(MediaFormatVideoVector) std::vector<pj::MediaFormatVideo>; 123 %template(CallMediaInfoVector) std::vector<pj::CallMediaInfo>; 124 %template(RtcpFbCapVector) std::vector<pj::RtcpFbCap>; 125 %template(SslCertNameVector) std::vector<pj::SslCertName>; 117 126 118 127 %ignore pj::WindowHandle::display; … … 145 154 %include "pjsua2/call.hpp" 146 155 147 %template(CallMediaInfoVector) std::vector<pj::CallMediaInfo>;148 149 156 %ignore pj::JsonDocument::allocElement; 150 157 %ignore pj::JsonDocument::getPool; -
pjproject/trunk/pjsip/include/pjsua2/account.hpp
r5820 r5969 1649 1649 * and delete the corresponding account in the PJSUA-LIB. 1650 1650 * 1651 * Note that application must delete all Buddy instances belong to this 1652 * account before shutting down the account. 1653 * 1651 1654 * If application implements a derived class, the derived class should 1652 1655 * call this method in the beginning stage in its destructor, or … … 1760 1763 1761 1764 /** 1765 * Warning: deprecated, use enumBuddies2() instead. This function is not 1766 * safe in multithreaded environment. 1767 * 1762 1768 * Enumerate all buddies of the account. 1763 1769 * … … 1767 1773 1768 1774 /** 1775 * Enumerate all buddies of the account. 1776 * 1777 * @return The buddy list. 1778 */ 1779 BuddyVector2 enumBuddies2() const throw(Error); 1780 1781 /** 1782 * Warning: deprecated, use findBuddy2 instead. This function is not 1783 * safe in multithreaded environment. 1784 * 1769 1785 * Find a buddy in the buddy list with the specified URI. 1770 1786 * … … 1778 1794 Buddy* findBuddy(string uri, FindBuddyMatch *buddy_match = NULL) const 1779 1795 throw(Error); 1796 1797 /** 1798 * Find a buddy in the buddy list with the specified URI. 1799 * 1800 * Exception: if buddy is not found, PJ_ENOTFOUND will be thrown. 1801 * 1802 * @param uri The buddy URI. 1803 * 1804 * @return The pointer to buddy. 1805 */ 1806 Buddy findBuddy2(string uri) const throw(Error); 1780 1807 1781 1808 public: -
pjproject/trunk/pjsip/include/pjsua2/call.hpp
r5923 r5969 312 312 * Default constructor initializes with empty or default values. 313 313 */ 314 CallSetting( pj_bool_tuseDefaultValues = false);314 CallSetting(bool useDefaultValues = false); 315 315 316 316 /** … … 1010 1010 * which are going to be used. 1011 1011 */ 1012 vector<SrtpCrypto>cryptos;1012 SrtpCryptoVector cryptos; 1013 1013 }; 1014 1014 … … 1236 1236 1237 1237 /** 1238 * Warning: deprecated, use getAudioMedia() instead. This function is not 1239 * safe in multithreaded environment. 1240 * 1238 1241 * Get media for the specified media index. 1239 1242 * … … 1243 1246 */ 1244 1247 Media *getMedia(unsigned med_idx) const; 1248 1249 /** 1250 * Get audio media for the specified media index. If the specified media 1251 * index is not audio or invalid or inactive, exception will be thrown. 1252 * 1253 * @param med_idx Media index. 1254 * 1255 * @return The audio media. 1256 */ 1257 AudioMedia getAudioMedia(unsigned med_idx) const throw(Error); 1245 1258 1246 1259 /** -
pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp
r5964 r5969 133 133 }; 134 134 135 /** Array of SSL certificate type and name. */ 136 typedef std::vector<SslCertName> SslCertNameVector; 137 135 138 /** 136 139 * SSL certificate information. … … 156 159 date/time use GMT */ 157 160 158 vector<SslCertName>subjectAltName; /**< Subject alternative161 SslCertNameVector subjectAltName; /**< Subject alternative 159 162 name extension */ 160 163 … … 1379 1382 1380 1383 /** 1384 * Warning: deprecated, use mediaEnumPorts2() instead. This function is 1385 * not safe in multithreaded environment. 1386 * 1381 1387 * Enumerate all media port. 1382 1388 * … … 1384 1390 */ 1385 1391 const AudioMediaVector &mediaEnumPorts() const throw(Error); 1392 1393 /** 1394 * Enumerate all audio media port. 1395 * 1396 * @return The list of audio media port. 1397 */ 1398 AudioMediaVector2 mediaEnumPorts2() const throw(Error); 1386 1399 1387 1400 /** … … 1404 1417 1405 1418 /** 1419 * Warning: deprecated, use codecEnum2() instead. This function is not 1420 * safe in multithreaded environment. 1421 * 1406 1422 * Enum all supported codecs in the system. 1407 1423 * … … 1409 1425 */ 1410 1426 const CodecInfoVector &codecEnum() throw(Error); 1427 1428 /** 1429 * Enum all supported codecs in the system. 1430 * 1431 * @return Array of codec info. 1432 */ 1433 CodecInfoVector2 codecEnum2() const throw(Error); 1411 1434 1412 1435 /** … … 1445 1468 1446 1469 /** 1470 * Warning: deprecated, use videoCodecEnum2() instead. This function is 1471 * not safe in multithreaded environment. 1472 * 1447 1473 * Enum all supported video codecs in the system. 1448 1474 * … … 1450 1476 */ 1451 1477 const CodecInfoVector &videoCodecEnum() throw(Error); 1478 1479 /** 1480 * Enum all supported video codecs in the system. 1481 * 1482 * @return Array of video codec info. 1483 */ 1484 CodecInfoVector2 videoCodecEnum2() const throw(Error); 1452 1485 1453 1486 /** -
pjproject/trunk/pjsip/include/pjsua2/media.hpp
r5956 r5969 214 214 215 215 /** 216 * Audio Media. 216 * Audio Media. This is a lite wrapper class for audio conference bridge port, 217 * i.e: this class only maintains one data member, conference slot ID, and 218 * the methods are simply proxies for conference bridge operations. 219 * 220 * Application can create a derived class and use registerMediaPort2()/ 221 * unregisterMediaPort() to register/unregister a media port to/from the 222 * conference bridge. 223 * 224 * The library will not keep a list of AudioMedia instances, so any 225 * AudioMedia (descendant) instances instantiated by application must be 226 * maintained and destroyed by the application itself. 227 * 228 * Note that any PJSUA2 APIs that return AudioMedia instance(s) such as 229 * Endpoint::mediaEnumPorts2() or Call::getAudioMedia() will just return 230 * generated copy. All AudioMedia methods should work normally on this 231 * generated copy instance. 217 232 */ 218 233 class AudioMedia : public Media … … 321 336 322 337 /** 338 * Warning: deprecated and will be removed in future release. 339 * 323 340 * Typecast from base class Media. This is useful for application written 324 341 * in language that does not support downcasting such as Python. … … 331 348 332 349 /** 333 * Virtual Destructor 350 * Default Constructor. Normally application will not create AudioMedia 351 * object directly, but it may instantiate an AudioMedia derived class. 352 */ 353 AudioMedia(); 354 355 /** 356 * Virtual Destructor. 334 357 */ 335 358 virtual ~AudioMedia(); … … 343 366 protected: 344 367 /** 345 * Default Constructor. 346 */ 347 AudioMedia(); 348 349 /** 368 * Warning: deprecated and will be removed in future release, use 369 * registerMediaPort2() instead. 370 * 350 371 * This method needs to be called by descendants of this class to register 351 372 * the media port created to the conference bridge and Endpoint's 352 373 * media list. 353 374 * 354 * param port the media port to be registered to the conference bridge.375 * param port The media port to be registered to the conference bridge. 355 376 * 356 377 */ 357 378 void registerMediaPort(MediaPort port) throw(Error); 379 380 /** 381 * This method needs to be called by descendants of this class to register 382 * the media port created to the conference bridge and Endpoint's 383 * media list. 384 * 385 * param port The media port to be registered to the conference bridge. 386 * param pool The memory pool. 387 * 388 */ 389 void registerMediaPort2(MediaPort port, pj_pool_t *pool) throw(Error); 358 390 359 391 /** … … 366 398 367 399 private: 400 /* Memory pool for deprecated registerMediaPort() */ 368 401 pj_caching_pool mediaCachingPool; 369 402 pj_pool_t *mediaPool; 370 }; 403 404 friend class Endpoint; 405 }; 406 407 /** 408 * Warning: deprecated, use AudioMediaVector2 instead. 409 * 410 * Array of Audio Media. 411 */ 412 typedef std::vector<AudioMedia*> AudioMediaVector; 413 371 414 372 415 /** Array of Audio Media */ 373 typedef std::vector<AudioMedia *> AudioMediaVector;416 typedef std::vector<AudioMedia> AudioMediaVector2; 374 417 375 418 /** … … 465 508 466 509 /** 510 * Warning: deprecated and will be removed in future release. 511 * 467 512 * Typecast from base class AudioMedia. This is useful for application 468 513 * written in language that does not support downcasting such as Python. … … 475 520 476 521 /** 477 * Destructor. 522 * Destructor. This will unregister the player port from the conference 523 * bridge. 478 524 */ 479 525 virtual ~AudioMediaPlayer(); … … 546 592 void createRecorder(const string &file_name, 547 593 unsigned enc_type=0, 548 pj_ssize_tmax_size=0,594 long max_size=0, 549 595 unsigned options=0) throw(Error); 550 596 551 597 /** 598 * Warning: deprecated and will be removed in future release. 599 * 552 600 * Typecast from base class AudioMedia. This is useful for application 553 601 * written in language that does not support downcasting such as Python. … … 560 608 561 609 /** 562 * Destructor. 610 * Destructor. This will unregister the recorder port from the conference 611 * bridge. 563 612 */ 564 613 virtual ~AudioMediaRecorder(); … … 635 684 636 685 /** 637 * Destructor. 686 * Destructor. This will unregister the tone generator port from the 687 * conference bridge. 638 688 */ 639 689 ~ToneGenerator(); 640 690 641 691 /** 642 * Create tone generator .692 * Create tone generator and register the port to the conference bridge. 643 693 */ 644 694 void createToneGenerator(unsigned clock_rate = 16000, … … 776 826 }; 777 827 828 /** 829 * Warning: deprecated, use AudioDevInfoVector2 instead. 830 * 831 * Array of audio device info. 832 */ 833 typedef std::vector<AudioDevInfo*> AudioDevInfoVector; 834 778 835 /** Array of audio device info */ 779 typedef std::vector<AudioDevInfo *> AudioDevInfoVector;836 typedef std::vector<AudioDevInfo> AudioDevInfoVector2; 780 837 781 838 /** … … 836 893 837 894 /** 895 * Warning: deprecated, use enumDev2 instead. This function is not 896 * safe in multithreaded environment. 897 * 898 * Enum all audio devices installed in the system. This function is not 899 * safe in multithreaded environment. 900 * 901 * @return The list of audio device info. 902 */ 903 const AudioDevInfoVector &enumDev() throw(Error); 904 905 /** 838 906 * Enum all audio devices installed in the system. 839 907 * 840 908 * @return The list of audio device info. 841 909 */ 842 const AudioDevInfoVector &enumDev()throw(Error);910 AudioDevInfoVector2 enumDev2() const throw(Error); 843 911 844 912 /** … … 1417 1485 public: 1418 1486 /** 1419 * Constructor 1487 * Constructor. 1420 1488 * 1421 1489 * @param playdev Playback device ID. … … 1425 1493 1426 1494 /** 1427 * Destructor 1495 * Destructor. 1428 1496 */ 1429 1497 virtual ~ExtraAudioDevice(); … … 1432 1500 * Open the audio device using format (e.g.: clock rate, bit per sample, 1433 1501 * samples per frame) matched to the conference bridge's format, except 1434 * the channel count, which will be set to one (mono channel). 1502 * the channel count, which will be set to one (mono channel). This will 1503 * also register the audio device port to conference bridge. 1435 1504 */ 1436 1505 void open(); 1437 1506 1438 1507 /** 1439 * Close the audio device. 1508 * Close the audio device and unregister the audio device port from the 1509 * conference bridge. 1440 1510 */ 1441 1511 void close(); … … 1766 1836 }; 1767 1837 1838 /** 1839 * Warning: deprecated, use VideoDevInfoVector2 instead. 1840 * 1841 * Array of video device info. 1842 */ 1843 typedef std::vector<VideoDevInfo*> VideoDevInfoVector; 1844 1768 1845 /** Array of video device info */ 1769 typedef std::vector<VideoDevInfo *> VideoDevInfoVector;1846 typedef std::vector<VideoDevInfo> VideoDevInfoVector2; 1770 1847 1771 1848 /** … … 1813 1890 1814 1891 /** 1892 * Warning: deprecated, use enumDev2() instead. This function is not 1893 * safe in multithreaded environment. 1894 * 1815 1895 * Enum all video devices installed in the system. 1816 1896 * … … 1818 1898 */ 1819 1899 const VideoDevInfoVector &enumDev() throw(Error); 1900 1901 /** 1902 * Enum all video devices installed in the system. 1903 * 1904 * @return The list of video device info 1905 */ 1906 VideoDevInfoVector2 enumDev2() const throw(Error); 1820 1907 1821 1908 /** … … 2056 2143 }; 2057 2144 2145 /** 2146 * Warning: deprecated, use CodecInfoVector2 instead. 2147 * 2148 * Array of codec info. 2149 */ 2150 typedef std::vector<CodecInfo*> CodecInfoVector; 2151 2058 2152 /** Array of codec info */ 2059 typedef std::vector<CodecInfo *> CodecInfoVector;2153 typedef std::vector<CodecInfo> CodecInfoVector2; 2060 2154 2061 2155 /** -
pjproject/trunk/pjsip/include/pjsua2/presence.hpp
r5672 r5969 169 169 */ 170 170 PresenceStatus presStatus; 171 171 172 172 public: 173 173 /** Import from pjsip structure */ … … 189 189 190 190 /** 191 * Buddy. 191 * Buddy. This is a lite wrapper class for PJSUA-LIB buddy, i.e: this class 192 * only maintains one data member, PJSUA-LIB buddy ID, and the methods are 193 * simply proxies for PJSUA-LIB buddy operations. 194 * 195 * Application can use create() to register a buddy to PJSUA-LIB, and 196 * the destructor of the original instance (i.e: the instance that calls 197 * create()) will unregister and delete the buddy from PJSUA-LIB. Application 198 * must delete all Buddy instances belong to an account before shutting down 199 * the account (via Account::shutdown()). 200 * 201 * The library will not keep a list of Buddy instances, so any Buddy (or 202 * descendant) instances instantiated by application must be maintained 203 * and destroyed by the application itself. Any PJSUA2 APIs that return Buddy 204 * instance(s) such as Account::enumBuddies2() or Account::findBuddy2() will 205 * just return generated copy. All Buddy methods should work normally on this 206 * generated copy instance. 192 207 */ 193 208 class Buddy … … 200 215 201 216 /** 202 * Destructor. Note that if the Buddy instance is deleted, it will also 203 * delete the corresponding buddy in the PJSUA-LIB. 217 * Destructor. Note that if the Buddy original instance (i.e: the instance 218 * that calls Buddy::create()) is destroyed, it will also delete the 219 * corresponding buddy in the PJSUA-LIB. While the destructor of 220 * a generated copy (i.e: Buddy instance returned by PJSUA2 APIs such as 221 * Account::enumBuddies2() or Account::findBuddy2()) will do nothing. 204 222 */ 205 223 virtual ~Buddy(); … … 207 225 /** 208 226 * Create buddy and register the buddy to PJSUA-LIB. 227 * 228 * Note that application should maintain the Buddy original instance, i.e: 229 * the instance that calls this create() method as it is only the original 230 * instance destructor that will delete the underlying Buddy in PJSUA-LIB. 209 231 * 210 232 * @param acc The account for this buddy. … … 298 320 * Buddy ID. 299 321 */ 300 pjsua_buddy_id id; 301 302 /** 303 * Account. 304 */ 305 Account *acc; 306 }; 307 322 pjsua_buddy_id id; 323 324 private: 325 friend class Endpoint; 326 friend class Account; 327 328 /* Internal constructor/methods used by Endpoint and Account */ 329 Buddy(pjsua_buddy_id buddy_id); 330 Buddy *getOriginalInstance(); 331 }; 332 333 334 /** 335 * Warning: deprecated, use BuddyVector2 instead. 336 * 337 * Array of buddies. 338 */ 339 typedef std::vector<Buddy*> BuddyVector; 308 340 309 341 /** Array of buddies */ 310 typedef std::vector<Buddy *> BuddyVector;342 typedef std::vector<Buddy> BuddyVector2; 311 343 312 344 -
pjproject/trunk/pjsip/src/pjsua2/account.cpp
r5837 r5969 1029 1029 } 1030 1030 1031 BuddyVector2 Account::enumBuddies2() const throw(Error) 1032 { 1033 BuddyVector2 bv2; 1034 pjsua_buddy_id ids[PJSUA_MAX_BUDDIES]; 1035 unsigned i, count = PJSUA_MAX_BUDDIES; 1036 1037 PJSUA2_CHECK_EXPR( pjsua_enum_buddies(ids, &count) ); 1038 for (i = 0; i < count; ++i) { 1039 bv2.push_back(Buddy(ids[i])); 1040 } 1041 1042 return bv2; 1043 } 1044 1031 1045 Buddy* Account::findBuddy(string uri, FindBuddyMatch *buddy_match) const 1032 1046 throw(Error) … … 1042 1056 } 1043 1057 PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 1058 } 1059 1060 Buddy Account::findBuddy2(string uri) const throw(Error) 1061 { 1062 pj_str_t pj_uri; 1063 pjsua_buddy_id id; 1064 1065 pj_strset2(&pj_uri, (char*)uri.c_str()); 1066 1067 id = pjsua_buddy_find(&pj_uri); 1068 if (id == PJSUA_INVALID_ID) { 1069 PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 1070 } 1071 1072 Buddy buddy(id); 1073 return buddy; 1044 1074 } 1045 1075 -
pjproject/trunk/pjsip/src/pjsua2/call.cpp
r5923 r5969 228 228 } 229 229 230 CallSetting::CallSetting( pj_bool_tuseDefaultValues)230 CallSetting::CallSetting(bool useDefaultValues) 231 231 { 232 232 if (useDefaultValues) { … … 522 522 } 523 523 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; 535 } 536 524 537 pjsip_dialog_cap_status Call::remoteHasCap(int htype, 525 538 const string &hname, -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5964 r5969 978 978 void Endpoint::on_buddy_state(pjsua_buddy_id buddy_id) 979 979 { 980 Buddy *buddy = (Buddy*)pjsua_buddy_get_user_data(buddy_id); 980 Buddy b(buddy_id); 981 Buddy *buddy = b.getOriginalInstance(); 981 982 if (!buddy || !buddy->isValid()) { 982 983 /* Ignored */ … … 993 994 PJ_UNUSED_ARG(sub); 994 995 995 Buddy *buddy = (Buddy*)pjsua_buddy_get_user_data(buddy_id); 996 Buddy b(buddy_id); 997 Buddy *buddy = b.getOriginalInstance(); 996 998 if (!buddy || !buddy->isValid()) { 997 999 /* Ignored */ … … 2045 2047 } 2046 2048 2049 AudioMediaVector2 Endpoint::mediaEnumPorts2() const throw(Error) 2050 { 2051 AudioMediaVector2 amv2; 2052 pjsua_conf_port_id ids[PJSUA_MAX_CONF_PORTS]; 2053 unsigned i, count = PJSUA_MAX_CONF_PORTS; 2054 2055 PJSUA2_CHECK_EXPR( pjsua_enum_conf_ports(ids, &count) ); 2056 for (i = 0; i < count; ++i) { 2057 AudioMedia am; 2058 am.id = ids[i]; 2059 amv2.push_back(am); 2060 } 2061 2062 return amv2; 2063 } 2064 2047 2065 void Endpoint::mediaAdd(AudioMedia &media) 2048 2066 { 2067 /* mediaList serves mediaEnumPorts() only, once mediaEnumPorts() 2068 * is removed, this function implementation should be no-op. 2069 */ 2049 2070 pj_mutex_lock(mediaListMutex); 2050 2071 … … 2060 2081 void Endpoint::mediaRemove(AudioMedia &media) 2061 2082 { 2083 /* mediaList serves mediaEnumPorts() only, once mediaEnumPorts() 2084 * is removed, this function implementation should be no-op. 2085 */ 2062 2086 pj_mutex_lock(mediaListMutex); 2063 2087 AudioMediaVector::iterator it = std::find(mediaList.begin(), … … 2067 2091 if (it != mediaList.end()) 2068 2092 mediaList.erase(it); 2069 2070 2093 pj_mutex_unlock(mediaListMutex); 2071 2094 } … … 2073 2096 bool Endpoint::mediaExists(const AudioMedia &media) const 2074 2097 { 2075 bool exists; 2076 2077 pj_mutex_lock(mediaListMutex); 2078 AudioMediaVector::const_iterator it = std::find(mediaList.begin(), 2079 mediaList.end(), 2080 &media); 2081 exists = (it != mediaList.end()); 2082 pj_mutex_unlock(mediaListMutex); 2083 return exists; 2098 pjsua_conf_port_id id = media.getPortId(); 2099 if (id == PJSUA_INVALID_ID || id >= (int)mediaMaxPorts()) 2100 return false; 2101 2102 pjsua_conf_port_info pi; 2103 return (pjsua_conf_get_port_info(id, &pi) == PJ_SUCCESS); 2084 2104 } 2085 2105 … … 2108 2128 } 2109 2129 2130 CodecInfoVector2 Endpoint::codecEnum2() const throw(Error) 2131 { 2132 CodecInfoVector2 civ2; 2133 pjsua_codec_info pj_codec[MAX_CODEC_NUM]; 2134 unsigned count = MAX_CODEC_NUM; 2135 2136 PJSUA2_CHECK_EXPR( pjsua_enum_codecs(pj_codec, &count) ); 2137 for (unsigned i = 0; i<count; ++i) { 2138 CodecInfo codec_info; 2139 codec_info.fromPj(pj_codec[i]); 2140 civ2.push_back(codec_info); 2141 } 2142 return civ2; 2143 } 2144 2110 2145 void Endpoint::codecSetPriority(const string &codec_id, 2111 2146 pj_uint8_t priority) throw(Error) … … 2169 2204 #endif 2170 2205 return videoCodecInfoList; 2206 } 2207 2208 CodecInfoVector2 Endpoint::videoCodecEnum2() const throw(Error) 2209 { 2210 CodecInfoVector2 civ2; 2211 #if PJSUA_HAS_VIDEO 2212 pjsua_codec_info pj_codec[MAX_CODEC_NUM]; 2213 unsigned count = MAX_CODEC_NUM; 2214 2215 PJSUA2_CHECK_EXPR(pjsua_vid_enum_codecs(pj_codec, &count)); 2216 for (unsigned i = 0; i<count; ++i) { 2217 CodecInfo codec_info; 2218 codec_info.fromPj(pj_codec[i]); 2219 civ2.push_back(codec_info); 2220 } 2221 #endif 2222 return civ2; 2171 2223 } 2172 2224 -
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r5956 r5969 158 158 } 159 159 160 void AudioMedia::registerMediaPort2(MediaPort port, pj_pool_t *pool) 161 throw(Error) 162 { 163 /* Check if media already added to Conf bridge. */ 164 pj_assert(!Endpoint::instance().mediaExists(*this)); 165 166 if (port != NULL) { 167 pj_assert(id == PJSUA_INVALID_ID); 168 pj_assert(pool); 169 170 PJSUA2_CHECK_EXPR( pjsua_conf_add_port(pool, 171 (pjmedia_port *)port, 172 &id) ); 173 } 174 175 Endpoint::instance().mediaAdd(*this); 176 } 177 160 178 void AudioMedia::unregisterMediaPort() 161 179 { … … 176 194 AudioMedia::~AudioMedia() 177 195 { 178 unregisterMediaPort();179 196 } 180 197 … … 409 426 void AudioMediaRecorder::createRecorder(const string &file_name, 410 427 unsigned enc_type, 411 pj_ssize_tmax_size,428 long max_size, 412 429 unsigned options) 413 430 throw(Error) … … 481 498 } 482 499 483 registerMediaPort (tonegen);500 registerMediaPort2(tonegen, pool); 484 501 } 485 502 … … 746 763 pj_leave_critical_section(); 747 764 return audioDevList; 765 } 766 767 AudioDevInfoVector2 AudDevManager::enumDev2() const throw(Error) 768 { 769 pjmedia_aud_dev_info pj_info[MAX_DEV_COUNT]; 770 unsigned count = MAX_DEV_COUNT; 771 AudioDevInfoVector2 adiv2; 772 773 PJSUA2_CHECK_EXPR( pjsua_enum_aud_devs(pj_info, &count) ); 774 775 for (unsigned i = 0; i<count ;++i) { 776 AudioDevInfo di; 777 di.fromPj(pj_info[i]); 778 adiv2.push_back(di); 779 } 780 781 return adiv2; 748 782 } 749 783 … … 1427 1461 } 1428 1462 1463 VideoDevInfoVector2 VidDevManager::enumDev2() const throw(Error) 1464 { 1465 VideoDevInfoVector2 vdiv2; 1466 #if PJSUA_HAS_VIDEO 1467 pjmedia_vid_dev_info pj_info[MAX_DEV_COUNT]; 1468 unsigned count = MAX_DEV_COUNT; 1469 1470 PJSUA2_CHECK_EXPR(pjsua_vid_enum_devs(pj_info, &count)); 1471 1472 for (unsigned i = 0; i<count;++i) { 1473 VideoDevInfo vdi; 1474 vdi.fromPj(pj_info[i]); 1475 vdiv2.push_back(vdi); 1476 } 1477 #endif 1478 return vdiv2; 1479 } 1480 1429 1481 int VidDevManager::lookupDev(const string &drv_name, 1430 1482 const string &dev_name) const throw(Error) -
pjproject/trunk/pjsip/src/pjsua2/presence.cpp
r4704 r5969 74 74 75 75 ////////////////////////////////////////////////////////////////////////////// 76 typedef struct BuddyUserData 77 { 78 Buddy *self; 79 Account *acc; 80 } BuddyUserData; 76 81 77 82 /* … … 83 88 } 84 89 90 Buddy::Buddy(pjsua_buddy_id buddy_id) 91 : id(buddy_id) 92 { 93 } 94 95 Buddy *Buddy::getOriginalInstance() 96 { 97 BuddyUserData *bud = (BuddyUserData*)pjsua_buddy_get_user_data(id); 98 return (bud? bud->self : NULL); 99 } 100 85 101 /* 86 102 * Destructor. … … 88 104 Buddy::~Buddy() 89 105 { 90 if (isValid()) { 106 if (isValid() && getOriginalInstance()==this) { 107 Account *acc = NULL; 108 BuddyUserData *bud = (BuddyUserData*)pjsua_buddy_get_user_data(id); 109 if (bud) { 110 acc = bud->acc; 111 delete bud; 112 } 113 91 114 pjsua_buddy_set_user_data(id, NULL); 92 115 pjsua_buddy_del(id); 93 116 94 117 /* Remove from account buddy list */ 95 acc->removeBuddy(this); 118 if (acc) 119 acc->removeBuddy(this); 96 120 } 97 121 } … … 108 132 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "Buddy::create()", "Invalid account"); 109 133 134 BuddyUserData *bud = new BuddyUserData(); 135 bud->self = this; 136 bud->acc = &account; 137 110 138 pj_cfg.uri = str2Pj(cfg.uri); 111 139 pj_cfg.subscribe = cfg.subscribe; 112 pj_cfg.user_data = (void*) this;140 pj_cfg.user_data = (void*)bud; 113 141 PJSUA2_CHECK_EXPR( pjsua_buddy_add(&pj_cfg, &id) ); 114 142 115 acc = &account; 116 acc->addBuddy(this); 143 account.addBuddy(this); 117 144 } 118 145 … … 161 188 { 162 189 BuddyInfo bi = getInfo(); 190 BuddyUserData *bud = (BuddyUserData*)pjsua_buddy_get_user_data(id); 191 Account *acc = bud? bud->acc : NULL; 192 193 if (!bud || !acc || !acc->isValid()) { 194 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "sendInstantMessage()", 195 "Invalid Buddy"); 196 } 163 197 164 198 pj_str_t to = str2Pj(bi.contact.empty()? bi.uri : bi.contact); … … 180 214 { 181 215 BuddyInfo bi = getInfo(); 216 BuddyUserData *bud = (BuddyUserData*)pjsua_buddy_get_user_data(id); 217 Account *acc = bud? bud->acc : NULL; 218 219 if (!bud || !acc || !acc->isValid()) { 220 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "sendInstantMessage()", 221 "Invalid Buddy"); 222 } 182 223 183 224 pj_str_t to = str2Pj(bi.contact.empty()? bi.uri : bi.contact);
Note: See TracChangeset
for help on using the changeset viewer.