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/videodev.c

    r3579 r3592  
    211211 
    212212/* Internal: init driver */ 
    213 static pj_status_t init_driver(unsigned drv_idx) 
     213static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh) 
    214214{ 
    215215    struct driver *drv = &vid_subsys.drv[drv_idx]; 
     
    218218    pj_status_t status; 
    219219 
    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; 
    230234    } 
    231235 
     
    357361    /* Initialize each factory and build the device ID list */ 
    358362    for (i=0; i<vid_subsys.drv_cnt; ++i) { 
    359         status = init_driver(i); 
     363        status = init_driver(i, PJ_FALSE); 
    360364        if (status != PJ_SUCCESS) { 
    361365            deinit_driver(i); 
     
    377381 
    378382    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); 
    380384    if (status == PJ_SUCCESS) { 
    381385        vid_subsys.drv_cnt++; 
     
    439443 
    440444        vid_subsys.pf = NULL; 
     445    } 
     446    return PJ_SUCCESS; 
     447} 
     448 
     449/* API: Refresh the list of video devices installed in the system. */ 
     450PJ_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); 
    441466    } 
    442467    return PJ_SUCCESS; 
Note: See TracChangeset for help on using the changeset viewer.