static void *v4l2_create(obs_data_t *settings, obs_source_t *source) { struct v4l2_data *data = bzalloc(sizeof(struct v4l2_data)); data->dev = -1; data->source = source; /* Bitch about build problems ... */ #ifndef V4L2_CAP_DEVICE_CAPS blog(LOG_WARNING, "Plugin built without device caps support!"); #endif #ifndef VIDIOC_ENUM_DV_TIMINGS blog(LOG_WARNING, "Plugin built without dv-timing support!"); #endif v4l2_update(data, settings); #if HAVE_UDEV v4l2_init_udev(); signal_handler_t *sh = v4l2_get_udev_signalhandler(); signal_handler_connect(sh, "device_added", &device_added, data); signal_handler_connect(sh, "device_removed", &device_removed, data); #endif return data; }
static void v4l2_destroy(void *vptr) { V4L2_DATA(vptr); if (!data) return; v4l2_terminate(data); if (data->device_id) bfree(data->device_id); #if HAVE_UDEV signal_handler_t *sh = v4l2_get_udev_signalhandler(); signal_handler_disconnect(sh, "device_added", device_added, data); signal_handler_disconnect(sh, "device_removed", device_removed, data); v4l2_unref_udev(); #endif bfree(data); }