Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gst-plugins-good.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2021-02-16 17:29:06 +0300
committerStéphane Cerveau <scerveau@collabora.com>2021-03-29 13:45:23 +0300
commitb20209ce0dab66b4bf4b607541d6c76f786d2867 (patch)
tree471cee5776ee59ce26a4928aa36f99dd42862b00 /sys
parent7cd54ccfc1a5b8b45d3f8342c24ea3291735173d (diff)
v4l2: allow per feature registration
Split plugin into features including dynamic types which can be indiviually registered during a static build. More details here: https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199 https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/876>
Diffstat (limited to 'sys')
-rw-r--r--sys/v4l2/gstv4l2.c32
-rw-r--r--sys/v4l2/gstv4l2deviceprovider.c3
-rw-r--r--sys/v4l2/gstv4l2element.c50
-rw-r--r--sys/v4l2/gstv4l2elements.h39
-rw-r--r--sys/v4l2/gstv4l2radio.c3
-rw-r--r--sys/v4l2/gstv4l2sink.c4
-rw-r--r--sys/v4l2/gstv4l2src.c3
-rw-r--r--sys/v4l2/meson.build1
8 files changed, 110 insertions, 25 deletions
diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c
index cd75ec553..dbdcff456 100644
--- a/sys/v4l2/gstv4l2.c
+++ b/sys/v4l2/gstv4l2.c
@@ -40,6 +40,7 @@
#include <unistd.h>
#include "ext/videodev2.h"
+#include "gstv4l2elements.h"
#include "v4l2-utils.h"
#include "gstv4l2object.h"
@@ -55,13 +56,8 @@
#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 *
@@ -248,37 +244,25 @@ gst_v4l2_probe_and_register (GstPlugin * plugin)
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,
diff --git a/sys/v4l2/gstv4l2deviceprovider.c b/sys/v4l2/gstv4l2deviceprovider.c
index 83efe0a8d..7c2c87fea 100644
--- a/sys/v4l2/gstv4l2deviceprovider.c
+++ b/sys/v4l2/gstv4l2deviceprovider.c
@@ -32,6 +32,7 @@
#include "gstv4l2object.h"
#include "v4l2-utils.h"
+#include "gstv4l2elements.h"
#ifdef HAVE_GUDEV
#include <gudev/gudev.h>
@@ -44,6 +45,8 @@ static GstV4l2Device *gst_v4l2_device_new (const gchar * device_path,
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);
diff --git a/sys/v4l2/gstv4l2element.c b/sys/v4l2/gstv4l2element.c
new file mode 100644
index 000000000..e547e3be7
--- /dev/null
+++ b/sys/v4l2/gstv4l2element.c
@@ -0,0 +1,50 @@
+/* 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);
+ }
+}
diff --git a/sys/v4l2/gstv4l2elements.h b/sys/v4l2/gstv4l2elements.h
new file mode 100644
index 000000000..51c20ff03
--- /dev/null
+++ b/sys/v4l2/gstv4l2elements.h
@@ -0,0 +1,39 @@
+/*
+ * 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__ */
diff --git a/sys/v4l2/gstv4l2radio.c b/sys/v4l2/gstv4l2radio.c
index 5cbc18c14..c375492d0 100644
--- a/sys/v4l2/gstv4l2radio.c
+++ b/sys/v4l2/gstv4l2radio.c
@@ -44,6 +44,7 @@
#include "gst/gst-i18n-plugin.h"
+#include "gstv4l2elements.h"
#include "gstv4l2object.h"
#include "gstv4l2tuner.h"
#include "gstv4l2radio.h"
@@ -273,6 +274,8 @@ G_DEFINE_TYPE_WITH_CODE (GstV4l2Radio, gst_v4l2radio, GST_TYPE_ELEMENT,
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);
diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c
index e4728ac70..cc601ac94 100644
--- a/sys/v4l2/gstv4l2sink.c
+++ b/sys/v4l2/gstv4l2sink.c
@@ -59,6 +59,7 @@
#include "gstv4l2tuner.h"
#include "gstv4l2vidorient.h"
+#include "gstv4l2elements.h"
#include "gstv4l2sink.h"
#include "gst/gst-i18n-plugin.h"
@@ -95,7 +96,8 @@ G_DEFINE_TYPE_WITH_CODE (GstV4l2Sink, gst_v4l2sink, GST_TYPE_VIDEO_SINK,
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);
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index ca74b9a9c..d00f7a80d 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -54,6 +54,7 @@
#include <gst/video/gstvideometa.h>
#include <gst/video/gstvideopool.h>
+#include "gstv4l2elements.h"
#include "gstv4l2src.h"
#include "gstv4l2colorbalance.h"
@@ -98,6 +99,8 @@ G_DEFINE_TYPE_WITH_CODE (GstV4l2Src, gst_v4l2src, GST_TYPE_PUSH_SRC,
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
{
diff --git a/sys/v4l2/meson.build b/sys/v4l2/meson.build
index a1222f0d9..65f551fb6 100644
--- a/sys/v4l2/meson.build
+++ b/sys/v4l2/meson.build
@@ -1,5 +1,6 @@
v4l2_sources = [
'gstv4l2.c',
+ 'gstv4l2element.c',
'gstv4l2allocator.c',
'gstv4l2codec.c',
'gstv4l2colorbalance.c',