Skip to content

Commit

Permalink
tcp: allow per feature registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane Cerveau authored and GStreamer Marge Bot committed Mar 16, 2021
1 parent 3d38316 commit 520a682
Show file tree
Hide file tree
Showing 11 changed files with 112 additions and 35 deletions.
3 changes: 3 additions & 0 deletions gst/tcp/gstmultifdsink.c
Expand Up @@ -119,6 +119,7 @@
#include <sys/stat.h>
#include <netinet/in.h>

#include "gsttcpelements.h"
#include "gstmultifdsink.h"

#define NOT_IMPLEMENTED 0
Expand Down Expand Up @@ -194,6 +195,8 @@ static void gst_multi_fd_sink_get_property (GObject * object, guint prop_id,

#define gst_multi_fd_sink_parent_class parent_class
G_DEFINE_TYPE (GstMultiFdSink, gst_multi_fd_sink, GST_TYPE_MULTI_HANDLE_SINK);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (multifdsink, "multifdsink",
GST_RANK_NONE, GST_TYPE_MULTI_FD_SINK, tcp_element_init (plugin));

static guint gst_multi_fd_sink_signals[LAST_SIGNAL] = { 0 };

Expand Down
3 changes: 3 additions & 0 deletions gst/tcp/gstmultisocketsink.c
Expand Up @@ -109,6 +109,7 @@
#include <string.h>

#include "gstmultisocketsink.h"
#include "gsttcpelements.h"

#ifndef G_OS_WIN32
#include <netinet/in.h>
Expand Down Expand Up @@ -206,6 +207,8 @@ static void gst_multi_socket_sink_get_property (GObject * object, guint prop_id,
#define gst_multi_socket_sink_parent_class parent_class
G_DEFINE_TYPE (GstMultiSocketSink, gst_multi_socket_sink,
GST_TYPE_MULTI_HANDLE_SINK);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (multisocketsink, "multisocketsink",
GST_RANK_NONE, GST_TYPE_MULTI_SOCKET_SINK, tcp_element_init (plugin));

static guint gst_multi_socket_sink_signals[LAST_SIGNAL] = { 0 };

Expand Down
4 changes: 3 additions & 1 deletion gst/tcp/gstsocketsrc.c
Expand Up @@ -51,6 +51,7 @@

#include <gst/gst-i18n-plugin.h>
#include <gst/net/gstnetcontrolmessagemeta.h>
#include "gsttcpelements.h"
#include "gstsocketsrc.h"
#include "gsttcp.h"

Expand Down Expand Up @@ -86,7 +87,8 @@ static guint gst_socket_src_signals[LAST_SIGNAL] = { 0 };

#define gst_socket_src_parent_class parent_class
G_DEFINE_TYPE (GstSocketSrc, gst_socket_src, GST_TYPE_PUSH_SRC);

GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (socketsrc, "socketsrc",
GST_RANK_NONE, GST_TYPE_SOCKET_SRC, tcp_element_init (plugin));

static void gst_socket_src_finalize (GObject * gobject);

Expand Down
3 changes: 3 additions & 0 deletions gst/tcp/gsttcpclientsink.c
Expand Up @@ -44,6 +44,7 @@
#include <gst/gst-i18n-plugin.h>

#include "gsttcp.h"
#include "gsttcpelements.h"
#include "gsttcpclientsink.h"

/* TCPClientSink signals and args */
Expand Down Expand Up @@ -90,6 +91,8 @@ static void gst_tcp_client_sink_get_property (GObject * object, guint prop_id,

#define gst_tcp_client_sink_parent_class parent_class
G_DEFINE_TYPE (GstTCPClientSink, gst_tcp_client_sink, GST_TYPE_BASE_SINK);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (tcpclientsink, "tcpclientsink",
GST_RANK_NONE, GST_TYPE_TCP_CLIENT_SINK, tcp_element_init (plugin));

static void
gst_tcp_client_sink_class_init (GstTCPClientSinkClass * klass)
Expand Down
4 changes: 3 additions & 1 deletion gst/tcp/gsttcpclientsrc.c
Expand Up @@ -44,6 +44,7 @@
#endif

#include <gst/gst-i18n-plugin.h>
#include "gsttcpelements.h"
#include "gsttcpclientsrc.h"
#include "gsttcpsrcstats.h"
#include "gsttcp.h"
Expand Down Expand Up @@ -72,7 +73,8 @@ enum

#define gst_tcp_client_src_parent_class parent_class
G_DEFINE_TYPE (GstTCPClientSrc, gst_tcp_client_src, GST_TYPE_PUSH_SRC);

GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (tcpclientsrc, "tcpclientsrc",
GST_RANK_NONE, GST_TYPE_TCP_CLIENT_SRC, tcp_element_init (plugin));

static void gst_tcp_client_src_finalize (GObject * gobject);

Expand Down
38 changes: 38 additions & 0 deletions gst/tcp/gsttcpelement.c
@@ -0,0 +1,38 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Stéphane Cerveau <scerveau@collabora.com>
*
* 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 "gsttcpelements.h"

GST_DEBUG_CATEGORY (tcp_debug);

void
tcp_element_init (GstPlugin * plugin)
{
static gsize res = FALSE;
if (g_once_init_enter (&res)) {
GST_DEBUG_CATEGORY_INIT (tcp_debug, "tcp", 0, "TCP calls");
g_once_init_leave (&res, TRUE);
}
}
39 changes: 39 additions & 0 deletions gst/tcp/gsttcpelements.h
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* @Author: Julian Bouzas <julian.bouzas@collabora.com>
*
* 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_TCP_ELEMENTS_H__
#define __GST_TCP_ELEMENTS_H__

#include <gst/gst.h>

G_BEGIN_DECLS

G_GNUC_INTERNAL void tcp_element_init (GstPlugin * plugin);

GST_ELEMENT_REGISTER_DECLARE (socketsrc);
GST_ELEMENT_REGISTER_DECLARE (tcpclientsink);
GST_ELEMENT_REGISTER_DECLARE (tcpclientsrc);
GST_ELEMENT_REGISTER_DECLARE (tcpserversink);
GST_ELEMENT_REGISTER_DECLARE (tcpserversrc);
GST_ELEMENT_REGISTER_DECLARE (multifdsink);
GST_ELEMENT_REGISTER_DECLARE (multisocketsink);

G_END_DECLS

#endif /* __GST_TCP_ELEMENTS_H__ */
46 changes: 13 additions & 33 deletions gst/tcp/gsttcpplugin.c
Expand Up @@ -21,46 +21,26 @@
#include "config.h"
#endif

#include "gstsocketsrc.h"
#include "gsttcpclientsrc.h"
#include "gsttcpclientsink.h"
#include "gsttcpserversrc.h"
#include "gsttcpserversink.h"
#include "gstmultifdsink.h"
#include "gstmultisocketsink.h"

GST_DEBUG_CATEGORY (tcp_debug);
#include "gsttcpelements.h"

static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "socketsrc", GST_RANK_NONE,
GST_TYPE_SOCKET_SRC))
return FALSE;
if (!gst_element_register (plugin, "tcpclientsink", GST_RANK_NONE,
GST_TYPE_TCP_CLIENT_SINK))
return FALSE;
if (!gst_element_register (plugin, "tcpclientsrc", GST_RANK_NONE,
GST_TYPE_TCP_CLIENT_SRC))
return FALSE;
if (!gst_element_register (plugin, "tcpserversink", GST_RANK_NONE,
GST_TYPE_TCP_SERVER_SINK))
return FALSE;
if (!gst_element_register (plugin, "tcpserversrc", GST_RANK_NONE,
GST_TYPE_TCP_SERVER_SRC))
return FALSE;
gboolean ret = FALSE;

ret |= GST_ELEMENT_REGISTER (socketsrc, plugin);
ret |= GST_ELEMENT_REGISTER (tcpclientsink, plugin);
ret |= GST_ELEMENT_REGISTER (tcpclientsrc, plugin);
ret |= GST_ELEMENT_REGISTER (tcpserversink, plugin);
ret |= GST_ELEMENT_REGISTER (tcpserversrc, plugin);

#ifdef HAVE_SYS_SOCKET_H
if (!gst_element_register (plugin, "multifdsink", GST_RANK_NONE,
GST_TYPE_MULTI_FD_SINK))
return FALSE;
#endif
if (!gst_element_register (plugin, "multisocketsink", GST_RANK_NONE,
GST_TYPE_MULTI_SOCKET_SINK))
return FALSE;
ret |= GST_ELEMENT_REGISTER (multifdsink, plugin);

GST_DEBUG_CATEGORY_INIT (tcp_debug, "tcp", 0, "TCP calls");
#endif
ret |= GST_ELEMENT_REGISTER (multisocketsink, plugin);

return TRUE;
return ret;
}

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
Expand Down
3 changes: 3 additions & 0 deletions gst/tcp/gsttcpserversink.c
Expand Up @@ -41,6 +41,7 @@
#include <string.h> /* memset */

