Changeset 5972 for pjproject/trunk/pjsip/src/pjsua2/media.cpp
- Timestamp:
- Apr 23, 2019 10:49:56 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.