diff --git a/gst/isomp4/gstisomp4element.c b/gst/isomp4/gstisomp4element.c new file mode 100644 index 0000000000..06a82d2b62 --- /dev/null +++ b/gst/isomp4/gstisomp4element.c @@ -0,0 +1,55 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David A. Schleef + * Copyright (C) <2006> Wim Taymans + * + * 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 + +#include "gstisomp4elements.h" +#include "qtdemux.h" + +void +isomp4_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + + if (g_once_init_enter (&res)) { +#ifdef ENABLE_NLS + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +#endif /* ENABLE_NLS */ + + gst_pb_utils_init (); + + /* ensure private tag is registered */ + gst_tag_register (GST_QT_DEMUX_PRIVATE_TAG, GST_TAG_FLAG_META, + GST_TYPE_SAMPLE, "QT atom", "unparsed QT tag atom", + gst_tag_merge_use_first); + + gst_tag_register (GST_QT_DEMUX_CLASSIFICATION_TAG, GST_TAG_FLAG_META, + G_TYPE_STRING, GST_QT_DEMUX_CLASSIFICATION_TAG, + "content classification", gst_tag_merge_use_first); + + g_once_init_leave (&res, TRUE); + } +} diff --git a/gst/isomp4/gstisomp4elements.h b/gst/isomp4/gstisomp4elements.h new file mode 100644 index 0000000000..0347e6e3b7 --- /dev/null +++ b/gst/isomp4/gstisomp4elements.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2003> David A. Schleef + * Copyright (C) <2006> Wim Taymans + * Copyright (C) 2020 Huawei Technologies Co., Ltd. + * @Author: Julian Bouzas + * + * 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_ISOMP4_ELEMENTS_H__ +#define __GST_ISOMP4_ELEMENTS_H__ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +G_BEGIN_DECLS + +void isomp4_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (qtdemux); +GST_ELEMENT_REGISTER_DECLARE (rtpxqtdepay); +GST_ELEMENT_REGISTER_DECLARE (qtmux); +GST_ELEMENT_REGISTER_DECLARE (qtmoovrecover); + +G_END_DECLS + +#endif /* __GST_ISOMP4_ELEMENTS_H__ */ diff --git a/gst/isomp4/gstqtmoovrecover.c b/gst/isomp4/gstqtmoovrecover.c index 185109fc90..068030a64c 100644 --- a/gst/isomp4/gstqtmoovrecover.c +++ b/gst/isomp4/gstqtmoovrecover.c @@ -64,6 +64,7 @@ #include #include +#include "gstisomp4elements.h" #include "gstqtmoovrecover.h" GST_DEBUG_CATEGORY_STATIC (gst_qt_moov_recover_debug); @@ -87,6 +88,8 @@ enum #define gst_qt_moov_recover_parent_class parent_class G_DEFINE_TYPE (GstQTMoovRecover, gst_qt_moov_recover, GST_TYPE_PIPELINE); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qtmoovrecover, "qtmoovrecover", + GST_RANK_NONE, GST_TYPE_QT_MOOV_RECOVER, isomp4_element_init (plugin)); /* property functions */ static void gst_qt_moov_recover_set_property (GObject * object, @@ -375,11 +378,3 @@ gst_qt_moov_recover_change_state (GstElement * element, } return ret; } - - -gboolean -gst_qt_moov_recover_register (GstPlugin * plugin) -{ - return gst_element_register (plugin, "qtmoovrecover", GST_RANK_NONE, - GST_TYPE_QT_MOOV_RECOVER); -} diff --git a/gst/isomp4/gstqtmux.c b/gst/isomp4/gstqtmux.c index 264aebe470..821e7f1710 100644 --- a/gst/isomp4/gstqtmux.c +++ b/gst/isomp4/gstqtmux.c @@ -86,6 +86,7 @@ # include #endif +#include "gstisomp4elements.h" #include "gstqtmux.h" GST_DEBUG_CATEGORY_STATIC (gst_qt_mux_debug); @@ -7454,7 +7455,11 @@ gst_qt_mux_register (GstPlugin * plugin) G_TYPE_STRING, GST_TAG_3GP_CLASSIFICATION, "content classification", gst_tag_merge_use_first); + isomp4_element_init (plugin); + GST_LOG ("Finished registering tags"); return TRUE; } + +GST_ELEMENT_REGISTER_DEFINE_CUSTOM (qtmux, gst_qt_mux_register); diff --git a/gst/isomp4/gstrtpxqtdepay.c b/gst/isomp4/gstrtpxqtdepay.c index 8a3c60e64e..3900db28f5 100644 --- a/gst/isomp4/gstrtpxqtdepay.c +++ b/gst/isomp4/gstrtpxqtdepay.c @@ -27,6 +27,7 @@ #include #include +#include "gstisomp4elements.h" #include "gstrtpxqtdepay.h" #define MAKE_TLV(a,b) (((a)<<8)|(b)) @@ -94,6 +95,8 @@ GST_STATIC_PAD_TEMPLATE ("sink", #define gst_rtp_xqt_depay_parent_class parent_class G_DEFINE_TYPE (GstRtpXQTDepay, gst_rtp_xqt_depay, GST_TYPE_RTP_BASE_DEPAYLOAD); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (rtpxqtdepay, "rtpxqtdepay", + GST_RANK_MARGINAL, GST_TYPE_RTP_XQT_DEPAY, isomp4_element_init (plugin)); static void gst_rtp_xqt_depay_finalize (GObject * object); diff --git a/gst/isomp4/isomp4-plugin.c b/gst/isomp4/isomp4-plugin.c index 7ff78cee75..3694d157b2 100644 --- a/gst/isomp4/isomp4-plugin.c +++ b/gst/isomp4/isomp4-plugin.c @@ -24,46 +24,20 @@ #endif #include "gst/gst-i18n-plugin.h" -#include "qtdemux.h" -#include "gstrtpxqtdepay.h" -#include "gstqtmux.h" -#include "gstqtmoovrecover.h" +#include "gstisomp4elements.h" -#include static gboolean plugin_init (GstPlugin * plugin) { -#ifdef ENABLE_NLS - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); -#endif /* ENABLE_NLS */ + gboolean ret = FALSE; - gst_pb_utils_init (); + ret |= GST_ELEMENT_REGISTER (qtdemux, plugin); + ret |= GST_ELEMENT_REGISTER (rtpxqtdepay, plugin); + ret |= GST_ELEMENT_REGISTER (qtmux, plugin); + ret |= GST_ELEMENT_REGISTER (qtmoovrecover, plugin); - /* ensure private tag is registered */ - gst_tag_register (GST_QT_DEMUX_PRIVATE_TAG, GST_TAG_FLAG_META, - GST_TYPE_SAMPLE, "QT atom", "unparsed QT tag atom", - gst_tag_merge_use_first); - - gst_tag_register (GST_QT_DEMUX_CLASSIFICATION_TAG, GST_TAG_FLAG_META, - G_TYPE_STRING, GST_QT_DEMUX_CLASSIFICATION_TAG, "content classification", - gst_tag_merge_use_first); - - if (!gst_element_register (plugin, "qtdemux", - GST_RANK_PRIMARY, GST_TYPE_QTDEMUX)) - return FALSE; - - if (!gst_element_register (plugin, "rtpxqtdepay", - GST_RANK_MARGINAL, GST_TYPE_RTP_XQT_DEPAY)) - return FALSE; - - if (!gst_qt_mux_register (plugin)) - return FALSE; - if (!gst_qt_moov_recover_register (plugin)) - return FALSE; - - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/gst/isomp4/meson.build b/gst/isomp4/meson.build index 17a83620b2..b510c0510e 100644 --- a/gst/isomp4/meson.build +++ b/gst/isomp4/meson.build @@ -1,5 +1,6 @@ mp4_sources = [ 'isomp4-plugin.c', + 'gstisomp4element.c', 'gstrtpxqtdepay.c', 'qtdemux.c', 'qtdemux_types.c', diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index 74d6ec22d4..8f09358f92 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -59,6 +59,7 @@ #include #include +#include "gstisomp4elements.h" #include "qtatomparser.h" #include "qtdemux_types.h" #include "qtdemux_dump.h" @@ -289,6 +290,8 @@ GST_STATIC_PAD_TEMPLATE ("subtitle_%u", #define gst_qtdemux_parent_class parent_class G_DEFINE_TYPE (GstQTDemux, gst_qtdemux, GST_TYPE_ELEMENT); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (qtdemux, "qtdemux", + GST_RANK_PRIMARY, GST_TYPE_QTDEMUX, isomp4_element_init (plugin)); static void gst_qtdemux_dispose (GObject * object); static void gst_qtdemux_finalize (GObject * object);