v4l2: Track /dev/video* to triggered required probe

If something in /dev/video* get added, removed or replaced, we need to
probe the devices again in order to ensure the dynamic devices are up to
date.

https://bugzilla.gnome.org/show_bug.cgi?id=758085
This commit is contained in:
Nicolas Dufresne 2015-11-13 12:35:59 -05:00
parent dd4df554d5
commit 3cdc700e3e
2 changed files with 26 additions and 2 deletions

View file

@ -555,6 +555,17 @@ if test x$HAVE_GST_V4L2 = xyes; then
fi fi
fi fi
dnl Allow enabling v4l2 device probing
AC_ARG_ENABLE(
v4l2-probe,
AC_HELP_STRING(
[--enable-v4l2-probe],
[enable V4L2 plugin to probe devices @<:@default=no@:>@]))
if test "x$enable_v4l2_probe" = xyes; then
AC_DEFINE(GST_V4L2_ENABLE_PROBE, 1,
[Define if Video4Linux probe shall be run at plugin load])
fi
dnl Check for X11 dnl Check for X11
translit(dnm, m, l) AM_CONDITIONAL(USE_X, true) translit(dnm, m, l) AM_CONDITIONAL(USE_X, true)
AG_GST_CHECK_FEATURE(X, [X libraries and plugins], AG_GST_CHECK_FEATURE(X, [X libraries and plugins],

View file

@ -54,6 +54,7 @@
GST_DEBUG_CATEGORY (v4l2_debug); GST_DEBUG_CATEGORY (v4l2_debug);
#define GST_CAT_DEFAULT v4l2_debug #define GST_CAT_DEFAULT v4l2_debug
#ifdef GST_V4L2_ENABLE_PROBE
/* This is a minimalist probe, for speed, we only enumerate formats */ /* This is a minimalist probe, for speed, we only enumerate formats */
static GstCaps * static GstCaps *
gst_v4l2_probe_template_caps (const gchar * device, gint video_fd, gst_v4l2_probe_template_caps (const gchar * device, gint video_fd,
@ -192,12 +193,21 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
return ret; return ret;
} }
#endif
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {
const gchar *paths[] = { "/dev", "/dev/v4l2", NULL };
const gchar *names[] = { "video", NULL };
GST_DEBUG_CATEGORY_INIT (v4l2_debug, "v4l2", 0, "V4L2 API calls"); GST_DEBUG_CATEGORY_INIT (v4l2_debug, "v4l2", 0, "V4L2 API calls");
/* Add some depedency, so the dynamic features get updated upon changes in
* /dev/video* */
gst_plugin_add_dependency (plugin,
NULL, paths, names, GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX);
if (!gst_element_register (plugin, "v4l2src", GST_RANK_PRIMARY, if (!gst_element_register (plugin, "v4l2src", GST_RANK_PRIMARY,
GST_TYPE_V4L2SRC) || GST_TYPE_V4L2SRC) ||
!gst_element_register (plugin, "v4l2sink", GST_RANK_NONE, !gst_element_register (plugin, "v4l2sink", GST_RANK_NONE,
@ -205,9 +215,12 @@ plugin_init (GstPlugin * plugin)
!gst_element_register (plugin, "v4l2radio", GST_RANK_NONE, !gst_element_register (plugin, "v4l2radio", GST_RANK_NONE,
GST_TYPE_V4L2RADIO) || GST_TYPE_V4L2RADIO) ||
!gst_device_provider_register (plugin, "v4l2deviceprovider", !gst_device_provider_register (plugin, "v4l2deviceprovider",
GST_RANK_PRIMARY, GST_TYPE_V4L2_DEVICE_PROVIDER) || GST_RANK_PRIMARY, GST_TYPE_V4L2_DEVICE_PROVIDER)
/* etc. */ /* etc. */
!gst_v4l2_probe_and_register (plugin)) #ifdef GST_V4L2_ENABLE_PROBE
|| !gst_v4l2_probe_and_register (plugin)
#endif
)
return FALSE; return FALSE;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS