From 891be511057dbcdf1f38740e55cbd376c4b25894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Thu, 25 Feb 2021 15:22:15 +0100 Subject: gst-plugins: 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: --- gst/transcode/gsttranscodebin.c | 33 +++++--------------------- gst/transcode/gsttranscodeelement.c | 46 ++++++++++++++++++++++++++++++++++++ gst/transcode/gsttranscodeelements.h | 33 ++++++++++++++++++++++++++ gst/transcode/gsttranscodeplugin.c | 43 +++++++++++++++++++++++++++++++++ gst/transcode/gsturitranscodebin.c | 6 ++++- gst/transcode/meson.build | 2 ++ 6 files changed, 135 insertions(+), 28 deletions(-) create mode 100644 gst/transcode/gsttranscodeelement.c create mode 100644 gst/transcode/gsttranscodeelements.h create mode 100644 gst/transcode/gsttranscodeplugin.c (limited to 'gst/transcode') diff --git a/gst/transcode/gsttranscodebin.c b/gst/transcode/gsttranscodebin.c index e5c041c59..0ceb163ca 100644 --- a/gst/transcode/gsttranscodebin.c +++ b/gst/transcode/gsttranscodebin.c @@ -23,13 +23,13 @@ #endif #include "gsttranscoding.h" +#include "gsttranscodeelements.h" #include #include #include -GST_DEBUG_CATEGORY_STATIC (gst_transcodebin_debug); -#define GST_CAT_DEFAULT gst_transcodebin_debug + /** * GstTranscodeBin!sink_%u: @@ -123,7 +123,10 @@ typedef struct #define DEFAULT_AVOID_REENCODING FALSE -G_DEFINE_TYPE (GstTranscodeBin, gst_transcode_bin, GST_TYPE_BIN) +G_DEFINE_TYPE (GstTranscodeBin, gst_transcode_bin, GST_TYPE_BIN); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (transcodebin, "transcodebin", GST_RANK_NONE, + GST_TYPE_TRANSCODE_BIN, transcodebin_element_init (plugin)); + enum { PROP_0, @@ -1011,27 +1014,3 @@ gst_transcode_bin_init (GstTranscodeBin * self) make_decodebin (self); } - -static gboolean -plugin_init (GstPlugin * plugin) -{ - gboolean res = TRUE; - gst_pb_utils_init (); - - GST_DEBUG_CATEGORY_INIT (gst_transcodebin_debug, "transcodebin", 0, - "Transcodebin element"); - - res &= gst_element_register (plugin, "transcodebin", GST_RANK_NONE, - GST_TYPE_TRANSCODE_BIN); - - res &= gst_element_register (plugin, "uritranscodebin", GST_RANK_NONE, - gst_uri_transcode_bin_get_type ()); - - return res; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - transcode, - "A plugin containing elements for transcoding", plugin_init, VERSION, - GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/gst/transcode/gsttranscodeelement.c b/gst/transcode/gsttranscodeelement.c new file mode 100644 index 000000000..7fae04b1a --- /dev/null +++ b/gst/transcode/gsttranscodeelement.c @@ -0,0 +1,46 @@ + +/* GStreamer + * Copyright (C) 2019 Thibault Saunier + * + * gsttranscodebin.c: + * + * 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 "gsttranscodeelements.h" +#include +#include + +#include + +GST_DEBUG_CATEGORY_STATIC (gst_transcodebin_debug); +#define GST_CAT_DEFAULT gst_transcodebin_debug + +void +transcodebin_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + + if (g_once_init_enter (&res)) { + gst_pb_utils_init (); + GST_DEBUG_CATEGORY_INIT (gst_transcodebin_debug, "transcodebin", 0, + "Transcodebin element"); + g_once_init_leave (&res, TRUE); + } +} diff --git a/gst/transcode/gsttranscodeelements.h b/gst/transcode/gsttranscodeelements.h new file mode 100644 index 000000000..25d6df366 --- /dev/null +++ b/gst/transcode/gsttranscodeelements.h @@ -0,0 +1,33 @@ +/* GStreamer + * Copyright (C) 2015 Thibault Saunier + * + * gsttranscodebin.c: + * + * 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_TRANSCODE_ELEMENTS_H__ +#define __GST_TRANSCODE_ELEMENTS_H__ + + +#include + +void transcodebin_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (transcodebin); +GST_ELEMENT_REGISTER_DECLARE (uritranscodebin); + +#endif /* __GST_TRANSCODE_ELEMENTS_H__ */ diff --git a/gst/transcode/gsttranscodeplugin.c b/gst/transcode/gsttranscodeplugin.c new file mode 100644 index 000000000..78fb88a95 --- /dev/null +++ b/gst/transcode/gsttranscodeplugin.c @@ -0,0 +1,43 @@ +/* GStreamer + * Copyright (C) 2019 Thibault Saunier + * + * gsttranscodebin.c: + * + * 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 "gsttranscodeelements.h" + + +static gboolean +plugin_init (GstPlugin * plugin) +{ + gboolean res = FALSE; + + res |= GST_ELEMENT_REGISTER (transcodebin, plugin); + res |= GST_ELEMENT_REGISTER (uritranscodebin, plugin); + + return res; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + transcode, + "A plugin containing elements for transcoding", plugin_init, VERSION, + GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/gst/transcode/gsturitranscodebin.c b/gst/transcode/gsturitranscodebin.c index c51ea37ac..8cf13d380 100644 --- a/gst/transcode/gsturitranscodebin.c +++ b/gst/transcode/gsturitranscodebin.c @@ -23,6 +23,7 @@ #endif #include "gsttranscoding.h" +#include "gsttranscodeelements.h" #if HAVE_GETRUSAGE #include "gst-cpu-throttling-clock.h" #endif @@ -73,7 +74,10 @@ typedef struct #define DEFAULT_AVOID_REENCODING FALSE -G_DEFINE_TYPE (GstUriTranscodeBin, gst_uri_transcode_bin, GST_TYPE_PIPELINE) +G_DEFINE_TYPE (GstUriTranscodeBin, gst_uri_transcode_bin, GST_TYPE_PIPELINE); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (uritranscodebin, "uritranscodebin", GST_RANK_NONE, + gst_uri_transcode_bin_get_type (), transcodebin_element_init (plugin)); + enum { PROP_0, diff --git a/gst/transcode/meson.build b/gst/transcode/meson.build index a28af9a15..080623e52 100644 --- a/gst/transcode/meson.build +++ b/gst/transcode/meson.build @@ -1,4 +1,6 @@ gsttranscoder_plugin = library('gsttranscode', + 'gsttranscodeelement.c', + 'gsttranscodeplugin.c', 'gsttranscodebin.c', 'gst-cpu-throttling-clock.c', 'gsturitranscodebin.c', -- cgit v1.2.1