#include <unistd.h>
#include "ext/videodev2.h"
+#include "gstv4l2elements.h"
#include "v4l2-utils.h"
#include "gstv4l2object.h"
#include "gstv4l2mpeg4enc.h"
#include "gstv4l2vp8enc.h"
#include "gstv4l2vp9enc.h"
-#include "gstv4l2deviceprovider.h"
#include "gstv4l2transform.h"
-/* used in gstv4l2object.c and v4l2_calls.c */
-GST_DEBUG_CATEGORY (v4l2_debug);
-#define GST_CAT_DEFAULT v4l2_debug
-
#ifdef GST_V4L2_ENABLE_PROBE
/* This is a minimalist probe, for speed, we only enumerate formats */
static GstCaps *
static gboolean
plugin_init (GstPlugin * plugin)
{
+ gboolean ret = FALSE;
const gchar *paths[] = { "/dev", "/dev/v4l2", NULL };
const gchar *names[] = { "video", NULL };
- GST_DEBUG_CATEGORY_INIT (v4l2_debug, "v4l2", 0, "V4L2 API calls");
-
/* Add some dependency, 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,
- GST_TYPE_V4L2SRC) ||
- !gst_element_register (plugin, "v4l2sink", GST_RANK_NONE,
- GST_TYPE_V4L2SINK) ||
- !gst_element_register (plugin, "v4l2radio", GST_RANK_NONE,
- GST_TYPE_V4L2RADIO) ||
- !gst_device_provider_register (plugin, "v4l2deviceprovider",
- GST_RANK_PRIMARY, GST_TYPE_V4L2_DEVICE_PROVIDER)
- /* etc. */
#ifdef GST_V4L2_ENABLE_PROBE
- || !gst_v4l2_probe_and_register (plugin)
+ ret |= gst_v4l2_probe_and_register (plugin);
#endif
- )
- return FALSE;
-#ifdef ENABLE_NLS
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-#endif /* ENABLE_NLS */
+ ret |= GST_ELEMENT_REGISTER (v4l2src, plugin);
+ ret |= GST_ELEMENT_REGISTER (v4l2sink, plugin);
+ ret |= GST_ELEMENT_REGISTER (v4l2radio, plugin);
+ ret |= GST_DEVICE_PROVIDER_REGISTER (v4l2deviceprovider, plugin);
- return TRUE;
+ return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
#include "gstv4l2object.h"
#include "v4l2-utils.h"
+#include "gstv4l2elements.h"
#ifdef HAVE_GUDEV
#include <gudev/gudev.h>
G_DEFINE_TYPE (GstV4l2DeviceProvider, gst_v4l2_device_provider,
GST_TYPE_DEVICE_PROVIDER);
+GST_DEVICE_PROVIDER_REGISTER_DEFINE (v4l2deviceprovider, "v4l2deviceprovider",
+ GST_RANK_PRIMARY, GST_TYPE_V4L2_DEVICE_PROVIDER);
static void gst_v4l2_device_provider_finalize (GObject * object);
static GList *gst_v4l2_device_provider_probe (GstDeviceProvider * provider);
--- /dev/null
+/* GStreamer
+ *
+ * Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
+ * 2006 Edgard Lima <edgard.lima@gmail.com>
+ *
+ * gstv4l2.c: plugin for v4l2 elements
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gst/gst-i18n-plugin.h"
+#include <gst/gst.h>
+
+#include "gstv4l2elements.h"
+
+
+/* used in gstv4l2object.c and v4l2_calls.c */
+GST_DEBUG_CATEGORY (v4l2_debug);
+#define GST_CAT_DEFAULT v4l2_debug
+
+void
+v4l2_element_init (GstPlugin * plugin)
+{
+ static gsize res = FALSE;
+ if (g_once_init_enter (&res)) {
+ GST_DEBUG_CATEGORY_INIT (v4l2_debug, "v4l2", 0, "V4L2 API calls");
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+ g_once_init_leave (&res, TRUE);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2020 Julian Bouzas <julian.bouzas@collabora.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GST_V4L2_ELEMENTS_H__
+#define __GST_V4L2_ELEMENTS_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+void v4l2_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (v4l2radio);
+GST_ELEMENT_REGISTER_DECLARE (v4l2sink);
+GST_ELEMENT_REGISTER_DECLARE (v4l2src);
+GST_DEVICE_PROVIDER_REGISTER_DECLARE (v4l2deviceprovider);
+
+G_END_DECLS
+
+#endif /* __GST_V4L2_ELEMENTS_H__ */
#include "gst/gst-i18n-plugin.h"
+#include "gstv4l2elements.h"
#include "gstv4l2object.h"
#include "gstv4l2tuner.h"
#include "gstv4l2radio.h"
gst_v4l2radio_uri_handler_init);
G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER,
gst_v4l2radio_tuner_interface_reinit));
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (v4l2radio,
+ "v4l2radio", GST_RANK_NONE, GST_TYPE_V4L2RADIO, v4l2_element_init (plugin));
static void gst_v4l2radio_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
#include "gstv4l2tuner.h"
#include "gstv4l2vidorient.h"
+#include "gstv4l2elements.h"
#include "gstv4l2sink.h"
#include "gst/gst-i18n-plugin.h"
gst_v4l2sink_color_balance_interface_init);
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION,
gst_v4l2sink_video_orientation_interface_init));
-
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (v4l2sink,
+ "v4l2sink", GST_RANK_NONE, GST_TYPE_V4L2SINK, v4l2_element_init (plugin));
static void gst_v4l2sink_finalize (GstV4l2Sink * v4l2sink);
#include <gst/video/gstvideometa.h>
#include <gst/video/gstvideopool.h>
+#include "gstv4l2elements.h"
#include "gstv4l2src.h"
#include "gstv4l2colorbalance.h"
gst_v4l2src_color_balance_interface_init);
G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION,
gst_v4l2src_video_orientation_interface_init));
+GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (v4l2src,
+ "v4l2src", GST_RANK_PRIMARY, GST_TYPE_V4L2SRC, v4l2_element_init (plugin));
struct PreferredCapsInfo
{
v4l2_sources = [
'gstv4l2.c',
+ 'gstv4l2element.c',
'gstv4l2allocator.c',
'gstv4l2codec.c',
'gstv4l2colorbalance.c',