• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
46 typedef struct _GstSRTObject GstSRTObject;
47 
48 struct _GstSRTObject
49 {
50   GstElement                   *element;
51   GstUri                       *uri;
52 
53   GstStructure                 *parameters;
54   gboolean                      opened;
55   SRTSOCKET                     sock;
56   gint                          poll_id;
57   gboolean                      sent_headers;
58 
59   GTask                        *listener_task;
60   SRTSOCKET                     listener_sock;
61   gint                          listener_poll_id;
62 
63   GThread                      *thread;
64 
65   /* Protects the list of callers */
66   GMutex                        sock_lock;
67   GCond                         sock_cond;
68 
69   GList                        *callers;
70 
71   gboolean                     wait_for_connection;
72 
73   gboolean                     authentication;
74 
75   guint64                      previous_bytes;
76 };
77 
78 GstSRTObject   *gst_srt_object_new              (GstElement *element);
79 
80 void            gst_srt_object_destroy          (GstSRTObject *srtobject);
81 
82 gboolean        gst_srt_object_open             (GstSRTObject *srtobject,
83                                                  GCancellable *cancellable,
84                                                  GError **error);
85 
86 void            gst_srt_object_close            (GstSRTObject *srtobject);
87 
88 gboolean        gst_srt_object_set_property_helper (GstSRTObject *srtobject,
89                                                     guint prop_id, const GValue * value,
90                                                     GParamSpec * pspec);
91 
92 gboolean        gst_srt_object_get_property_helper (GstSRTObject *srtobject,
93                                                     guint prop_id, GValue * value,
94                                                     GParamSpec * pspec);
95 
96 void            gst_srt_object_install_properties_helper (GObjectClass *gobject_class);
97 
98 gboolean        gst_srt_object_set_uri (GstSRTObject * srtobject, const gchar *uri, GError ** err);
99 
100 gssize          gst_srt_object_read     (GstSRTObject * srtobject,
101                                          guint8 *data, gsize size,
102                                          GCancellable *cancellable,
103                                          GError **err,
104 					 SRT_MSGCTRL *mctrl);
105 
106 gssize          gst_srt_object_write    (GstSRTObject * srtobject,
107                                          GstBufferList * headers,
108                                          const GstMapInfo * mapinfo,
109                                          GCancellable *cancellable,
110                                          GError **err);
111 
112 void            gst_srt_object_wakeup   (GstSRTObject * srtobject,
113                                          GCancellable *cancellable);
114 
115 GstStructure   *gst_srt_object_get_stats        (GstSRTObject * srtobject);
116 
117 G_END_DECLS
118 
119 #endif // __GST_SRT_OBJECT_H__
120