summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorStéphane Cerveau <scerveau@collabora.com>2021-02-18 15:21:40 +0100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-03-23 14:19:17 +0000
commit8fa3dd4bf370a9cc0d6b7bf0daa3a60652b3b824 (patch)
tree8a9190e2522ebf6e5d8fecb7ddde8fae65ee6799 /ext
parent7e0ad83f04d11035ced3e2f34bb2c304b4109380 (diff)
downloadgstreamer-plugins-bad-8fa3dd4bf370a9cc0d6b7bf0daa3a60652b3b824.tar.gz
openh264: 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-bad/-/merge_requests/2038>
Diffstat (limited to 'ext')
-rw-r--r--ext/openh264/gstopenh264dec.cpp14
-rw-r--r--ext/openh264/gstopenh264element.c56
-rw-r--r--ext/openh264/gstopenh264elements.h37
-rw-r--r--ext/openh264/gstopenh264enc.cpp13
-rw-r--r--ext/openh264/gstopenh264plugin.c29
-rw-r--r--ext/openh264/meson.build1
6 files changed, 129 insertions, 21 deletions
diff --git a/ext/openh264/gstopenh264dec.cpp b/ext/openh264/gstopenh264dec.cpp
index e60838048..e42dc093b 100644
--- a/ext/openh264/gstopenh264dec.cpp
+++ b/ext/openh264/gstopenh264dec.cpp
@@ -27,6 +27,7 @@
#include "config.h"
#endif
+#include "gstopenh264elements.h"
#include "gstopenh264dec.h"
#include <wels/codec_ver.h>
@@ -59,6 +60,7 @@ static GstFlowReturn gst_openh264dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
static gboolean gst_openh264dec_decide_allocation (GstVideoDecoder * decoder,
GstQuery * query);
+static gboolean openh264dec_element_init (GstPlugin * plugin);
#if HAVE_OPENH264_MAIN_PROFILE
#define SUPPORTED_PROFILE_STR "profile=(string){ constrained-baseline, baseline, main, high, constrained-high, progressive-high }"
@@ -88,6 +90,7 @@ G_DEFINE_TYPE_WITH_CODE (GstOpenh264Dec, gst_openh264dec,
GST_TYPE_VIDEO_DECODER,
GST_DEBUG_CATEGORY_INIT (gst_openh264dec_debug_category, "openh264dec", 0,
"debug category for openh264dec element"));
+GST_ELEMENT_REGISTER_DEFINE_CUSTOM (openh264dec, openh264dec_element_init);
static void
gst_openh264dec_class_init (GstOpenh264DecClass * klass)
@@ -448,3 +451,14 @@ gst_openh264dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
return TRUE;
}
+
+static gboolean
+openh264dec_element_init (GstPlugin * plugin)
+{
+ if (openh264_element_init (plugin))
+ return gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL,
+ GST_TYPE_OPENH264DEC);
+
+ GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
+ return FALSE;
+}
diff --git a/ext/openh264/gstopenh264element.c b/ext/openh264/gstopenh264element.c
new file mode 100644
index 000000000..5d8f9d376
--- /dev/null
+++ b/ext/openh264/gstopenh264element.c
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2014, Ericsson AB. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this
+ * list of conditions and the following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gst/gst.h>
+#include <wels/codec_api.h>
+#include <wels/codec_ver.h>
+#include <string.h>
+#include "gstopenh264elements.h"
+
+
+gboolean
+openh264_element_init (GstPlugin * plugin)
+{
+ static gsize res = FALSE;
+
+ if (g_once_init_enter (&res)) {
+ gsize value;
+ OpenH264Version libver;
+ /* g_stCodecVersion is the version detected at build time as defined in the
+ * headers and WelsGetCodecVersion() is the version detected at runtime.
+ * This is a safeguard to avoid crashes since OpenH264 has been changing
+ * ABI without changing the SONAME.
+ */
+ libver = WelsGetCodecVersion ();
+ value = memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0;
+ g_once_init_leave (&res, value);
+ }
+
+ return res;
+}
diff --git a/ext/openh264/gstopenh264elements.h b/ext/openh264/gstopenh264elements.h
new file mode 100644
index 000000000..572f6a8e0
--- /dev/null
+++ b/ext/openh264/gstopenh264elements.h
@@ -0,0 +1,37 @@
+/* GStreamer
+ * Copyright (C) <2020> The GStreamer Contributors.
+ *
+ * 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_OPENH264_ELEMENT_H__
+#define __GST_OPENH264_ELEMENT_H__
+
+#include <config.h>
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+gboolean openh264_element_init (GstPlugin * plugin);
+
+GST_ELEMENT_REGISTER_DECLARE (openh264dec);
+GST_ELEMENT_REGISTER_DECLARE (openh264enc);
+
+G_END_DECLS
+
+#endif /* __GST_OPENH264_ELEMENT_H__ */
diff --git a/ext/openh264/gstopenh264enc.cpp b/ext/openh264/gstopenh264enc.cpp
index 0f054592d..dff3db6dd 100644
--- a/ext/openh264/gstopenh264enc.cpp
+++ b/ext/openh264/gstopenh264enc.cpp
@@ -27,6 +27,7 @@
#include "config.h"
#endif
+#include "gstopenh264elements.h"
#include "gstopenh264enc.h"
#include <gst/gst.h>
@@ -162,6 +163,7 @@ static void gst_openh264enc_set_usage_type (GstOpenh264Enc * openh264enc,
gint usage_type);
static void gst_openh264enc_set_rate_control (GstOpenh264Enc * openh264enc,
gint rc_mode);
+static gboolean openh264enc_element_init (GstPlugin * plugin);
#define DEFAULT_BITRATE (128000)
@@ -235,6 +237,7 @@ G_DEFINE_TYPE_WITH_CODE (GstOpenh264Enc, gst_openh264enc,
G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL);
GST_DEBUG_CATEGORY_INIT (gst_openh264enc_debug_category, "openh264enc", 0,
"debug category for openh264enc element"));
+GST_ELEMENT_REGISTER_DEFINE_CUSTOM (openh264enc, openh264enc_element_init);
static void
gst_openh264enc_class_init (GstOpenh264EncClass * klass)
@@ -1056,3 +1059,13 @@ gst_openh264enc_finish (GstVideoEncoder * encoder)
return GST_FLOW_OK;
}
+static gboolean
+openh264enc_element_init (GstPlugin * plugin)
+{
+ if (openh264_element_init (plugin))
+ return gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL,
+ GST_TYPE_OPENH264ENC);
+
+ GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
+ return FALSE;
+}
diff --git a/ext/openh264/gstopenh264plugin.c b/ext/openh264/gstopenh264plugin.c
index d659a488c..715241ee1 100644
--- a/ext/openh264/gstopenh264plugin.c
+++ b/ext/openh264/gstopenh264plugin.c
@@ -31,31 +31,18 @@
#include <config.h>
#endif
-#include <gst/gst.h>
-#include <wels/codec_api.h>
-#include <wels/codec_ver.h>
-#include <string.h>
-#include "gstopenh264dec.h"
-#include "gstopenh264enc.h"
+#include "gstopenh264elements.h"
+
static gboolean
plugin_init (GstPlugin * plugin)
{
- /* g_stCodecVersion is the version detected at build time as defined in the
- * headers and WelsGetCodecVersion() is the version detected at runtime.
- * This is a safeguard to avoid crashes since OpenH264 has been changing
- * ABI without changing the SONAME.
- */
- OpenH264Version libver = WelsGetCodecVersion ();
- if (memcmp (&libver, &g_stCodecVersion, sizeof (libver)) == 0) {
- gst_element_register (plugin, "openh264dec", GST_RANK_MARGINAL,
- GST_TYPE_OPENH264DEC);
- gst_element_register (plugin, "openh264enc", GST_RANK_MARGINAL,
- GST_TYPE_OPENH264ENC);
- } else {
- GST_ERROR ("Incorrect library version loaded, expecting %s", g_strCodecVer);
- }
- return TRUE;
+ gboolean ret = FALSE;
+
+ ret |= GST_ELEMENT_REGISTER (openh264dec, plugin);
+ ret |= GST_ELEMENT_REGISTER (openh264enc, plugin);
+
+ return ret;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
diff --git a/ext/openh264/meson.build b/ext/openh264/meson.build
index 7f893cf91..6147f9e3d 100644
--- a/ext/openh264/meson.build
+++ b/ext/openh264/meson.build
@@ -1,6 +1,7 @@
openh264_sources = [
'gstopenh264dec.cpp',
'gstopenh264enc.cpp',
+ 'gstopenh264element.c',
'gstopenh264plugin.c',
]