Ignore:
Timestamp:
Jun 21, 2011 9:33:01 AM (13 years ago)
Author:
ming
Message:

Re #1312: Support for refreshing video device list
Add pjmedia-videodev API: pjmedia_vid_dev_refresh() and its implementation for Windows and Linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/ffmpeg_dev.c

    r3489 r3592  
    6161    pj_pool_factory             *pf; 
    6262    pj_pool_t                   *pool; 
     63    pj_pool_t                   *dev_pool; 
    6364    unsigned                     dev_count; 
    6465    ffmpeg_dev_info              dev_info[MAX_DEV_CNT]; 
     
    7980static pj_status_t ffmpeg_factory_init(pjmedia_vid_dev_factory *f); 
    8081static pj_status_t ffmpeg_factory_destroy(pjmedia_vid_dev_factory *f); 
     82static pj_status_t ffmpeg_factory_refresh(pjmedia_vid_dev_factory *f); 
    8183static unsigned    ffmpeg_factory_get_dev_count(pjmedia_vid_dev_factory *f); 
    8284static pj_status_t ffmpeg_factory_get_dev_info(pjmedia_vid_dev_factory *f, 
     
    116118    &ffmpeg_factory_get_dev_info, 
    117119    &ffmpeg_factory_default_param, 
    118     &ffmpeg_factory_create_stream 
     120    &ffmpeg_factory_create_stream, 
     121    &ffmpeg_factory_refresh 
    119122}; 
    120123 
     
    220223static pj_status_t ffmpeg_factory_init(pjmedia_vid_dev_factory *f) 
    221224{ 
     225    return ffmpeg_factory_refresh(f); 
     226} 
     227 
     228/* API: destroy factory */ 
     229static 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 */ 
     245static pj_status_t ffmpeg_factory_refresh(pjmedia_vid_dev_factory *f) 
     246{ 
    222247    ffmpeg_factory *ff = (ffmpeg_factory*)f; 
    223248    AVInputFormat *p; 
     
    227252    av_log_set_level(AV_LOG_DEBUG); 
    228253 
     254    if (ff->dev_pool) { 
     255        pj_pool_release(ff->dev_pool); 
     256        ff->dev_pool = NULL; 
     257    } 
     258 
    229259    /* TODO: this should enumerate devices, now it enumerates host APIs */ 
    230260    ff->dev_count = 0; 
     261    ff->dev_pool = pj_pool_create(ff->pf, "ffmpeg_cap_dev", 500, 500, NULL); 
     262 
    231263    p = av_iformat_next(NULL); 
    232264    while (p) { 
     
    255287            info->base.fmt_cnt = 1; 
    256288            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, 
    258290                                            sizeof(pjmedia_format)); 
    259291            for (i = 0; i < info->base.fmt_cnt; ++i) { 
     
    271303} 
    272304 
    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  
    283305/* API: get number of devices */ 
    284306static unsigned ffmpeg_factory_get_dev_count(pjmedia_vid_dev_factory *f) 
Note: See TracChangeset for help on using the changeset viewer.