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:
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 inpjmedia_vid_unregister_factory
it is overwritten: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
pjsua_create();
pjsua_init();
pjmedia_vid_subsys *vs = pjmedia_get_vid_subsys();
pjmedia_vid_unregister_factory(NULL, vs->drv[0].f);
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);
PJSIP version
2.14.1
Context
Debian 12, video enabled, sdl and v4l2 devices enabled
Log, call stack, etc