610c9a0a184e39726f737158cad6ca5f1d7c1fcb
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-server.h
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
25 G_BEGIN_DECLS
26
27 typedef struct _GstRTSPServer GstRTSPServer;
28 typedef struct _GstRTSPServerClass GstRTSPServerClass;
29 typedef struct _GstRTSPServerPrivate GstRTSPServerPrivate;
30
31 #include "rtsp-session-pool.h"
32 #include "rtsp-mount-points.h"
33 #include "rtsp-client.h"
34 #include "rtsp-auth.h"
35
36 #define GST_TYPE_RTSP_SERVER              (gst_rtsp_server_get_type ())
37 #define GST_IS_RTSP_SERVER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SERVER))
38 #define GST_IS_RTSP_SERVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SERVER))
39 #define GST_RTSP_SERVER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
40 #define GST_RTSP_SERVER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServer))
41 #define GST_RTSP_SERVER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
42 #define GST_RTSP_SERVER_CAST(obj)         ((GstRTSPServer*)(obj))
43 #define GST_RTSP_SERVER_CLASS_CAST(klass) ((GstRTSPServerClass*)(klass))
44
45 /**
46  * GstRTSPServer:
47  *
48  * This object listens on a port, creates and manages the clients connected to
49  * it.
50  */
51 struct _GstRTSPServer {
52   GObject      parent;
53
54   GstRTSPServerPrivate *priv;
55 };
56
57 /**
58  * GstRTSPServerClass:
59  * @create_client: Create, configure a new GstRTSPClient
60  *          object that handles the new connection on @socket. The default
61  *          implementation will create a GstRTSPClient and will configure the
62  *          mount-points, auth, session-pool and thread-pool on the client.
63  * @client_connected: emited when a new client connected.
64  *
65  * The RTSP server class structure
66  */
67 struct _GstRTSPServerClass {
68   GObjectClass  parent_class;
69
70   GstRTSPClient * (*create_client)      (GstRTSPServer *server);
71
72   /* signals */
73   void            (*client_connected)   (GstRTSPServer *server, GstRTSPClient *client);
74 };
75
76 GType                 gst_rtsp_server_get_type             (void);
77
78 GstRTSPServer *       gst_rtsp_server_new                  (void);
79
80 void                  gst_rtsp_server_set_address          (GstRTSPServer *server, const gchar *address);
81 gchar *               gst_rtsp_server_get_address          (GstRTSPServer *server);
82
83 void                  gst_rtsp_server_set_service          (GstRTSPServer *server, const gchar *service);
84 gchar *               gst_rtsp_server_get_service          (GstRTSPServer *server);
85
86 void                  gst_rtsp_server_set_backlog          (GstRTSPServer *server, gint backlog);
87 gint                  gst_rtsp_server_get_backlog          (GstRTSPServer *server);
88
89 int                   gst_rtsp_server_get_bound_port       (GstRTSPServer *server);
90
91 void                  gst_rtsp_server_set_session_pool     (GstRTSPServer *server, GstRTSPSessionPool *pool);
92 GstRTSPSessionPool *  gst_rtsp_server_get_session_pool     (GstRTSPServer *server);
93
94 void                  gst_rtsp_server_set_mount_points     (GstRTSPServer *server, GstRTSPMountPoints *mounts);
95 GstRTSPMountPoints *  gst_rtsp_server_get_mount_points     (GstRTSPServer *server);
96
97 void                  gst_rtsp_server_set_auth             (GstRTSPServer *server, GstRTSPAuth *auth);
98 GstRTSPAuth *         gst_rtsp_server_get_auth             (GstRTSPServer *server);
99
100 void                  gst_rtsp_server_set_thread_pool      (GstRTSPServer *server, GstRTSPThreadPool *pool);
101 GstRTSPThreadPool *   gst_rtsp_server_get_thread_pool      (GstRTSPServer *server);
102
103 gboolean              gst_rtsp_server_transfer_connection  (GstRTSPServer * server, GSocket *socket,
104                                                             const gchar * ip, gint port,
105                                                             const gchar *initial_buffer);
106
107 gboolean              gst_rtsp_server_io_func              (GSocket *socket, GIOCondition condition,
108                                                             GstRTSPServer *server);
109
110 GSocket *             gst_rtsp_server_create_socket        (GstRTSPServer *server,
111                                                             GCancellable  *cancellable,
112                                                             GError **error);
113 GSource *             gst_rtsp_server_create_source        (GstRTSPServer *server,
114                                                             GCancellable * cancellable,
115                                                             GError **error);
116 guint                 gst_rtsp_server_attach               (GstRTSPServer *server,
117                                                             GMainContext *context);
118
119 /**
120  * GstRTSPServerClientFilterFunc:
121  * @server: a #GstRTSPServer object
122  * @client: a #GstRTSPClient in @server
123  * @user_data: user data that has been given to gst_rtsp_server_client_filter()
124  *
125  * This function will be called by the gst_rtsp_server_client_filter(). An
126  * implementation should return a value of #GstRTSPFilterResult.
127  *
128  * When this function returns #GST_RTSP_FILTER_REMOVE, @client will be removed
129  * from @server.
130  *
131  * A return value of #GST_RTSP_FILTER_KEEP will leave @client untouched in
132  * @server.
133  *
134  * A value of #GST_RTSP_FILTER_REF will add @client to the result #GList of
135  * gst_rtsp_server_client_filter().
136  *
137  * Returns: a #GstRTSPFilterResult.
138  */
139 typedef GstRTSPFilterResult (*GstRTSPServerClientFilterFunc)  (GstRTSPServer *server,
140                                                                GstRTSPClient *client,
141                                                                gpointer user_data);
142
143 GList *                gst_rtsp_server_client_filter    (GstRTSPServer *server,
144                                                          GstRTSPServerClientFilterFunc func,
145                                                          gpointer user_data);
146
147 G_END_DECLS
148
149 #endif /* __GST_RTSP_SERVER_H__ */