Changeset 5123 for pjproject/trunk/pjsip/src/pjsua2/media.cpp
- Timestamp:
- Jul 1, 2015 2:20:12 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/media.cpp
r5102 r5123 1095 1095 } 1096 1096 /////////////////////////////////////////////////////////////////////////////// 1097 1098 1097 VideoPreviewOpParam::VideoPreviewOpParam() 1099 1098 { … … 1178 1177 1179 1178 /////////////////////////////////////////////////////////////////////////////// 1179 void MediaFormatVideo::fromPj(const pjmedia_format &format) 1180 { 1181 #if PJSUA_HAS_VIDEO 1182 if ((format.type != PJMEDIA_TYPE_VIDEO) && 1183 (format.detail_type != PJMEDIA_FORMAT_DETAIL_VIDEO)) 1184 { 1185 type = PJMEDIA_TYPE_UNKNOWN; 1186 return; 1187 } 1188 1189 id = format.id; 1190 type = format.type; 1191 1192 /* Detail. */ 1193 width = format.det.vid.size.w; 1194 height = format.det.vid.size.h; 1195 fpsNum = format.det.vid.fps.num; 1196 fpsDenum = format.det.vid.fps.denum; 1197 avgBps = format.det.vid.avg_bps; 1198 maxBps = format.det.vid.max_bps; 1199 #else 1200 type = PJMEDIA_TYPE_UNKNOWN; 1201 #endif 1202 } 1203 1204 pjmedia_format MediaFormatVideo::toPj() const 1205 { 1206 pjmedia_format pj_format; 1207 1208 #if PJSUA_HAS_VIDEO 1209 pj_format.id = id; 1210 pj_format.type = type; 1211 1212 pj_format.detail_type = PJMEDIA_FORMAT_DETAIL_VIDEO; 1213 pj_format.det.vid.size.w = width; 1214 pj_format.det.vid.size.h = height; 1215 pj_format.det.vid.fps.num = fpsNum; 1216 pj_format.det.vid.fps.denum = fpsDenum; 1217 pj_format.det.vid.avg_bps = avgBps; 1218 pj_format.det.vid.max_bps = maxBps; 1219 #else 1220 pj_format.type = PJMEDIA_TYPE_UNKNOWN; 1221 #endif 1222 return pj_format; 1223 } 1224 1225 /////////////////////////////////////////////////////////////////////////////// 1226 void VideoDevInfo::fromPj(const pjmedia_vid_dev_info &dev_info) 1227 { 1228 #if PJSUA_HAS_VIDEO 1229 name = dev_info.name; 1230 driver = dev_info.driver; 1231 dir = dev_info.dir; 1232 caps = dev_info.caps; 1233 1234 for (unsigned i = 0; i<dev_info.fmt_cnt;++i) { 1235 MediaFormatVideo *format = new MediaFormatVideo; 1236 1237 format->fromPj(dev_info.fmt[i]); 1238 if (format->type == PJMEDIA_TYPE_VIDEO) 1239 fmt.push_back(format); 1240 } 1241 #else 1242 PJ_UNUSED_ARG(dev_info); 1243 #endif 1244 } 1245 1246 VideoDevInfo::~VideoDevInfo() 1247 { 1248 #if PJSUA_HAS_VIDEO 1249 for (unsigned i = 0;i<fmt.size();++i) { 1250 delete fmt[i]; 1251 } 1252 fmt.clear(); 1253 #endif 1254 } 1255 1256 /////////////////////////////////////////////////////////////////////////////// 1257 unsigned VidDevManager::getDevCount() 1258 { 1259 #if PJSUA_HAS_VIDEO 1260 return pjsua_vid_dev_count(); 1261 #else 1262 return 0; 1263 #endif 1264 } 1265 1266 VideoDevInfo VidDevManager::getDevInfo(int dev_id) const throw(Error) 1267 { 1268 VideoDevInfo dev_info; 1269 #if PJSUA_HAS_VIDEO 1270 pjmedia_vid_dev_info pj_info; 1271 1272 PJSUA2_CHECK_EXPR(pjsua_vid_dev_get_info(dev_id, &pj_info)); 1273 1274 dev_info.fromPj(pj_info); 1275 #endif 1276 return dev_info; 1277 } 1278 1279 const VideoDevInfoVector &VidDevManager::enumDev() throw(Error) 1280 { 1281 #if PJSUA_HAS_VIDEO 1282 pjmedia_vid_dev_info pj_info[MAX_DEV_COUNT]; 1283 unsigned count = MAX_DEV_COUNT; 1284 1285 PJSUA2_CHECK_EXPR(pjsua_vid_enum_devs(pj_info, &count)); 1286 1287 pj_enter_critical_section(); 1288 clearVideoDevList(); 1289 for (unsigned i = 0; i<count;++i) { 1290 VideoDevInfo *dev_info = new VideoDevInfo; 1291 dev_info->fromPj(pj_info[i]); 1292 videoDevList.push_back(dev_info); 1293 } 1294 pj_leave_critical_section(); 1295 #endif 1296 return videoDevList; 1297 } 1298 1299 void VidDevManager::clearVideoDevList() 1300 { 1301 #if PJSUA_HAS_VIDEO 1302 for (unsigned i = 0;i<videoDevList.size();++i) { 1303 delete videoDevList[i]; 1304 } 1305 videoDevList.clear(); 1306 #endif 1307 } 1308 1309 VidDevManager::VidDevManager() 1310 { 1311 } 1312 1313 VidDevManager::~VidDevManager() 1314 { 1315 #if PJSUA_HAS_VIDEO 1316 clearVideoDevList(); 1317 #endif 1318 } 1319 1320 /////////////////////////////////////////////////////////////////////////////// 1180 1321 void CodecInfo::fromPj(const pjsua_codec_info &codec_info) 1181 1322 {
Note: See TracChangeset
for help on using the changeset viewer.