diff --git a/ext/curl/gstcurl.c b/ext/curl/gstcurl.c index 982c6e092a..db3819c917 100644 --- a/ext/curl/gstcurl.c +++ b/ext/curl/gstcurl.c @@ -20,55 +20,25 @@ #include #endif -#include +#include "gstcurlelements.h" -#include "gstcurlbasesink.h" -#include "gstcurltlssink.h" -#include "gstcurlhttpsink.h" -#include "gstcurlfilesink.h" -#include "gstcurlftpsink.h" -#include "gstcurlsmtpsink.h" -#ifdef HAVE_SSH2 -#include "gstcurlsftpsink.h" -#endif -#include "gstcurlhttpsrc.h" static gboolean plugin_init (GstPlugin * plugin) { -#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 */ + gboolean ret = FALSE; - if (!gst_element_register (plugin, "curlhttpsink", GST_RANK_NONE, - GST_TYPE_CURL_HTTP_SINK)) - return FALSE; - - if (!gst_element_register (plugin, "curlfilesink", GST_RANK_NONE, - GST_TYPE_CURL_FILE_SINK)) - return FALSE; - - if (!gst_element_register (plugin, "curlftpsink", GST_RANK_NONE, - GST_TYPE_CURL_FTP_SINK)) - return FALSE; - - if (!gst_element_register (plugin, "curlsmtpsink", GST_RANK_NONE, - GST_TYPE_CURL_SMTP_SINK)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (curlhttpsink, plugin); + ret |= GST_ELEMENT_REGISTER (curlfilesink, plugin); + ret |= GST_ELEMENT_REGISTER (curlftpsink, plugin); + ret |= GST_ELEMENT_REGISTER (curlsmtpsink, plugin); #ifdef HAVE_SSH2 - if (!gst_element_register (plugin, "curlsftpsink", GST_RANK_NONE, - GST_TYPE_CURL_SFTP_SINK)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (curlsftpsink, plugin); #endif - if (!gst_element_register (plugin, "curlhttpsrc", GST_RANK_SECONDARY, - GST_TYPE_CURLHTTPSRC)) - return FALSE; + ret |= GST_ELEMENT_REGISTER (curlhttpsrc, plugin); - return TRUE; + return ret; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, diff --git a/ext/curl/gstcurlelement.c b/ext/curl/gstcurlelement.c new file mode 100644 index 0000000000..01078c4fb8 --- /dev/null +++ b/ext/curl/gstcurlelement.c @@ -0,0 +1,41 @@ +/* GStreamer + * Copyright (C) 2011 Axis Communications + * + * 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 +#endif + +#include + +#include "gstcurlelements.h" + +void +curl_element_init (GstPlugin * plugin) +{ + static gsize res = FALSE; + + if (g_once_init_enter (&res)) { +#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); + } +} diff --git a/ext/curl/gstcurlelements.h b/ext/curl/gstcurlelements.h new file mode 100644 index 0000000000..b15fb66d08 --- /dev/null +++ b/ext/curl/gstcurlelements.h @@ -0,0 +1,39 @@ +/* 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_CURL_ELEMENTS_H__ +#define __GST_CURL_ELEMENTS_H__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +void curl_element_init (GstPlugin * plugin); + +GST_ELEMENT_REGISTER_DECLARE (curlfilesink); +GST_ELEMENT_REGISTER_DECLARE (curlftpsink); +GST_ELEMENT_REGISTER_DECLARE (curlhttpsink); +GST_ELEMENT_REGISTER_DECLARE (curlhttpsrc); +GST_ELEMENT_REGISTER_DECLARE (curlsftpsink); +GST_ELEMENT_REGISTER_DECLARE (curlsmtpsink); + +#endif /* __GST_CURL_ELEMENT_H__ */ diff --git a/ext/curl/gstcurlfilesink.c b/ext/curl/gstcurlfilesink.c index 4847301f3e..09cc391ddd 100644 --- a/ext/curl/gstcurlfilesink.c +++ b/ext/curl/gstcurlfilesink.c @@ -59,6 +59,7 @@ #include #include +#include "gstcurlelements.h" #include "gstcurlbasesink.h" #include "gstcurlfilesink.h" @@ -94,6 +95,8 @@ static gboolean gst_curl_file_sink_prepare_transfer (GstCurlBaseSink * #define gst_curl_file_sink_parent_class parent_class G_DEFINE_TYPE (GstCurlFileSink, gst_curl_file_sink, GST_TYPE_CURL_BASE_SINK); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (curlfilesink, "curlfilesink", + GST_RANK_NONE, GST_TYPE_CURL_FILE_SINK, curl_element_init (plugin)); static void gst_curl_file_sink_class_init (GstCurlFileSinkClass * klass) diff --git a/ext/curl/gstcurlftpsink.c b/ext/curl/gstcurlftpsink.c index 2c4ec4423c..4027f2b5f0 100644 --- a/ext/curl/gstcurlftpsink.c +++ b/ext/curl/gstcurlftpsink.c @@ -62,6 +62,7 @@ #include #include +#include "gstcurlelements.h" #include "gstcurltlssink.h" #include "gstcurlftpsink.h" @@ -101,6 +102,8 @@ static gboolean set_ftp_dynamic_options_unlocked #define gst_curl_ftp_sink_parent_class parent_class G_DEFINE_TYPE (GstCurlFtpSink, gst_curl_ftp_sink, GST_TYPE_CURL_TLS_SINK); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (curlftpsink, "curlftpsink", + GST_RANK_NONE, GST_TYPE_CURL_FTP_SINK, curl_element_init (plugin)); static void gst_curl_ftp_sink_class_init (GstCurlFtpSinkClass * klass) diff --git a/ext/curl/gstcurlhttpsink.c b/ext/curl/gstcurlhttpsink.c index 7d98f225a4..2fd681501f 100644 --- a/ext/curl/gstcurlhttpsink.c +++ b/ext/curl/gstcurlhttpsink.c @@ -64,6 +64,7 @@ #include #include +#include "gstcurlelements.h" #include "gstcurltlssink.h" #include "gstcurlhttpsink.h" @@ -111,7 +112,8 @@ static void gst_curl_http_sink_transfer_prepare_poll_wait #define gst_curl_http_sink_parent_class parent_class G_DEFINE_TYPE (GstCurlHttpSink, gst_curl_http_sink, GST_TYPE_CURL_TLS_SINK); - +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (curlhttpsink, "curlhttpsink", + GST_RANK_NONE, GST_TYPE_CURL_HTTP_SINK, curl_element_init (plugin)); /* private functions */ static gboolean proxy_setup (GstCurlBaseSink * bcsink); diff --git a/ext/curl/gstcurlhttpsrc.c b/ext/curl/gstcurlhttpsrc.c index 32f4475269..a681566590 100644 --- a/ext/curl/gstcurlhttpsrc.c +++ b/ext/curl/gstcurlhttpsrc.c @@ -118,6 +118,7 @@ #include +#include "gstcurlelements.h" #include "gstcurlhttpsrc.h" #include "gstcurlqueue.h" #include "gstcurldefaults.h" @@ -254,6 +255,8 @@ gst_curl_http_version_get_type (void) G_DEFINE_TYPE_WITH_CODE (GstCurlHttpSrc, gst_curl_http_src, GST_TYPE_PUSH_SRC, G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_curl_http_src_uri_handler_init)); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (curlhttpsrc, "curlhttpsrc", + GST_RANK_SECONDARY, GST_TYPE_CURLHTTPSRC, curl_element_init (plugin)); static void gst_curl_http_src_class_init (GstCurlHttpSrcClass * klass) diff --git a/ext/curl/gstcurlsftpsink.c b/ext/curl/gstcurlsftpsink.c index 983aa5fc33..701603d9de 100644 --- a/ext/curl/gstcurlsftpsink.c +++ b/ext/curl/gstcurlsftpsink.c @@ -44,6 +44,7 @@ #include "config.h" #endif +#include "gstcurlelements.h" #include "gstcurlsshsink.h" #include "gstcurlsftpsink.h" @@ -92,6 +93,8 @@ static gboolean set_sftp_dynamic_options_unlocked (GstCurlBaseSink * #define gst_curl_sftp_sink_parent_class parent_class G_DEFINE_TYPE (GstCurlSftpSink, gst_curl_sftp_sink, GST_TYPE_CURL_SSH_SINK); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (curlsftpsink, "curlsftpsink", + GST_RANK_NONE, GST_TYPE_CURL_SFTP_SINK, curl_element_init (plugin)); static void gst_curl_sftp_sink_class_init (GstCurlSftpSinkClass * klass) diff --git a/ext/curl/gstcurlsmtpsink.c b/ext/curl/gstcurlsmtpsink.c index fb2d9aefcc..df0f50f2f1 100644 --- a/ext/curl/gstcurlsmtpsink.c +++ b/ext/curl/gstcurlsmtpsink.c @@ -72,6 +72,7 @@ #include #include +#include "gstcurlelements.h" #include "gstcurltlssink.h" #include "gstcurlsmtpsink.h" @@ -134,6 +135,8 @@ static size_t transfer_payload_headers (GstCurlSmtpSink * sink, void *curl_ptr, #define gst_curl_smtp_sink_parent_class parent_class G_DEFINE_TYPE (GstCurlSmtpSink, gst_curl_smtp_sink, GST_TYPE_CURL_TLS_SINK); +GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (curlsmtpsink, "curlsmtpsink", + GST_RANK_NONE, GST_TYPE_CURL_SMTP_SINK, curl_element_init (plugin)); static void gst_curl_smtp_sink_notify_transfer_end_unlocked (GstCurlSmtpSink * sink) diff --git a/ext/curl/meson.build b/ext/curl/meson.build index c23736d50a..c14504f0ad 100644 --- a/ext/curl/meson.build +++ b/ext/curl/meson.build @@ -1,6 +1,7 @@ curl_sources = [ 'gstcurlbasesink.c', 'gstcurl.c', + 'gstcurlelement.c', 'gstcurlfilesink.c', 'gstcurlftpsink.c', 'gstcurlhttpsink.c',