Changeset 5972
- Timestamp:
- Apr 23, 2019 10:49:56 AM (6 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/swig/pjsua2.i
r5969 r5972 109 109 %template(AudioMediaVector) std::vector<pj::AudioMedia*>; 110 110 %template(AudioMediaVector2) std::vector<pj::AudioMedia>; 111 %template(VideoMediaVector) std::vector<pj::VideoMedia>; 111 112 %template(ToneDescVector) std::vector<pj::ToneDesc>; 112 113 %template(ToneDigitVector) std::vector<pj::ToneDigit>; -
pjproject/trunk/pjsip/include/pjsua2/call.hpp
r5969 r5972 334 334 /** 335 335 * Call media information. 336 * 337 * Application can query conference bridge port of this media using 338 * Call::getAudioMedia() if the media type is audio, 339 * or Call::getEncodingVideoMedia()/Call::getDecodingVideoMedia() 340 * if the media type is video. 336 341 */ 337 342 struct CallMediaInfo … … 358 363 359 364 /** 365 * Warning: this is deprecated, application can query conference bridge 366 * port of this media using Call::getAudioMedia(). 367 * 360 368 * The conference port number for the call. Only valid if the media type 361 369 * is audio. … … 375 383 */ 376 384 VideoWindow videoWindow; 377 385 378 386 /** 379 387 * The video capture device for outgoing transmission, if any, … … 1251 1259 * index is not audio or invalid or inactive, exception will be thrown. 1252 1260 * 1253 * @param med_idx Media index. 1261 * @param med_idx Media index, or -1 to specify any first audio 1262 * media registered in the conference bridge. 1254 1263 * 1255 1264 * @return The audio media. 1256 1265 */ 1257 AudioMedia getAudioMedia(unsigned med_idx) const throw(Error); 1266 AudioMedia getAudioMedia(int med_idx) const throw(Error); 1267 1268 /** 1269 * Get video media in encoding direction for the specified media index. 1270 * If the specified media index is not video or invalid or the direction 1271 * is receive only, exception will be thrown. 1272 * 1273 * @param med_idx Media index, or -1 to specify any first video 1274 * media with encoding direction registered in the 1275 * conference bridge. 1276 * 1277 * @return The video media. 1278 */ 1279 VideoMedia getEncodingVideoMedia(int med_idx) const throw(Error); 1280 1281 /** 1282 * Get video media in decoding direction for the specified media index. 1283 * If the specified media index is not video or invalid or the direction 1284 * is send only, exception will be thrown. 1285 * 1286 * @param med_idx Media index, or -1 to specify any first video 1287 * media with decoding direction registered in the 1288 * conference bridge. 1289 * 1290 * @return The video media. 1291 */ 1292 VideoMedia getDecodingVideoMedia(int med_idx) const throw(Error); 1258 1293 1259 1294 /** -
pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp
r5969 r5972 1397 1397 */ 1398 1398 AudioMediaVector2 mediaEnumPorts2() const throw(Error); 1399 1400 /** 1401 * Enumerate all video media port. 1402 * 1403 * @return The list of video media port. 1404 */ 1405 VideoMediaVector mediaEnumVidPorts() const throw(Error); 1399 1406 1400 1407 /** -
pjproject/trunk/pjsip/include/pjsua2/media.hpp
r5969 r5972 149 149 /** 150 150 * Array of listeners (in other words, ports where this port is 151 * transmitting to .151 * transmitting to). 152 152 */ 153 153 IntVector listeners; … … 196 196 }; 197 197 198 /** 199 * Parameters for AudioMedia::startTransmit2() method. 200 */ 198 201 struct AudioMediaTransmitParam 199 202 { … … 348 351 349 352 /** 350 * Default Constructor. Normally application will not create AudioMedia 351 * object directly, but it may instantiate an AudioMedia derived class. 353 * Default Constructor. 354 * 355 * Normally application will not create AudioMedia object directly, 356 * but it instantiates an AudioMedia derived class. This is set as public 357 * because some STL vector implementations require it. 352 358 */ 353 359 AudioMedia(); … … 401 407 pj_caching_pool mediaCachingPool; 402 408 pj_pool_t *mediaPool; 403 404 friend class Endpoint;405 409 }; 406 410 … … 1547 1551 }; 1548 1552 1553 1554 /** 1555 * This structure descibes information about a particular media port that 1556 * has been registered into the conference bridge. 1557 */ 1558 struct VidConfPortInfo 1559 { 1560 /** 1561 * Conference port number. 1562 */ 1563 int portId; 1564 1565 /** 1566 * Port name. 1567 */ 1568 string name; 1569 1570 /** 1571 * Media audio format information 1572 */ 1573 MediaFormatVideo format; 1574 1575 /** 1576 * Array of listeners (in other words, ports where this port is 1577 * transmitting to). 1578 */ 1579 IntVector listeners; 1580 1581 /** 1582 * Array of listeners (in other words, ports where this port is 1583 * listening to). 1584 */ 1585 IntVector transmitters; 1586 1587 public: 1588 /** 1589 * Construct from pjsua_conf_port_info. 1590 */ 1591 void fromPj(const pjsua_vid_conf_port_info &port_info); 1592 }; 1593 1594 /** 1595 * Parameters for VideoMedia::startTransmit() method. 1596 */ 1597 struct VideoMediaTransmitParam 1598 { 1599 }; 1600 1601 /** 1602 * Video Media. 1603 */ 1604 class VideoMedia : public Media 1605 { 1606 public: 1607 /** 1608 * Get information about the specified conference port. 1609 */ 1610 VidConfPortInfo getPortInfo() const throw(Error); 1611 1612 /** 1613 * Get port Id. 1614 */ 1615 int getPortId() const; 1616 1617 /** 1618 * Get information from specific port id. 1619 */ 1620 static VidConfPortInfo getPortInfoFromId(int port_id) throw(Error); 1621 1622 /** 1623 * Establish unidirectional media flow to sink. This media port 1624 * will act as a source, and it may transmit to multiple destinations/sink. 1625 * And if multiple sources are transmitting to the same sink, the media 1626 * will be mixed together. Source and sink may refer to the same Media, 1627 * effectively looping the media. 1628 * 1629 * If bidirectional media flow is desired, application needs to call 1630 * this method twice, with the second one called from the opposite source 1631 * media. 1632 * 1633 * @param sink The destination Media. 1634 * @param param The parameter. 1635 */ 1636 void startTransmit(const VideoMedia &sink, 1637 const VideoMediaTransmitParam ¶m) const 1638 throw(Error); 1639 1640 /** 1641 * Stop media flow to destination/sink port. 1642 * 1643 * @param sink The destination media. 1644 * 1645 */ 1646 void stopTransmit(const VideoMedia &sink) const throw(Error); 1647 1648 /** 1649 * Default Constructor. 1650 * 1651 * Normally application will not create VideoMedia object directly, 1652 * but it instantiates a VideoMedia derived class. This is set as public 1653 * because some STL vector implementations require it. 1654 */ 1655 VideoMedia(); 1656 1657 /** 1658 * Virtual Destructor 1659 */ 1660 virtual ~VideoMedia(); 1661 1662 protected: 1663 /** 1664 * Conference port Id. 1665 */ 1666 int id; 1667 1668 protected: 1669 /** 1670 * This method needs to be called by descendants of this class to register 1671 * the media port created to the conference bridge and Endpoint's 1672 * media list. 1673 * 1674 * param port The media port to be registered to the conference bridge. 1675 * param pool The memory pool. 1676 */ 1677 void registerMediaPort(MediaPort port, pj_pool_t *pool) throw(Error); 1678 1679 /** 1680 * This method needs to be called by descendants of this class to remove 1681 * the media port from the conference bridge and Endpoint's media list. 1682 * Descendant should only call this method if it has registered the media 1683 * with the previous call to registerMediaPort(). 1684 */ 1685 void unregisterMediaPort(); 1686 }; 1687 1688 /** Array of Video Media */ 1689 typedef std::vector<VideoMedia> VideoMediaVector; 1690 1691 1549 1692 /** 1550 1693 * Window handle. … … 1628 1771 */ 1629 1772 VideoWindowInfo getInfo() const throw(Error); 1773 1774 /** 1775 * Get video media or conference bridge port of the renderer of 1776 * this video window. 1777 * 1778 * @return Video media of this renderer window. 1779 */ 1780 VideoMedia getVideoMedia() throw(Error); 1630 1781 1631 1782 /** … … 1781 1932 */ 1782 1933 VideoWindow getVideoWindow(); 1934 1935 /** 1936 * Get video media or conference bridge port of the video capture device. 1937 * 1938 * @return Video media of the video capture device. 1939 */ 1940 VideoMedia getVideoMedia() throw(Error); 1783 1941 1784 1942 private: -
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 } -
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r5969 r5972 2055 2055 PJSUA2_CHECK_EXPR( pjsua_enum_conf_ports(ids, &count) ); 2056 2056 for (i = 0; i < count; ++i) { 2057 AudioMedia am;2058 am. id = ids[i];2057 AudioMediaHelper am; 2058 am.setPortId(ids[i]); 2059 2059 amv2.push_back(am); 2060 2060 } 2061 2061 2062 2062 return amv2; 2063 } 2064 2065 VideoMediaVector Endpoint::mediaEnumVidPorts() const throw(Error) 2066 { 2067 VideoMediaVector vmv; 2068 pjsua_conf_port_id ids[PJSUA_MAX_CONF_PORTS]; 2069 unsigned i, count = PJSUA_MAX_CONF_PORTS; 2070 2071 PJSUA2_CHECK_EXPR( pjsua_vid_conf_enum_ports(ids, &count) ); 2072 for (i = 0; i < count; ++i) { 2073 VideoMediaHelper vm; 2074 vm.setPortId(ids[i]); 2075 vmv.push_back(vm); 2076 } 2077 2078 return vmv; 2063 2079 } 2064 2080 -
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r5969 r5972 1195 1195 return vwi; 1196 1196 } 1197 1197 1198 VideoMedia VideoWindow::getVideoMedia() throw(Error) 1199 { 1200 #if PJSUA_HAS_VIDEO 1201 pjsua_vid_win_info pj_vwi; 1202 PJSUA2_CHECK_EXPR( pjsua_vid_win_get_info(winId, &pj_vwi) ); 1203 1204 pjsua_conf_port_id id = pj_vwi.slot_id; 1205 if (id != PJSUA_INVALID_ID) { 1206 VideoMediaHelper vm; 1207 vm.setPortId(id); 1208 return vm; 1209 } else { 1210 PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 1211 } 1212 #else 1213 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 1214 #endif 1215 } 1216 1198 1217 void VideoWindow::Show(bool show) throw(Error) 1199 1218 { … … 1333 1352 #else 1334 1353 return (VideoWindow(PJSUA_INVALID_ID)); 1354 #endif 1355 } 1356 1357 VideoMedia VideoPreview::getVideoMedia() throw(Error) 1358 { 1359 #if PJSUA_HAS_VIDEO 1360 pjsua_conf_port_id id = pjsua_vid_preview_get_vid_conf_port(devId); 1361 if (id != PJSUA_INVALID_ID) { 1362 VideoMediaHelper vm; 1363 vm.setPortId(id); 1364 return vm; 1365 } else { 1366 PJSUA2_RAISE_ERROR2(PJ_EINVALIDOP, "Preview not started"); 1367 } 1368 #else 1369 PJSUA2_RAISE_ERROR(PJ_EINVALIDOP); 1335 1370 #endif 1336 1371 } … … 1808 1843 } 1809 1844 1845 1846 /////////////////////////////////////////////////////////////////////////////// 1847 1848 void VidConfPortInfo::fromPj(const pjsua_vid_conf_port_info &port_info) 1849 { 1850 portId = port_info.slot_id; 1851 name = pj2Str(port_info.name); 1852 format.fromPj(port_info.format); 1853 listeners.clear(); 1854 for (unsigned i=0; i<port_info.listener_cnt; ++i) { 1855 listeners.push_back(port_info.listeners[i]); 1856 } 1857 transmitters.clear(); 1858 for (unsigned i=0; i<port_info.transmitter_cnt; ++i) { 1859 transmitters.push_back(port_info.transmitters[i]); 1860 } 1861 } 1862 1863 VideoMedia::VideoMedia() 1864 : Media(PJMEDIA_TYPE_VIDEO), id(PJSUA_INVALID_ID) 1865 { 1866 1867 } 1868 1869 void VideoMedia::registerMediaPort(MediaPort port, pj_pool_t *pool) 1870 throw(Error) 1871 { 1872 if (!pool) { 1873 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "registerMediaPort()", 1874 "pool must be supplied"); 1875 } 1876 if (!port) { 1877 PJSUA2_RAISE_ERROR3(PJ_EINVAL, "registerMediaPort()", 1878 "port must be supplied"); 1879 } 1880 if (id != PJSUA_INVALID_ID) { 1881 PJSUA2_RAISE_ERROR3(PJ_EINVALIDOP, "registerMediaPort()", 1882 "VideoMedia is occupied"); 1883 } 1884 1885 PJSUA2_CHECK_EXPR( pjsua_vid_conf_add_port(pool, 1886 (pjmedia_port*)port, NULL, 1887 &id) ); 1888 } 1889 1890 void VideoMedia::unregisterMediaPort() 1891 { 1892 if (id != PJSUA_INVALID_ID) { 1893 pjsua_vid_conf_remove_port(id); 1894 id = PJSUA_INVALID_ID; 1895 } 1896 } 1897 1898 VideoMedia::~VideoMedia() 1899 { 1900 } 1901 1902 VidConfPortInfo VideoMedia::getPortInfo() const throw(Error) 1903 { 1904 return VideoMedia::getPortInfoFromId(id); 1905 } 1906 1907 int VideoMedia::getPortId() const 1908 { 1909 return id; 1910 } 1911 1912 VidConfPortInfo VideoMedia::getPortInfoFromId(int port_id) throw(Error) 1913 { 1914 pjsua_vid_conf_port_info pj_info; 1915 VidConfPortInfo pi; 1916 1917 PJSUA2_CHECK_EXPR( pjsua_vid_conf_get_port_info(port_id, &pj_info) ); 1918 pi.fromPj(pj_info); 1919 return pi; 1920 } 1921 1922 void VideoMedia::startTransmit(const VideoMedia &sink, 1923 const VideoMediaTransmitParam ¶m) const 1924 throw(Error) 1925 { 1926 PJ_UNUSED_ARG(param); 1927 PJSUA2_CHECK_EXPR( pjsua_vid_conf_connect(id, sink.id, NULL) ); 1928 } 1929 1930 void VideoMedia::stopTransmit(const VideoMedia &sink) const throw(Error) 1931 { 1932 PJSUA2_CHECK_EXPR( pjsua_vid_conf_disconnect(id, sink.id) ); 1933 } -
pjproject/trunk/pjsip/src/pjsua2/util.hpp
r5601 r5972 19 19 20 20 #include <pjsua2/types.hpp> 21 #include <pjsua2/media.hpp> 21 22 #include <string> 22 23 … … 42 43 } 43 44 45 class AudioMediaHelper : public AudioMedia 46 { 47 public: 48 void setPortId(int port_id) { id = port_id; } 49 }; 44 50 45 } // namespace 51 class VideoMediaHelper : public VideoMedia 52 { 53 public: 54 void setPortId(int port_id) { id = port_id; } 55 }; 56 57 } // namespace pj
Note: See TracChangeset
for help on using the changeset viewer.