dtlsdec: Check if pad is linked before pushing buffer
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / ext / srt / gstsrtobject.h
1 /* GStreamer
2  * Copyright (C) 2018, Collabora Ltd.
3  * Copyright (C) 2018, SK Telecom, Co., Ltd.
4  *   Author: Jeongseok Kim <jeongseok.kim@sk.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef __GST_SRT_OBJECT_H__
23 #define __GST_SRT_OBJECT_H__
24
25 #include "gstsrt-enums.h"
26 #include "gstsrt-enumtypes.h"
27
28 #include <gio/gio.h>
29 #include <srt/srt.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_SRT_DEFAULT_URI_SCHEME "srt"
34 #define GST_SRT_DEFAULT_PORT 7001
35 #define GST_SRT_DEFAULT_HOST "127.0.0.1"
36 #define GST_SRT_DEFAULT_LOCALADDRESS "0.0.0.0"
37 #define GST_SRT_DEFAULT_URI GST_SRT_DEFAULT_URI_SCHEME"://"GST_SRT_DEFAULT_HOST":"G_STRINGIFY(GST_SRT_DEFAULT_PORT)
38
39 #define GST_SRT_DEFAULT_MODE GST_SRT_CONNECTION_MODE_CALLER
40 #define GST_SRT_DEFAULT_PBKEYLEN GST_SRT_KEY_LENGTH_0
41 #define GST_SRT_DEFAULT_POLL_TIMEOUT -1
42 #define GST_SRT_DEFAULT_LATENCY 125
43 #define GST_SRT_DEFAULT_MSG_SIZE 1316
44 #define GST_SRT_DEFAULT_WAIT_FOR_CONNECTION (TRUE)
45 #define GST_SRT_DEFAULT_AUTO_RECONNECT (TRUE)
46
47 typedef struct _GstSRTObject GstSRTObject;
48
49 struct _GstSRTObject
50 {
51   GstElement                   *element;
52   GstUri                       *uri;
53
54   GstStructure                 *parameters;
55   gboolean                      opened;
56   SRTSOCKET                     sock;
57   gint                          poll_id;
58   gboolean                      sent_headers;
59
60   GTask                        *listener_task;
61   SRTSOCKET                     listener_sock;
62   gint                          listener_poll_id;
63
64   GThread                      *thread;
65
66   /* Protects the list of callers */
67   GMutex                        sock_lock;
68   GCond                         sock_cond;
69
70   GList                        *callers;
71
72   gboolean                     wait_for_connection;
73   gboolean                     auto_reconnect;
74
75   gboolean                     authentication;
76
77   guint64                      bytes;
78 };
79
80 GstSRTObject   *gst_srt_object_new              (GstElement *element);
81
82 void            gst_srt_object_destroy          (GstSRTObject *srtobject);
83
84 gboolean        gst_srt_object_open             (GstSRTObject *srtobject,
85                                                  GCancellable *cancellable,
86                                                  GError **error);
87
88 void            gst_srt_object_close            (GstSRTObject *srtobject);
89
90 gboolean        gst_srt_object_set_property_helper (GstSRTObject *srtobject,
91                                                     guint prop_id, const GValue * value,
92                                                     GParamSpec * pspec);
93
94 gboolean        gst_srt_object_get_property_helper (GstSRTObject *srtobject,
95                                                     guint prop_id, GValue * value,
96                                                     GParamSpec * pspec);
97
98 void            gst_srt_object_install_properties_helper (GObjectClass *gobject_class);
99
100 gboolean        gst_srt_object_set_uri (GstSRTObject * srtobject, const gchar *uri, GError ** err);
101
102 gssize          gst_srt_object_read     (GstSRTObject * srtobject,
103                                          guint8 *data, gsize size,
104                                          GCancellable *cancellable,
105                                          GError **err,
106                                          SRT_MSGCTRL *mctrl);
107
108 gssize          gst_srt_object_write    (GstSRTObject * srtobject,
109                                          GstBufferList * headers,
110                                          const GstMapInfo * mapinfo,
111                                          GCancellable *cancellable,
112                                          GError **err);
113
114 void            gst_srt_object_wakeup   (GstSRTObject * srtobject,
115                                          GCancellable *cancellable);
116
117 GstStructure   *gst_srt_object_get_stats        (GstSRTObject * srtobject);
118
119 G_END_DECLS
120
121 #endif // __GST_SRT_OBJECT_H__