Changeset 3592
- Timestamp:
- Jun 21, 2011 9:33:01 AM (13 years ago)
- Location:
- pjproject/branches/projects/2.0-dev/pjmedia
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia-videodev/videodev.h
r3590 r3592 446 446 447 447 /** 448 * Refresh the list of video devices installed in the system. This function 449 * will only refresh the list of videoo device so all active video streams will 450 * be unaffected. After refreshing the device list, application MUST make sure 451 * to update all index references to video devices (i.e. all variables of type 452 * pjmedia_vid_dev_index) before calling any function that accepts video device 453 * index as its parameter. 454 * 455 * @return PJ_SUCCESS on successful operation or the appropriate 456 * error code. 457 */ 458 PJ_DECL(pj_status_t) pjmedia_vid_dev_refresh(void); 459 460 461 /** 448 462 * Get the number of video devices installed in the system. 449 463 * -
pjproject/branches/projects/2.0-dev/pjmedia/include/pjmedia-videodev/videodev_imp.h
r3489 r3592 91 91 void *user_data, 92 92 pjmedia_vid_dev_stream **p_vid_strm); 93 94 /** 95 * Refresh the list of video devices installed in the system. 96 * 97 * @param f The video device factory. 98 */ 99 pj_status_t (*refresh)(pjmedia_vid_dev_factory *f); 93 100 94 101 } pjmedia_vid_dev_factory_op; -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/colorbar_dev.c
r3580 r3592 100 100 static pj_status_t cbar_factory_init(pjmedia_vid_dev_factory *f); 101 101 static pj_status_t cbar_factory_destroy(pjmedia_vid_dev_factory *f); 102 static pj_status_t cbar_factory_refresh(pjmedia_vid_dev_factory *f); 102 103 static unsigned cbar_factory_get_dev_count(pjmedia_vid_dev_factory *f); 103 104 static pj_status_t cbar_factory_get_dev_info(pjmedia_vid_dev_factory *f, … … 137 138 &cbar_factory_get_dev_info, 138 139 &cbar_factory_default_param, 139 &cbar_factory_create_stream 140 &cbar_factory_create_stream, 141 &cbar_factory_refresh 140 142 }; 141 143 … … 226 228 pj_pool_release(pool); 227 229 230 return PJ_SUCCESS; 231 } 232 233 /* API: refresh the list of devices */ 234 static pj_status_t cbar_factory_refresh(pjmedia_vid_dev_factory *f) 235 { 236 PJ_UNUSED_ARG(f); 228 237 return PJ_SUCCESS; 229 238 } -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/dshow_dev.c
r3582 r3592 83 83 pjmedia_vid_dev_factory base; 84 84 pj_pool_t *pool; 85 pj_pool_t *dev_pool; 85 86 pj_pool_factory *pf; 86 87 … … 124 125 static pj_status_t dshow_factory_init(pjmedia_vid_dev_factory *f); 125 126 static pj_status_t dshow_factory_destroy(pjmedia_vid_dev_factory *f); 127 static pj_status_t dshow_factory_refresh(pjmedia_vid_dev_factory *f); 126 128 static unsigned dshow_factory_get_dev_count(pjmedia_vid_dev_factory *f); 127 129 static pj_status_t dshow_factory_get_dev_info(pjmedia_vid_dev_factory *f, … … 161 163 &dshow_factory_get_dev_info, 162 164 &dshow_factory_default_param, 163 &dshow_factory_create_stream 165 &dshow_factory_create_stream, 166 &dshow_factory_refresh 164 167 }; 165 168 … … 200 203 static pj_status_t dshow_factory_init(pjmedia_vid_dev_factory *f) 201 204 { 205 CoInitializeEx(NULL, COINIT_MULTITHREADED); 206 207 return dshow_factory_refresh(f); 208 } 209 210 /* API: destroy factory */ 211 static pj_status_t dshow_factory_destroy(pjmedia_vid_dev_factory *f) 212 { 213 struct dshow_factory *df = (struct dshow_factory*)f; 214 pj_pool_t *pool = df->pool; 215 216 df->pool = NULL; 217 if (df->dev_pool) 218 pj_pool_release(df->dev_pool); 219 if (pool) 220 pj_pool_release(pool); 221 222 CoUninitialize(); 223 224 return PJ_SUCCESS; 225 } 226 227 /* API: refresh the list of devices */ 228 static pj_status_t dshow_factory_refresh(pjmedia_vid_dev_factory *f) 229 { 202 230 struct dshow_factory *df = (struct dshow_factory*)f; 203 231 struct dshow_dev_info *ddi; … … 210 238 ULONG fetched; 211 239 240 if (df->dev_pool) { 241 pj_pool_release(df->dev_pool); 242 df->dev_pool = NULL; 243 } 244 212 245 df->dev_count = 0; 213 214 CoInitializeEx(NULL, COINIT_MULTITHREADED); 246 df->dev_pool = pj_pool_create(df->pf, "dshow video", 500, 500, NULL); 215 247 216 248 hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, … … 234 266 dev_count += 1; 235 267 df->dev_info = (struct dshow_dev_info*) 236 pj_pool_calloc(df-> pool, dev_count,268 pj_pool_calloc(df->dev_pool, dev_count, 237 269 sizeof(struct dshow_dev_info)); 238 270 … … 305 337 ddi->info.fmt_cnt = sizeof(dshow_fmts)/sizeof(dshow_fmts[0]); 306 338 ddi->info.fmt = (pjmedia_format*) 307 pj_pool_calloc(df-> pool, ddi->info.fmt_cnt,339 pj_pool_calloc(df->dev_pool, ddi->info.fmt_cnt, 308 340 sizeof(pjmedia_format)); 309 341 … … 322 354 // ddi->info.caps = PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW; 323 355 324 PJ_LOG(4, (THIS_FILE, "DShow initialized, found%d devices:",356 PJ_LOG(4, (THIS_FILE, "DShow has %d devices:", 325 357 df->dev_count)); 326 358 for (c = 0; c < df->dev_count; ++c) { … … 331 363 "capture" : "render")); 332 364 } 333 334 return PJ_SUCCESS;335 }336 337 /* API: destroy factory */338 static pj_status_t dshow_factory_destroy(pjmedia_vid_dev_factory *f)339 {340 struct dshow_factory *df = (struct dshow_factory*)f;341 pj_pool_t *pool = df->pool;342 343 df->pool = NULL;344 pj_pool_release(pool);345 346 CoUninitialize();347 365 348 366 return PJ_SUCCESS; -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/ffmpeg_dev.c
r3489 r3592 61 61 pj_pool_factory *pf; 62 62 pj_pool_t *pool; 63 pj_pool_t *dev_pool; 63 64 unsigned dev_count; 64 65 ffmpeg_dev_info dev_info[MAX_DEV_CNT]; … … 79 80 static pj_status_t ffmpeg_factory_init(pjmedia_vid_dev_factory *f); 80 81 static pj_status_t ffmpeg_factory_destroy(pjmedia_vid_dev_factory *f); 82 static pj_status_t ffmpeg_factory_refresh(pjmedia_vid_dev_factory *f); 81 83 static unsigned ffmpeg_factory_get_dev_count(pjmedia_vid_dev_factory *f); 82 84 static pj_status_t ffmpeg_factory_get_dev_info(pjmedia_vid_dev_factory *f, … … 116 118 &ffmpeg_factory_get_dev_info, 117 119 &ffmpeg_factory_default_param, 118 &ffmpeg_factory_create_stream 120 &ffmpeg_factory_create_stream, 121 &ffmpeg_factory_refresh 119 122 }; 120 123 … … 220 223 static pj_status_t ffmpeg_factory_init(pjmedia_vid_dev_factory *f) 221 224 { 225 return ffmpeg_factory_refresh(f); 226 } 227 228 /* API: destroy factory */ 229 static pj_status_t ffmpeg_factory_destroy(pjmedia_vid_dev_factory *f) 230 { 231 ffmpeg_factory *ff = (ffmpeg_factory*)f; 232 pj_pool_t *pool = ff->pool; 233 234 ff->dev_count = 0; 235 ff->pool = NULL; 236 if (ff->dev_pool) 237 pj_pool_release(ff->dev_pool); 238 if (pool) 239 pj_pool_release(pool); 240 241 return PJ_SUCCESS; 242 } 243 244 /* API: refresh the list of devices */ 245 static pj_status_t ffmpeg_factory_refresh(pjmedia_vid_dev_factory *f) 246 { 222 247 ffmpeg_factory *ff = (ffmpeg_factory*)f; 223 248 AVInputFormat *p; … … 227 252 av_log_set_level(AV_LOG_DEBUG); 228 253 254 if (ff->dev_pool) { 255 pj_pool_release(ff->dev_pool); 256 ff->dev_pool = NULL; 257 } 258 229 259 /* TODO: this should enumerate devices, now it enumerates host APIs */ 230 260 ff->dev_count = 0; 261 ff->dev_pool = pj_pool_create(ff->pf, "ffmpeg_cap_dev", 500, 500, NULL); 262 231 263 p = av_iformat_next(NULL); 232 264 while (p) { … … 255 287 info->base.fmt_cnt = 1; 256 288 info->base.fmt = (pjmedia_format*) 257 pj_pool_calloc(ff-> pool, info->base.fmt_cnt,289 pj_pool_calloc(ff->dev_pool, info->base.fmt_cnt, 258 290 sizeof(pjmedia_format)); 259 291 for (i = 0; i < info->base.fmt_cnt; ++i) { … … 271 303 } 272 304 273 /* API: destroy factory */274 static pj_status_t ffmpeg_factory_destroy(pjmedia_vid_dev_factory *f)275 {276 ffmpeg_factory *ff = (ffmpeg_factory*)f;277 278 ff->dev_count = 0;279 280 return PJ_SUCCESS;281 }282 283 305 /* API: get number of devices */ 284 306 static unsigned ffmpeg_factory_get_dev_count(pjmedia_vid_dev_factory *f) -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/sdl_dev.c
r3590 r3592 186 186 static pj_status_t sdl_factory_init(pjmedia_vid_dev_factory *f); 187 187 static pj_status_t sdl_factory_destroy(pjmedia_vid_dev_factory *f); 188 static pj_status_t sdl_factory_refresh(pjmedia_vid_dev_factory *f); 188 189 static unsigned sdl_factory_get_dev_count(pjmedia_vid_dev_factory *f); 189 190 static pj_status_t sdl_factory_get_dev_info(pjmedia_vid_dev_factory *f, … … 227 228 &sdl_factory_get_dev_info, 228 229 &sdl_factory_default_param, 229 &sdl_factory_create_stream 230 &sdl_factory_create_stream, 231 &sdl_factory_refresh 230 232 }; 231 233 … … 354 356 #endif 355 357 358 return PJ_SUCCESS; 359 } 360 361 /* API: refresh the list of devices */ 362 static pj_status_t sdl_factory_refresh(pjmedia_vid_dev_factory *f) 363 { 364 PJ_UNUSED_ARG(f); 356 365 return PJ_SUCCESS; 357 366 } -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/v4l2_dev.c
r3580 r3592 82 82 pjmedia_vid_dev_factory base; 83 83 pj_pool_t *pool; 84 pj_pool_t *dev_pool; 84 85 pj_pool_factory *pf; 85 86 … … 120 121 static pj_status_t vid4lin_factory_init(pjmedia_vid_dev_factory *f); 121 122 static pj_status_t vid4lin_factory_destroy(pjmedia_vid_dev_factory *f); 123 static pj_status_t vid4lin_factory_refresh(pjmedia_vid_dev_factory *f); 122 124 static unsigned vid4lin_factory_get_dev_count(pjmedia_vid_dev_factory *f); 123 125 static pj_status_t vid4lin_factory_get_dev_info(pjmedia_vid_dev_factory *f, … … 156 158 &vid4lin_factory_get_dev_info, 157 159 &vid4lin_factory_default_param, 158 &vid4lin_factory_create_stream 160 &vid4lin_factory_create_stream, 161 &vid4lin_factory_refresh 159 162 }; 160 163 … … 213 216 pj_status_t status; 214 217 218 if (f->dev_pool) { 219 pj_pool_release(f->dev_pool); 220 f->dev_pool = NULL; 221 } 222 215 223 pj_bzero(vdi, sizeof(vdi)); 216 224 old_count = f->dev_count; 217 225 f->dev_count = 0; 226 f->dev_pool = pj_pool_create(f->pf, DRIVER_NAME, 500, 500, NULL); 218 227 219 228 for (i=0; i<V4L2_MAX_DEVS && f->dev_count < V4L2_MAX_DEVS; ++i) { 220 229 int fd; 221 230 vid4lin_dev_info *pdi; 222 pj_pool_t *pool = f-> pool;231 pj_pool_t *pool = f->dev_pool; 223 232 pj_uint32_t fmt_cap[8]; 224 233 int j, fmt_cnt=0; … … 313 322 if (f->dev_count > old_count || f->dev_info == NULL) { 314 323 f->dev_info = (vid4lin_dev_info*) 315 pj_pool_calloc(f-> pool,324 pj_pool_calloc(f->dev_pool, 316 325 f->dev_count, 317 326 sizeof(vid4lin_dev_info)); … … 325 334 /* API: init factory */ 326 335 static pj_status_t vid4lin_factory_init(pjmedia_vid_dev_factory *f) 336 { 337 return vid4lin_factory_refresh(f); 338 } 339 340 /* API: destroy factory */ 341 static pj_status_t vid4lin_factory_destroy(pjmedia_vid_dev_factory *f) 342 { 343 vid4lin_factory *cf = (vid4lin_factory*)f; 344 pj_pool_t *pool = cf->pool; 345 346 if (cf->dev_pool) 347 pj_pool_release(cf->dev_pool); 348 if (cf->pool) { 349 cf->pool = NULL; 350 pj_pool_release(pool); 351 } 352 353 return PJ_SUCCESS; 354 } 355 356 /* API: refresh the list of devices */ 357 static pj_status_t vid4lin_factory_refresh(pjmedia_vid_dev_factory *f) 327 358 { 328 359 vid4lin_factory *cf = (vid4lin_factory*)f; … … 333 364 return status; 334 365 335 PJ_LOG(4, (THIS_FILE, "Video4Linux2 initialized with%d devices",366 PJ_LOG(4, (THIS_FILE, "Video4Linux2 has %d devices", 336 367 cf->dev_count)); 337 338 return PJ_SUCCESS;339 }340 341 /* API: destroy factory */342 static pj_status_t vid4lin_factory_destroy(pjmedia_vid_dev_factory *f)343 {344 vid4lin_factory *cf = (vid4lin_factory*)f;345 pj_pool_t *pool = cf->pool;346 347 if (cf->pool) {348 cf->pool = NULL;349 pj_pool_release(pool);350 }351 368 352 369 return PJ_SUCCESS; -
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/videodev.c
r3579 r3592 211 211 212 212 /* Internal: init driver */ 213 static pj_status_t init_driver(unsigned drv_idx )213 static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh) 214 214 { 215 215 struct driver *drv = &vid_subsys.drv[drv_idx]; … … 218 218 pj_status_t status; 219 219 220 /* Create the factory */ 221 f = (*drv->create)(vid_subsys.pf); 222 if (!f) 223 return PJ_EUNKNOWN; 224 225 /* Call factory->init() */ 226 status = f->op->init(f); 227 if (status != PJ_SUCCESS) { 228 f->op->destroy(f); 229 return status; 220 if (!refresh) { 221 /* Create the factory */ 222 f = (*drv->create)(vid_subsys.pf); 223 if (!f) 224 return PJ_EUNKNOWN; 225 226 /* Call factory->init() */ 227 status = f->op->init(f); 228 if (status != PJ_SUCCESS) { 229 f->op->destroy(f); 230 return status; 231 } 232 } else { 233 f = drv->f; 230 234 } 231 235 … … 357 361 /* Initialize each factory and build the device ID list */ 358 362 for (i=0; i<vid_subsys.drv_cnt; ++i) { 359 status = init_driver(i );363 status = init_driver(i, PJ_FALSE); 360 364 if (status != PJ_SUCCESS) { 361 365 deinit_driver(i); … … 377 381 378 382 vid_subsys.drv[vid_subsys.drv_cnt].create = adf; 379 status = init_driver(vid_subsys.drv_cnt );383 status = init_driver(vid_subsys.drv_cnt, PJ_FALSE); 380 384 if (status == PJ_SUCCESS) { 381 385 vid_subsys.drv_cnt++; … … 439 443 440 444 vid_subsys.pf = NULL; 445 } 446 return PJ_SUCCESS; 447 } 448 449 /* API: Refresh the list of video devices installed in the system. */ 450 PJ_DEF(pj_status_t) pjmedia_vid_dev_refresh(void) 451 { 452 unsigned i; 453 454 vid_subsys.dev_cnt = 0; 455 for (i=0; i<vid_subsys.drv_cnt; ++i) { 456 struct driver *drv = &vid_subsys.drv[i]; 457 458 if (drv->f && drv->f->op->refresh) { 459 pj_status_t status = drv->f->op->refresh(drv->f); 460 if (status != PJ_SUCCESS) { 461 PJ_PERROR(4, (THIS_FILE, status, "Unable to refresh device " 462 "list for %s", drv->name)); 463 } 464 } 465 init_driver(i, PJ_TRUE); 441 466 } 442 467 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.