pjsip / pjproject

PJSIP project
http://www.pjsip.org
GNU General Public License v2.0
2.08k stars 788 forks source link

Default video capture and render devices are undefined after pjmedia_vid_unregister_factory() #4129

Closed half-left closed 2 weeks ago

half-left commented 3 weeks ago

Describe the bug

When some built-in video device factory is unregistered, use of PJMEDIA_VID_DEFAULT_RENDER_DEV or PJMEDIA_VID_DEFAULT_CAPTURE_DEV can be incorrect. In pjmedia_vid_driver_deinit() we have reset: drv->rend_dev_idx = drv->cap_dev_idx = -1; But in pjmedia_vid_unregister_factory it is overwritten:

            pjmedia_vid_driver_deinit(i);
            pj_bzero(drv, sizeof(*drv));
            return PJ_SUCCESS;

It couses an error in lookup_dev() in videodev.c (with arg PJMEDIA_VID_DEFAULT_RENDER_DEV or PJMEDIA_VID_DEFAULT_CAPTURE_DEV )

Steps to reproduce

  1. pjsua_create(); pjsua_init();
  2. pjmedia_vid_subsys *vs = pjmedia_get_vid_subsys(); pjmedia_vid_unregister_factory(NULL, vs->drv[0].f);
  3. pj_status_t status1 = pjsua_vid_dev_get_info(PJMEDIA_VID_DEFAULT_RENDER_DEV, &vdi1); pj_status_t status2 = pjsua_vid_dev_get_info(PJMEDIA_VID_DEFAULT_CAPTURE_DEV, &vdi2);
  4. status1 and status2 are PJMEDIA_EVID_INVDEV

PJSIP version

2.14.1

Context

Debian 12, video enabled, sdl and v4l2 devices enabled

Log, call stack, etc

...
aol-nnov commented 3 weeks ago

https://github.com/pjsip/pjproject/pull/4130