diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index aa0ec50351..c46ac22c08 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -99,7 +99,7 @@ #include #include "gstplay-enum.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstrawcaps.h" #include "gstplaybackutils.h" @@ -584,37 +584,29 @@ static GstPadProbeReturn pad_event_cb (GstPad * pad, GstPadProbeInfo * info, * Standard GObject boilerplate * ********************************/ -static void gst_decode_bin_class_init (GstDecodeBinClass * klass); -static void gst_decode_bin_init (GstDecodeBin * decode_bin); static void gst_decode_bin_dispose (GObject * object); static void gst_decode_bin_finalize (GObject * object); -static GType -gst_decode_bin_get_type (void) -{ - static GType gst_decode_bin_type = 0; +/* Register some quarks here for the stream topology message */ +static GQuark topology_structure_name = 0; +static GQuark topology_caps = 0; +static GQuark topology_next = 0; +static GQuark topology_pad = 0; +static GQuark topology_element_srcpad = 0; - if (!gst_decode_bin_type) { - static const GTypeInfo gst_decode_bin_info = { - sizeof (GstDecodeBinClass), - NULL, - NULL, - (GClassInitFunc) gst_decode_bin_class_init, - NULL, - NULL, - sizeof (GstDecodeBin), - 0, - (GInstanceInitFunc) gst_decode_bin_init, - NULL - }; +GType gst_decode_bin_get_type (void); +G_DEFINE_TYPE (GstDecodeBin, gst_decode_bin, GST_TYPE_BIN); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_decode_bin_debug, "decodebin", 0, "decoder bin");\ + topology_structure_name = g_quark_from_static_string ("stream-topology"); \ + topology_caps = g_quark_from_static_string ("caps");\ + topology_next = g_quark_from_static_string ("next");\ + topology_pad = g_quark_from_static_string ("pad");\ + topology_element_srcpad = g_quark_from_static_string ("element-srcpad");\ + ret |= playback_element_init (plugin);\ - gst_decode_bin_type = - g_type_register_static (GST_TYPE_BIN, "GstDecodeBin", - &gst_decode_bin_info, 0); - } - - return gst_decode_bin_type; -} +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decodebin, "decodebin", GST_RANK_NONE, + GST_TYPE_DECODE_BIN, _do_init); static gboolean _gst_boolean_accumulator (GSignalInvocationHint * ihint, @@ -4527,12 +4519,6 @@ _gst_element_get_linked_caps (GstElement * src, GstElement * sink, return caps; } -static GQuark topology_structure_name = 0; -static GQuark topology_caps = 0; -static GQuark topology_next = 0; -static GQuark topology_pad = 0; -static GQuark topology_element_srcpad = 0; - /* FIXME: Invent gst_structure_take_structure() to prevent all the * structure copying for nothing */ @@ -5704,19 +5690,3 @@ gst_decode_bin_remove_element (GstBin * bin, GstElement * element) return GST_BIN_CLASS (parent_class)->remove_element (bin, element); } - -gboolean -gst_decode_bin_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_decode_bin_debug, "decodebin", 0, "decoder bin"); - - /* Register some quarks here for the stream topology message */ - topology_structure_name = g_quark_from_static_string ("stream-topology"); - topology_caps = g_quark_from_static_string ("caps"); - topology_next = g_quark_from_static_string ("next"); - topology_pad = g_quark_from_static_string ("pad"); - topology_element_srcpad = g_quark_from_static_string ("element-srcpad"); - - return gst_element_register (plugin, "decodebin", GST_RANK_NONE, - GST_TYPE_DECODE_BIN); -} diff --git a/gst/playback/gstdecodebin3.c b/gst/playback/gstdecodebin3.c index 653aa94890..b932903572 100644 --- a/gst/playback/gstdecodebin3.c +++ b/gst/playback/gstdecodebin3.c @@ -30,7 +30,7 @@ #include #include -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplay-enum.h" #include "gstrawcaps.h" @@ -425,6 +425,11 @@ static guint gst_decodebin3_signals[LAST_SIGNAL] = { 0 }; GType gst_decodebin3_get_type (void); #define gst_decodebin3_parent_class parent_class G_DEFINE_TYPE (GstDecodebin3, gst_decodebin3, GST_TYPE_BIN); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (decodebin3_debug, "decodebin3", 0, "decoder bin");\ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (decodebin3, "decodebin3", GST_RANK_NONE, + GST_TYPE_DECODEBIN3, _do_init); static GstStaticCaps default_raw_caps = GST_STATIC_CAPS (DEFAULT_RAW_CAPS); @@ -3011,12 +3016,3 @@ gst_decodebin3_change_state (GstElement * element, GstStateChange transition) beach: return ret; } - -gboolean -gst_decodebin3_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (decodebin3_debug, "decodebin3", 0, "decoder bin"); - - return gst_element_register (plugin, "decodebin3", GST_RANK_NONE, - GST_TYPE_DECODEBIN3); -} diff --git a/gst/playback/gstparsebin.c b/gst/playback/gstparsebin.c index 4f9f8b6bad..ab3b587652 100644 --- a/gst/playback/gstparsebin.c +++ b/gst/playback/gstparsebin.c @@ -104,7 +104,7 @@ #include #include "gstplay-enum.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplaybackutils.h" #include "gstrawcaps.h" @@ -495,37 +495,16 @@ static GstPadProbeReturn pad_event_cb (GstPad * pad, GstPadProbeInfo * info, * Standard GObject boilerplate * ********************************/ -static void gst_parse_bin_class_init (GstParseBinClass * klass); -static void gst_parse_bin_init (GstParseBin * parse_bin); static void gst_parse_bin_dispose (GObject * object); static void gst_parse_bin_finalize (GObject * object); +static GType gst_parse_bin_get_type (void); -static GType -gst_parse_bin_get_type (void) -{ - static GType gst_parse_bin_type = 0; - - if (!gst_parse_bin_type) { - static const GTypeInfo gst_parse_bin_info = { - sizeof (GstParseBinClass), - NULL, - NULL, - (GClassInitFunc) gst_parse_bin_class_init, - NULL, - NULL, - sizeof (GstParseBin), - 0, - (GInstanceInitFunc) gst_parse_bin_init, - NULL - }; - - gst_parse_bin_type = - g_type_register_static (GST_TYPE_BIN, "GstParseBin", - &gst_parse_bin_info, 0); - } - - return gst_parse_bin_type; -} +G_DEFINE_TYPE (GstParseBin, gst_parse_bin, GST_TYPE_BIN); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_parse_bin_debug, "parsebin", 0, "parser bin");\ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (parsebin, "parsebin", GST_RANK_NONE, + GST_TYPE_PARSE_BIN, _do_init); static gboolean _gst_boolean_accumulator (GSignalInvocationHint * ihint, @@ -4399,12 +4378,3 @@ gst_parse_bin_handle_message (GstBin * bin, GstMessage * msg) else GST_BIN_CLASS (parent_class)->handle_message (bin, msg); } - -gboolean -gst_parse_bin_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_parse_bin_debug, "parsebin", 0, "parser bin"); - - return gst_element_register (plugin, "parsebin", GST_RANK_NONE, - GST_TYPE_PARSE_BIN); -} diff --git a/gst/playback/gstplayback.h b/gst/playback/gstplaybackelement.c similarity index 51% rename from gst/playback/gstplayback.h rename to gst/playback/gstplaybackelement.c index 26e3683cfd..7ac053b567 100644 --- a/gst/playback/gstplayback.h +++ b/gst/playback/gstplaybackelement.c @@ -1,5 +1,7 @@ /* GStreamer * Copyright (C) <2007> Wim Taymans + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -16,23 +18,38 @@ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, * Boston, MA 02110-1301, USA. */ +/** + * SECTION:plugin-playback: + * @short_description: Set of elements to create dynamic pipelines (or part of it) to play + * media files. + */ -#ifndef __GST_PLAY_BACK_H__ -#define __GST_PLAY_BACK_H__ - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include -gboolean gst_decode_bin_plugin_init (GstPlugin * plugin); -gboolean gst_decodebin3_plugin_init (GstPlugin * plugin); -gboolean gst_uri_decode_bin_plugin_init (GstPlugin * plugin); -gboolean gst_uri_decode_bin3_plugin_init (GstPlugin * plugin); -gboolean gst_uri_source_bin_plugin_init (GstPlugin * plugin); -gboolean gst_parse_bin_plugin_init (GstPlugin * plugin); +#include +#include -gboolean gst_play_bin_plugin_init (GstPlugin * plugin); -gboolean gst_play_bin2_plugin_init (GstPlugin * plugin); -gboolean gst_play_bin3_plugin_init (GstPlugin * plugin, gboolean as_playbin); +#include "gstplaybackelements.h" -#endif /* __GST_PLAY_BACK_H__ */ +gboolean +playback_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + if (g_once_init_enter (&res)) { + gst_pb_utils_init (); + +#ifdef ENABLE_NLS + GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, + LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +#endif /* ENABLE_NLS */ + g_once_init_leave (&res, TRUE); + } + return res; +} diff --git a/gst/playback/gstplaybackelements.h b/gst/playback/gstplaybackelements.h new file mode 100644 index 0000000000..e08608df43 --- /dev/null +++ b/gst/playback/gstplaybackelements.h @@ -0,0 +1,44 @@ +/* GStreamer + * Copyright (C) <2007> Wim Taymans + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Stéphane Cerveau + * + * 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_PLAY_BACK_ELEMENTS_H__ +#define __GST_PLAY_BACK_ELEMENTS_H__ + +#include + +GST_ELEMENT_REGISTER_DECLARE (playbin); +GST_ELEMENT_REGISTER_DECLARE (playbin3); +GST_ELEMENT_REGISTER_DECLARE (playsink); +GST_ELEMENT_REGISTER_DECLARE (subtitleoverlay); +GST_ELEMENT_REGISTER_DECLARE (streamsynchronizer); +GST_ELEMENT_REGISTER_DECLARE (decodebin); +GST_ELEMENT_REGISTER_DECLARE (decodebin3); +GST_ELEMENT_REGISTER_DECLARE (uridecodebin); +GST_ELEMENT_REGISTER_DECLARE (uridecodebin3); +GST_ELEMENT_REGISTER_DECLARE (urisourcebin); +GST_ELEMENT_REGISTER_DECLARE (parsebin); + +gboolean gst_play_bin_custom_element_init (GstPlugin * plugin); +gboolean gst_play_bin3_custom_element_init (GstPlugin * plugin); + +G_GNUC_INTERNAL gboolean playback_element_init (GstPlugin * plugin); + +#endif /* __GST_PLAY_BACK_ELEMENTS_H__ */ diff --git a/gst/playback/gstplayback.c b/gst/playback/gstplaybackplugin.c similarity index 54% rename from gst/playback/gstplayback.c rename to gst/playback/gstplaybackplugin.c index 248e9cd00f..95d438dc3d 100644 --- a/gst/playback/gstplayback.c +++ b/gst/playback/gstplaybackplugin.c @@ -32,45 +32,25 @@ #include #include -#include "gstplayback.h" -#include "gstplaysink.h" -#include "gstsubtitleoverlay.h" -#include "gststreamsynchronizer.h" +#include "gstplaybackelements.h" + static gboolean plugin_init (GstPlugin * plugin) { - gboolean res; - - gst_pb_utils_init (); - -#ifdef ENABLE_NLS - GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE, - LOCALEDIR); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); -#endif /* ENABLE_NLS */ - - /* Swap in playbin3 as 'playbin' if USE_PLAYBIN3=1 */ - { - const gchar *env = g_getenv ("USE_PLAYBIN3"); - if (env && g_str_has_prefix (env, "1")) - res = gst_play_bin3_plugin_init (plugin, TRUE); - else - res = gst_play_bin2_plugin_init (plugin); - } - - res &= gst_play_bin3_plugin_init (plugin, FALSE); - res &= gst_play_sink_plugin_init (plugin); - res &= gst_subtitle_overlay_plugin_init (plugin); - res &= gst_stream_synchronizer_plugin_init (plugin); - - res &= gst_decode_bin_plugin_init (plugin); - res &= gst_decodebin3_plugin_init (plugin); - res &= gst_uri_decode_bin_plugin_init (plugin); - res &= gst_uri_decode_bin3_plugin_init (plugin); - res &= gst_uri_source_bin_plugin_init (plugin); - res &= gst_parse_bin_plugin_init (plugin); + gboolean res = FALSE; + if (!g_getenv ("USE_PLAYBIN3")) + res |= GST_ELEMENT_REGISTER (playbin, plugin); + res |= GST_ELEMENT_REGISTER (playbin3, plugin); + res |= GST_ELEMENT_REGISTER (playsink, plugin); + res |= GST_ELEMENT_REGISTER (subtitleoverlay, plugin); + res |= GST_ELEMENT_REGISTER (streamsynchronizer, plugin); + res |= GST_ELEMENT_REGISTER (decodebin, plugin); + res |= GST_ELEMENT_REGISTER (decodebin3, plugin); + res |= GST_ELEMENT_REGISTER (uridecodebin, plugin); + res |= GST_ELEMENT_REGISTER (uridecodebin3, plugin); + res |= GST_ELEMENT_REGISTER (urisourcebin, plugin); + res |= GST_ELEMENT_REGISTER (parsebin, plugin); return res; } diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index a8d719f228..c13bfa80cd 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -216,7 +216,7 @@ #include #include #include "gstplay-enum.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplaysink.h" #include "gstsubtitleoverlay.h" #include "gstplaybackutils.h" @@ -591,8 +591,6 @@ enum static GstStaticCaps raw_audio_caps = GST_STATIC_CAPS ("audio/x-raw(ANY)"); static GstStaticCaps raw_video_caps = GST_STATIC_CAPS ("video/x-raw(ANY)"); -static void gst_play_bin_class_init (GstPlayBinClass * klass); -static void gst_play_bin_init (GstPlayBin * playbin); static void gst_play_bin_finalize (GObject * object); static void gst_play_bin_set_property (GObject * object, guint prop_id, @@ -655,57 +653,43 @@ static void gst_play_bin_navigation_init (gpointer g_iface, static void gst_play_bin_colorbalance_init (gpointer g_iface, gpointer g_iface_data); -static GType -gst_play_bin_get_type (void) -{ - static GType gst_play_bin_type = 0; - - if (!gst_play_bin_type) { - static const GTypeInfo gst_play_bin_info = { - sizeof (GstPlayBinClass), - NULL, - NULL, - (GClassInitFunc) gst_play_bin_class_init, - NULL, - NULL, - sizeof (GstPlayBin), - 0, - (GInstanceInitFunc) gst_play_bin_init, - NULL - }; - static const GInterfaceInfo svol_info = { - NULL, NULL, NULL - }; - static const GInterfaceInfo ov_info = { - gst_play_bin_overlay_init, - NULL, NULL - }; - static const GInterfaceInfo nav_info = { - gst_play_bin_navigation_init, - NULL, NULL - }; - static const GInterfaceInfo col_info = { - gst_play_bin_colorbalance_init, - NULL, NULL - }; - - gst_play_bin_type = g_type_register_static (GST_TYPE_PIPELINE, - "GstPlayBin", &gst_play_bin_info, 0); - - g_type_add_interface_static (gst_play_bin_type, GST_TYPE_STREAM_VOLUME, - &svol_info); - g_type_add_interface_static (gst_play_bin_type, GST_TYPE_VIDEO_OVERLAY, - &ov_info); - g_type_add_interface_static (gst_play_bin_type, GST_TYPE_NAVIGATION, - &nav_info); - g_type_add_interface_static (gst_play_bin_type, GST_TYPE_COLOR_BALANCE, - &col_info); - } - - return gst_play_bin_type; -} +static GType gst_play_bin_get_type (void); static void +_do_init_type (GType type) +{ + + static const GInterfaceInfo svol_info = { + NULL, NULL, NULL + }; + static const GInterfaceInfo ov_info = { + gst_play_bin_overlay_init, + NULL, NULL + }; + static const GInterfaceInfo nav_info = { + gst_play_bin_navigation_init, + NULL, NULL + }; + static const GInterfaceInfo col_info = { + gst_play_bin_colorbalance_init, + NULL, NULL + }; + + g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info); + g_type_add_interface_static (type, GST_TYPE_VIDEO_OVERLAY, &ov_info); + g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &nav_info); + g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, &col_info); +} + +G_DEFINE_TYPE_WITH_CODE (GstPlayBin, gst_play_bin, GST_TYPE_PIPELINE, + _do_init_type (g_define_type_id)); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin");\ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (playbin, "playbin", GST_RANK_NONE, + GST_TYPE_PLAY_BIN, _do_init); + +void gst_play_bin_class_init (GstPlayBinClass * klass) { GObjectClass *gobject_klass; @@ -6091,12 +6075,3 @@ gst_play_bin_colorbalance_init (gpointer g_iface, gpointer g_iface_data) iface->get_value = gst_play_bin_colorbalance_get_value; iface->get_balance_type = gst_play_bin_colorbalance_get_balance_type; } - -gboolean -gst_play_bin2_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_play_bin_debug, "playbin", 0, "play bin"); - - return gst_element_register (plugin, "playbin", GST_RANK_NONE, - GST_TYPE_PLAY_BIN); -} diff --git a/gst/playback/gstplaybin3.c b/gst/playback/gstplaybin3.c index 323dc1ffee..753e12df89 100644 --- a/gst/playback/gstplaybin3.c +++ b/gst/playback/gstplaybin3.c @@ -228,7 +228,7 @@ #include #include #include "gstplay-enum.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplaysink.h" #include "gstsubtitleoverlay.h" #include "gstplaybackutils.h" @@ -601,8 +601,6 @@ static GstStaticCaps raw_audio_caps = GST_STATIC_CAPS ("audio/x-raw(ANY)"); static GstStaticCaps raw_video_caps = GST_STATIC_CAPS ("video/x-raw(ANY)"); #endif -static void gst_play_bin3_class_init (GstPlayBin3Class * klass); -static void gst_play_bin3_init (GstPlayBin3 * playbin); static void gst_play_bin3_finalize (GObject * object); static void gst_play_bin3_set_property (GObject * object, guint prop_id, @@ -653,56 +651,38 @@ static void gst_play_bin3_navigation_init (gpointer g_iface, static void gst_play_bin3_colorbalance_init (gpointer g_iface, gpointer g_iface_data); -static GType -gst_play_bin3_get_type (void) +static void +_do_init_type (GType type) { - static GType gst_play_bin3_type = 0; + static const GInterfaceInfo svol_info = { + NULL, NULL, NULL + }; + static const GInterfaceInfo ov_info = { + gst_play_bin3_overlay_init, + NULL, NULL + }; + static const GInterfaceInfo nav_info = { + gst_play_bin3_navigation_init, + NULL, NULL + }; + static const GInterfaceInfo col_info = { + gst_play_bin3_colorbalance_init, + NULL, NULL + }; - if (!gst_play_bin3_type) { - static const GTypeInfo gst_play_bin3_info = { - sizeof (GstPlayBin3Class), - NULL, - NULL, - (GClassInitFunc) gst_play_bin3_class_init, - NULL, - NULL, - sizeof (GstPlayBin3), - 0, - (GInstanceInitFunc) gst_play_bin3_init, - NULL - }; - static const GInterfaceInfo svol_info = { - NULL, NULL, NULL - }; - static const GInterfaceInfo ov_info = { - gst_play_bin3_overlay_init, - NULL, NULL - }; - static const GInterfaceInfo nav_info = { - gst_play_bin3_navigation_init, - NULL, NULL - }; - static const GInterfaceInfo col_info = { - gst_play_bin3_colorbalance_init, - NULL, NULL - }; - - gst_play_bin3_type = g_type_register_static (GST_TYPE_PIPELINE, - "GstPlayBin3", &gst_play_bin3_info, 0); - - g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_STREAM_VOLUME, - &svol_info); - g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_VIDEO_OVERLAY, - &ov_info); - g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_NAVIGATION, - &nav_info); - g_type_add_interface_static (gst_play_bin3_type, GST_TYPE_COLOR_BALANCE, - &col_info); - } - - return gst_play_bin3_type; + g_type_add_interface_static (type, GST_TYPE_STREAM_VOLUME, &svol_info); + g_type_add_interface_static (type, GST_TYPE_VIDEO_OVERLAY, &ov_info); + g_type_add_interface_static (type, GST_TYPE_NAVIGATION, &nav_info); + g_type_add_interface_static (type, GST_TYPE_COLOR_BALANCE, &col_info); } +static GType gst_play_bin3_get_type (void); +G_DEFINE_TYPE_WITH_CODE (GstPlayBin3, gst_play_bin3, GST_TYPE_PIPELINE, + _do_init_type (g_define_type_id)); + +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (playbin3, + gst_play_bin3_custom_element_init); + static void gst_play_bin3_class_init (GstPlayBin3Class * klass) { @@ -5168,14 +5148,20 @@ gst_play_bin3_colorbalance_init (gpointer g_iface, gpointer g_iface_data) } gboolean -gst_play_bin3_plugin_init (GstPlugin * plugin, gboolean as_playbin) +gst_play_bin3_custom_element_init (GstPlugin * plugin) { - GST_DEBUG_CATEGORY_INIT (gst_play_bin3_debug, "playbin3", 0, "play bin"); + gboolean ret = TRUE; - if (as_playbin) - return gst_element_register (plugin, "playbin", GST_RANK_NONE, + GST_DEBUG_CATEGORY_INIT (gst_play_bin3_debug, "playbin3", 0, "play bin3"); + + ret &= playback_element_init (plugin); + + if (g_getenv ("USE_PLAYBIN3")) + ret &= gst_element_register (plugin, "playbin", GST_RANK_NONE, + GST_TYPE_PLAY_BIN); + else + ret &= gst_element_register (plugin, "playbin3", GST_RANK_NONE, GST_TYPE_PLAY_BIN); - return gst_element_register (plugin, "playbin3", GST_RANK_NONE, - GST_TYPE_PLAY_BIN); + return ret; } diff --git a/gst/playback/gstplaysink.c b/gst/playback/gstplaysink.c index e626fcf11d..c53a5f1aac 100644 --- a/gst/playback/gstplaysink.c +++ b/gst/playback/gstplaysink.c @@ -33,6 +33,7 @@ #include #include +#include "gstplaybackelements.h" #include "gstplaysink.h" #include "gststreamsynchronizer.h" #include "gstplaysinkvideoconvert.h" @@ -412,7 +413,7 @@ static void gst_play_sink_colorbalance_init (gpointer g_iface, gpointer g_iface_data); static void -_do_init (GType type) +_do_init_type (GType type) { static const GInterfaceInfo svol_info = { NULL, NULL, NULL @@ -437,7 +438,13 @@ _do_init (GType type) } G_DEFINE_TYPE_WITH_CODE (GstPlaySink, gst_play_sink, GST_TYPE_BIN, - _do_init (g_define_type_id)); + _do_init_type (g_define_type_id)); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_play_sink_debug, "playsink", 0, "play sink");\ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (playsink, "playsink", GST_RANK_NONE, + GST_TYPE_PLAY_SINK, _do_init); + static void gst_play_sink_class_init (GstPlaySinkClass * klass) @@ -5521,11 +5528,3 @@ gst_play_sink_colorbalance_init (gpointer g_iface, gpointer g_iface_data) iface->get_value = gst_play_sink_colorbalance_get_value; iface->get_balance_type = gst_play_sink_colorbalance_get_balance_type; } - -gboolean -gst_play_sink_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_play_sink_debug, "playsink", 0, "play bin"); - return gst_element_register (plugin, "playsink", GST_RANK_NONE, - GST_TYPE_PLAY_SINK); -} diff --git a/gst/playback/gstplaysink.h b/gst/playback/gstplaysink.h index fa19d9df72..b3a3d8f9ae 100644 --- a/gst/playback/gstplaysink.h +++ b/gst/playback/gstplaysink.h @@ -101,8 +101,6 @@ GstSample * gst_play_sink_convert_sample (GstPlaySink * playsink, GstCaps gboolean gst_play_sink_reconfigure (GstPlaySink * playsink); -gboolean gst_play_sink_plugin_init (GstPlugin * plugin); - G_END_DECLS #endif /* __GST_PLAY_SINK_H__ */ diff --git a/gst/playback/gststreamsynchronizer.c b/gst/playback/gststreamsynchronizer.c index 41836f79b7..082e8b0bc6 100644 --- a/gst/playback/gststreamsynchronizer.c +++ b/gst/playback/gststreamsynchronizer.c @@ -21,6 +21,7 @@ #include "config.h" #endif +#include "gstplaybackelements.h" #include "gststreamsynchronizer.h" GST_DEBUG_CATEGORY_STATIC (stream_synchronizer_debug); @@ -55,6 +56,10 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink_%u", #define gst_stream_synchronizer_parent_class parent_class G_DEFINE_TYPE (GstStreamSynchronizer, gst_stream_synchronizer, GST_TYPE_ELEMENT); +#define _do_init \ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (streamsynchronizer, "streamsynchronizer", + GST_RANK_NONE, GST_TYPE_STREAM_SYNCHRONIZER, _do_init); typedef struct { @@ -1193,14 +1198,7 @@ gst_stream_synchronizer_class_init (GstStreamSynchronizerClass * klass) GST_DEBUG_FUNCPTR (gst_stream_synchronizer_request_new_pad); element_class->release_pad = GST_DEBUG_FUNCPTR (gst_stream_synchronizer_release_pad); -} -gboolean -gst_stream_synchronizer_plugin_init (GstPlugin * plugin) -{ GST_DEBUG_CATEGORY_INIT (stream_synchronizer_debug, "streamsynchronizer", 0, "Stream Synchronizer"); - - return gst_element_register (plugin, "streamsynchronizer", GST_RANK_NONE, - GST_TYPE_STREAM_SYNCHRONIZER); } diff --git a/gst/playback/gststreamsynchronizer.h b/gst/playback/gststreamsynchronizer.h index e6310be092..2df9e0df92 100644 --- a/gst/playback/gststreamsynchronizer.h +++ b/gst/playback/gststreamsynchronizer.h @@ -66,8 +66,6 @@ struct _GstStreamSynchronizerClass GType gst_stream_synchronizer_get_type (void); -gboolean gst_stream_synchronizer_plugin_init (GstPlugin * plugin); - G_END_DECLS #endif /* __GST_STREAM_SYNCHRONIZER_H__ */ diff --git a/gst/playback/gstsubtitleoverlay.c b/gst/playback/gstsubtitleoverlay.c index 6420b76667..8e19fca719 100644 --- a/gst/playback/gstsubtitleoverlay.c +++ b/gst/playback/gstsubtitleoverlay.c @@ -39,6 +39,7 @@ #include "config.h" #endif +#include "gstplaybackelements.h" #include "gstsubtitleoverlay.h" #include @@ -85,6 +86,13 @@ G_DEFINE_TYPE (GstSubtitleOverlay, gst_subtitle_overlay, GST_TYPE_BIN); static GQuark _subtitle_overlay_event_marker_id = 0; +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (subtitle_overlay_debug, "subtitleoverlay", 0, "Subtitle Overlay"); \ + ret |= playback_element_init (plugin); \ + _subtitle_overlay_event_marker_id = g_quark_from_static_string ("gst-subtitle-overlay-event-marker") +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (subtitleoverlay, "subtitleoverlay", + GST_RANK_NONE, GST_TYPE_SUBTITLE_OVERLAY, _do_init); + static void do_async_start (GstSubtitleOverlay * self) { @@ -2106,16 +2114,3 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self) self->fps_n = 0; self->fps_d = 0; } - -gboolean -gst_subtitle_overlay_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (subtitle_overlay_debug, "subtitleoverlay", 0, - "Subtitle Overlay"); - - _subtitle_overlay_event_marker_id = - g_quark_from_static_string ("gst-subtitle-overlay-event-marker"); - - return gst_element_register (plugin, "subtitleoverlay", GST_RANK_NONE, - GST_TYPE_SUBTITLE_OVERLAY); -} diff --git a/gst/playback/gstsubtitleoverlay.h b/gst/playback/gstsubtitleoverlay.h index 53c10c4c48..22a04ffb71 100644 --- a/gst/playback/gstsubtitleoverlay.h +++ b/gst/playback/gstsubtitleoverlay.h @@ -112,7 +112,6 @@ struct _GstSubtitleOverlayClass }; GType gst_subtitle_overlay_get_type (void); -gboolean gst_subtitle_overlay_plugin_init (GstPlugin * plugin); GstCaps *gst_subtitle_overlay_create_factory_caps (void); diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index aed3ab7a2d..4807df1928 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -41,7 +41,7 @@ #include "gstplay-enum.h" #include "gstrawcaps.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplaybackutils.h" #define GST_TYPE_URI_DECODE_BIN \ @@ -208,6 +208,12 @@ GType gst_uri_decode_bin_get_type (void); #define gst_uri_decode_bin_parent_class parent_class G_DEFINE_TYPE (GstURIDecodeBin, gst_uri_decode_bin, GST_TYPE_BIN); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin_debug, "uridecodebin", 0, "URI decoder element"); \ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (uridecodebin, "uridecodebin", + GST_RANK_NONE, GST_TYPE_URI_DECODE_BIN, _do_init); + static void remove_decoders (GstURIDecodeBin * bin, gboolean force); static void gst_uri_decode_bin_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -2924,13 +2930,3 @@ setup_failed: return GST_STATE_CHANGE_FAILURE; } } - -gboolean -gst_uri_decode_bin_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin_debug, "uridecodebin", 0, - "URI decoder element"); - - return gst_element_register (plugin, "uridecodebin", GST_RANK_NONE, - GST_TYPE_URI_DECODE_BIN); -} diff --git a/gst/playback/gsturidecodebin3.c b/gst/playback/gsturidecodebin3.c index 295ba451fd..6d0d77946d 100644 --- a/gst/playback/gsturidecodebin3.c +++ b/gst/playback/gsturidecodebin3.c @@ -55,7 +55,7 @@ #include "gstplay-enum.h" #include "gstrawcaps.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplaybackutils.h" #define GST_TYPE_URI_DECODE_BIN3 \ @@ -329,6 +329,12 @@ GType gst_uri_decode_bin3_get_type (void); #define gst_uri_decode_bin3_parent_class parent_class G_DEFINE_TYPE (GstURIDecodeBin3, gst_uri_decode_bin3, GST_TYPE_BIN); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin3_debug, "uridecodebin3", 0, "URI decoder element 3"); \ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (uridecodebin3, "uridecodebin3", + GST_RANK_NONE, GST_TYPE_URI_DECODE_BIN3, _do_init); + #define REMOVE_SIGNAL(obj,id) \ if (id) { \ g_signal_handler_disconnect (obj, id); \ @@ -1144,13 +1150,3 @@ gst_uri_decodebin3_send_event (GstElement * element, GstEvent * event) return GST_ELEMENT_CLASS (parent_class)->send_event (element, event); } - -gboolean -gst_uri_decode_bin3_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_uri_decode_bin3_debug, "uridecodebin3", 0, - "URI decoder element 3"); - - return gst_element_register (plugin, "uridecodebin3", GST_RANK_NONE, - GST_TYPE_URI_DECODE_BIN3); -} diff --git a/gst/playback/gsturisourcebin.c b/gst/playback/gsturisourcebin.c index b8100d2333..89275e5b4b 100644 --- a/gst/playback/gsturisourcebin.c +++ b/gst/playback/gsturisourcebin.c @@ -50,7 +50,7 @@ #include "gstplay-enum.h" #include "gstrawcaps.h" -#include "gstplayback.h" +#include "gstplaybackelements.h" #include "gstplaybackutils.h" #define GST_TYPE_URI_SOURCE_BIN \ @@ -256,6 +256,12 @@ GType gst_uri_source_bin_get_type (void); #define gst_uri_source_bin_parent_class parent_class G_DEFINE_TYPE (GstURISourceBin, gst_uri_source_bin, GST_TYPE_BIN); +#define _do_init \ + GST_DEBUG_CATEGORY_INIT (gst_uri_source_bin_debug, "urisourcebin", 0, "URI source element"); \ + ret |= playback_element_init (plugin); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (urisourcebin, "urisourcebin", + GST_RANK_NONE, GST_TYPE_URI_SOURCE_BIN, _do_init); + static void gst_uri_source_bin_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_uri_source_bin_get_property (GObject * object, guint prop_id, @@ -2853,13 +2859,3 @@ setup_failed: return GST_STATE_CHANGE_FAILURE; } } - -gboolean -gst_uri_source_bin_plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (gst_uri_source_bin_debug, "urisourcebin", 0, - "URI source element"); - - return gst_element_register (plugin, "urisourcebin", GST_RANK_NONE, - GST_TYPE_URI_SOURCE_BIN); -} diff --git a/gst/playback/meson.build b/gst/playback/meson.build index babcb6e865..1ad770d8ef 100644 --- a/gst/playback/meson.build +++ b/gst/playback/meson.build @@ -5,7 +5,8 @@ playback_sources = [ 'gsturidecodebin3.c', 'gsturisourcebin.c', 'gstparsebin.c', - 'gstplayback.c', + 'gstplaybackplugin.c', + 'gstplaybackelement.c', 'gstplaybackutils.c', 'gstplaybin2.c', 'gstplaybin3.c',