#include "gsttcp.h"
#include "gsttcpelements.h"
#include "gsttcpserversink.h"

#define TCP_BACKLOG 5
Expand Down Expand Up @@ -71,6 +72,8 @@ static void gst_tcp_server_sink_get_property (GObject * object, guint prop_id,
#define gst_tcp_server_sink_parent_class parent_class
G_DEFINE_TYPE (GstTCPServerSink, gst_tcp_server_sink,
GST_TYPE_MULTI_SOCKET_SINK);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (tcpserversink, "tcpserversink",
GST_RANK_NONE, GST_TYPE_TCP_SERVER_SINK, tcp_element_init (plugin));

static void
gst_tcp_server_sink_class_init (GstTCPServerSinkClass * klass)
Expand Down
3 changes: 3 additions & 0 deletions gst/tcp/gsttcpserversrc.c
Expand Up @@ -42,6 +42,7 @@

#include <gst/gst-i18n-plugin.h>
#include "gsttcp.h"
#include "gsttcpelements.h"
#include "gsttcpsrcstats.h"
#include "gsttcpserversrc.h"

Expand Down Expand Up @@ -69,6 +70,8 @@ enum

#define gst_tcp_server_src_parent_class parent_class
G_DEFINE_TYPE (GstTCPServerSrc, gst_tcp_server_src, GST_TYPE_PUSH_SRC);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (tcpserversrc, "tcpserversrc",
GST_RANK_NONE, GST_TYPE_TCP_SERVER_SRC, tcp_element_init (plugin));

static void gst_tcp_server_src_finalize (GObject * gobject);

Expand Down
1 change: 1 addition & 0 deletions gst/tcp/meson.build
Expand Up @@ -4,6 +4,7 @@ tcp_sources = [
'gstsocketsrc.c',
'gsttcpclientsrc.c',
'gsttcpclientsink.c',
'gsttcpelement.c',
'gsttcpserversrc.c',
'gsttcpserversink.c',
'gsttcpsrcstats.c',
Expand Down

0 comments on commit 520a682

Please sign in to comment.