· 7 years ago · Oct 30, 2018, 10:06 PM
1/* GStreamer
2 * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef __GST_RTSP_SERVER_H__
21#define __GST_RTSP_SERVER_H__
22
23#include <gst/gst.h>
24
25G_BEGIN_DECLS
26
27/* Do *not* use these defines outside of rtsp-server. Use G_DEPRECATED instead. */
28#ifdef GST_DISABLE_DEPRECATED
29#define GST_RTSP_SERVER_DEPRECATED GST_RTSP_SERVER_API
30#define GST_RTSP_SERVER_DEPRECATED_FOR(f) GST_RTSP_SERVER_API
31#else
32#define GST_RTSP_SERVER_DEPRECATED G_DEPRECATED GST_RTSP_SERVER_API
33#define GST_RTSP_SERVER_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) GST_RTSP_SERVER_API
34#endif
35
36typedef struct _GstRTSPServer GstRTSPServer;
37typedef struct _GstRTSPServerClass GstRTSPServerClass;
38typedef struct _GstRTSPServerPrivate GstRTSPServerPrivate;
39
40#include "rtsp-server-prelude.h"
41#include "rtsp-session-pool.h"
42#include "rtsp-session.h"
43#include "rtsp-media.h"
44#include "rtsp-stream.h"
45#include "rtsp-stream-transport.h"
46#include "rtsp-address-pool.h"
47#include "rtsp-thread-pool.h"
48#include "rtsp-client.h"
49#include "rtsp-context.h"
50#include "rtsp-server.h"
51#include "rtsp-mount-points.h"
52#include "rtsp-media-factory.h"
53#include "rtsp-permissions.h"
54#include "rtsp-auth.h"
55#include "rtsp-token.h"
56#include "rtsp-session-media.h"
57#include "rtsp-sdp.h"
58#include "rtsp-media-factory-uri.h"
59#include "rtsp-params.h"
60
61#define GST_TYPE_RTSP_SERVER (gst_rtsp_server_get_type ())
62#define GST_IS_RTSP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SERVER))
63#define GST_IS_RTSP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SERVER))
64#define GST_RTSP_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
65#define GST_RTSP_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServer))
66#define GST_RTSP_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
67#define GST_RTSP_SERVER_CAST(obj) ((GstRTSPServer*)(obj))
68#define GST_RTSP_SERVER_CLASS_CAST(klass) ((GstRTSPServerClass*)(klass))
69
70/**
71 * GstRTSPServer:
72 *
73 * This object listens on a port, creates and manages the clients connected to
74 * it.
75 */
76struct _GstRTSPServer {
77 GObject parent;
78
79 /*< private >*/
80 GstRTSPServerPrivate *priv;
81 gpointer _gst_reserved[GST_PADDING];
82};
83
84/**
85 * GstRTSPServerClass:
86 * @create_client: Create, configure a new GstRTSPClient
87 * object that handles the new connection on @socket. The default
88 * implementation will create a GstRTSPClient and will configure the
89 * mount-points, auth, session-pool and thread-pool on the client.
90 * @client_connected: emitted when a new client connected.
91 *
92 * The RTSP server class structure
93 */
94struct _GstRTSPServerClass {
95 GObjectClass parent_class;
96
97 GstRTSPClient * (*create_client) (GstRTSPServer *server);
98
99 /* signals */
100 void (*client_connected) (GstRTSPServer *server, GstRTSPClient *client);
101
102 /*< private >*/
103 gpointer _gst_reserved[GST_PADDING_LARGE];
104};
105
106GST_RTSP_SERVER_API
107GType gst_rtsp_server_get_type (void);
108
109GST_RTSP_SERVER_API
110GstRTSPServer * gst_rtsp_server_new (void);
111
112GST_RTSP_SERVER_API
113void gst_rtsp_server_set_address (GstRTSPServer *server, const gchar *address);
114
115GST_RTSP_SERVER_API
116gchar * gst_rtsp_server_get_address (GstRTSPServer *server);
117
118GST_RTSP_SERVER_API
119void gst_rtsp_server_set_service (GstRTSPServer *server, const gchar *service);
120
121GST_RTSP_SERVER_API
122gchar * gst_rtsp_server_get_service (GstRTSPServer *server);
123
124GST_RTSP_SERVER_API
125void gst_rtsp_server_set_backlog (GstRTSPServer *server, gint backlog);
126
127GST_RTSP_SERVER_API
128gint gst_rtsp_server_get_backlog (GstRTSPServer *server);
129
130GST_RTSP_SERVER_API
131int gst_rtsp_server_get_bound_port (GstRTSPServer *server);
132
133GST_RTSP_SERVER_API
134void gst_rtsp_server_set_session_pool (GstRTSPServer *server, GstRTSPSessionPool *pool);
135
136GST_RTSP_SERVER_API
137GstRTSPSessionPool * gst_rtsp_server_get_session_pool (GstRTSPServer *server);
138
139GST_RTSP_SERVER_API
140void gst_rtsp_server_set_mount_points (GstRTSPServer *server, GstRTSPMountPoints *mounts);
141
142GST_RTSP_SERVER_API
143GstRTSPMountPoints * gst_rtsp_server_get_mount_points (GstRTSPServer *server);
144
145GST_RTSP_SERVER_API
146void gst_rtsp_server_set_auth (GstRTSPServer *server, GstRTSPAuth *auth);
147
148GST_RTSP_SERVER_API
149GstRTSPAuth * gst_rtsp_server_get_auth (GstRTSPServer *server);
150
151GST_RTSP_SERVER_API
152void gst_rtsp_server_set_thread_pool (GstRTSPServer *server, GstRTSPThreadPool *pool);
153
154GST_RTSP_SERVER_API
155GstRTSPThreadPool * gst_rtsp_server_get_thread_pool (GstRTSPServer *server);
156
157GST_RTSP_SERVER_API
158gboolean gst_rtsp_server_transfer_connection (GstRTSPServer * server, GSocket *socket,
159 const gchar * ip, gint port,
160 const gchar *initial_buffer);
161
162GST_RTSP_SERVER_API
163gboolean gst_rtsp_server_io_func (GSocket *socket, GIOCondition condition,
164 GstRTSPServer *server);
165
166GST_RTSP_SERVER_API
167GSocket * gst_rtsp_server_create_socket (GstRTSPServer *server,
168 GCancellable *cancellable,
169 GError **error);
170
171GST_RTSP_SERVER_API
172GSource * gst_rtsp_server_create_source (GstRTSPServer *server,
173 GCancellable * cancellable,
174 GError **error);
175
176GST_RTSP_SERVER_API
177guint gst_rtsp_server_attach (GstRTSPServer *server,
178 GMainContext *context);
179
180/**
181 * GstRTSPServerClientFilterFunc:
182 * @server: a #GstRTSPServer object
183 * @client: a #GstRTSPClient in @server
184 * @user_data: user data that has been given to gst_rtsp_server_client_filter()
185 *
186 * This function will be called by the gst_rtsp_server_client_filter(). An
187 * implementation should return a value of #GstRTSPFilterResult.
188 *
189 * When this function returns #GST_RTSP_FILTER_REMOVE, @client will be removed
190 * from @server.
191 *
192 * A return value of #GST_RTSP_FILTER_KEEP will leave @client untouched in
193 * @server.
194 *
195 * A value of #GST_RTSP_FILTER_REF will add @client to the result #GList of
196 * gst_rtsp_server_client_filter().
197 *
198 * Returns: a #GstRTSPFilterResult.
199 */
200typedef GstRTSPFilterResult (*GstRTSPServerClientFilterFunc) (GstRTSPServer *server,
201 GstRTSPClient *client,
202 gpointer user_data);
203
204GST_RTSP_SERVER_API
205GList * gst_rtsp_server_client_filter (GstRTSPServer *server,
206 GstRTSPServerClientFilterFunc func,
207 gpointer user_data);
208
209#ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
210G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPServer, gst_object_unref)
211#endif
212
213G_END_DECLS
214
215#endif /* __GST_RTSP_SERVER_H__ */