rtsp-stream: obtain stream position from pad
[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-session.h"
33 #include "rtsp-media.h"
34 #include "rtsp-stream.h"
35 #include "rtsp-stream-transport.h"
36 #include "rtsp-address-pool.h"
37 #include "rtsp-thread-pool.h"
38 #include "rtsp-client.h"
39 #include "rtsp-context.h"
40 #include "rtsp-server.h"
41 #include "rtsp-mount-points.h"
42 #include "rtsp-media-factory.h"
43 #include "rtsp-permissions.h"
44 #include "rtsp-auth.h"
45 #include "rtsp-token.h"
46 #include "rtsp-session-media.h"
47 #include "rtsp-sdp.h"
48 #include "rtsp-media-factory-uri.h"
49 #include "rtsp-params.h"
50
51 #define GST_TYPE_RTSP_SERVER              (gst_rtsp_server_get_type ())
52 #define GST_IS_RTSP_SERVER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_SERVER))
53 #define GST_IS_RTSP_SERVER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_SERVER))
54 #define GST_RTSP_SERVER_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
55 #define GST_RTSP_SERVER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_SERVER, GstRTSPServer))
56 #define GST_RTSP_SERVER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_SERVER, GstRTSPServerClass))
57 #define GST_RTSP_SERVER_CAST(obj)         ((GstRTSPServer*)(obj))
58 #define GST_RTSP_SERVER_CLASS_CAST(klass) ((GstRTSPServerClass*)(klass))
59
60 /**
61  * GstRTSPServer:
62  *
63  * This object listens on a port, creates and manages the clients connected to
64  * it.
65  */
66 struct _GstRTSPServer {
67   GObject      parent;
68
69   /*< private >*/
70   GstRTSPServerPrivate *priv;
71   gpointer _gst_reserved[GST_PADDING];
72 };
73
74 /**
75  * GstRTSPServerClass:
76  * @create_client: Create, configure a new GstRTSPClient
77  *          object that handles the new connection on @socket. The default
78  *          implementation will create a GstRTSPClient and will configure the
79  *          mount-points, auth, session-pool and thread-pool on the client.
80  * @client_connected: emitted when a new client connected.
81  *
82  * The RTSP server class structure
83  */
84 struct _GstRTSPServerClass {
85   GObjectClass  parent_class;
86
87   GstRTSPClient * (*create_client)      (GstRTSPServer *server);
88
89   /* signals */
90   void            (*client_connected)   (GstRTSPServer *server, GstRTSPClient *client);
91
92   /*< private >*/
93   gpointer         _gst_reserved[GST_PADDING_LARGE];
94 };
95
96 GST_EXPORT
97 GType                 gst_rtsp_server_get_type             (void);
98
99 GST_EXPORT
100 GstRTSPServer *       gst_rtsp_server_new                  (void);
101
102 GST_EXPORT
103 void                  gst_rtsp_server_set_address          (GstRTSPServer *server, const gchar *address);
104
105 GST_EXPORT
106 gchar *               gst_rtsp_server_get_address          (GstRTSPServer *server);
107
108 GST_EXPORT
109 void                  gst_rtsp_server_set_service          (GstRTSPServer *server, const gchar *service);
110
111 GST_EXPORT
112 gchar *               gst_rtsp_server_get_service          (GstRTSPServer *server);
113
114 GST_EXPORT
115 void                  gst_rtsp_server_set_backlog          (GstRTSPServer *server, gint backlog);
116
117 GST_EXPORT
118 gint                  gst_rtsp_server_get_backlog          (GstRTSPServer *server);
119
120 GST_EXPORT
121 int                   gst_rtsp_server_get_bound_port       (GstRTSPServer *server);
122
123 GST_EXPORT
124 void                  gst_rtsp_server_set_session_pool     (GstRTSPServer *server, GstRTSPSessionPool *pool);
125
126 GST_EXPORT
127 GstRTSPSessionPool *  gst_rtsp_server_get_session_pool     (GstRTSPServer *server);
128
129 GST_EXPORT
130 void                  gst_rtsp_server_set_mount_points     (GstRTSPServer *server, GstRTSPMountPoints *mounts);
131
132 GST_EXPORT
133 GstRTSPMountPoints *  gst_rtsp_server_get_mount_points     (GstRTSPServer *server);
134
135 GST_EXPORT
136 void                  gst_rtsp_server_set_auth             (GstRTSPServer *server, GstRTSPAuth *auth);
137
138 GST_EXPORT
139 GstRTSPAuth *         gst_rtsp_server_get_auth             (GstRTSPServer *server);
140
141 GST_EXPORT
142 void                  gst_rtsp_server_set_thread_pool      (GstRTSPServer *server, GstRTSPThreadPool *pool);
143
144 GST_EXPORT
145 GstRTSPThreadPool *   gst_rtsp_server_get_thread_pool      (GstRTSPServer *server);
146
147 GST_EXPORT
148 gboolean              gst_rtsp_server_transfer_connection  (GstRTSPServer * server, GSocket *socket,
149                                                             const gchar * ip, gint port,
150                                                             const gchar *initial_buffer);
151
152 GST_EXPORT
153 gboolean              gst_rtsp_server_io_func              (GSocket *socket, GIOCondition condition,
154                                                             GstRTSPServer *server);
155
156 GST_EXPORT
157 GSocket *             gst_rtsp_server_create_socket        (GstRTSPServer *server,
158                                                             GCancellable  *cancellable,
159                                                             GError **error);
160
161 GST_EXPORT
162 GSource *             gst_rtsp_server_create_source        (GstRTSPServer *server,
163                                                             GCancellable * cancellable,
164                                                             GError **error);
165
166 GST_EXPORT
167 guint                 gst_rtsp_server_attach               (GstRTSPServer *server,
168                                                             GMainContext *context);
169
170 /**
171  * GstRTSPServerClientFilterFunc:
172  * @server: a #GstRTSPServer object
173  * @client: a #GstRTSPClient in @server
174  * @user_data: user data that has been given to gst_rtsp_server_client_filter()
175  *
176  * This function will be called by the gst_rtsp_server_client_filter(). An
177  * implementation should return a value of #GstRTSPFilterResult.
178  *
179  * When this function returns #GST_RTSP_FILTER_REMOVE, @client will be removed
180  * from @server.
181  *
182  * A return value of #GST_RTSP_FILTER_KEEP will leave @client untouched in
183  * @server.
184  *
185  * A value of #GST_RTSP_FILTER_REF will add @client to the result #GList of
186  * gst_rtsp_server_client_filter().
187  *
188  * Returns: a #GstRTSPFilterResult.
189  */
190 typedef GstRTSPFilterResult (*GstRTSPServerClientFilterFunc)  (GstRTSPServer *server,
191                                                                GstRTSPClient *client,
192                                                                gpointer user_data);
193
194 GST_EXPORT
195 GList *                gst_rtsp_server_client_filter    (GstRTSPServer *server,
196                                                          GstRTSPServerClientFilterFunc func,
197                                                          gpointer user_data);
198
199 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
200 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPServer, gst_object_unref)
201 #endif
202
203 G_END_DECLS
204
205 #endif /* __GST_RTSP_SERVER_H__ */