rtsp-client: allow application to decide what requirements are supported
[platform/upstream/gst-rtsp-server.git] / gst / rtsp-server / rtsp-client.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 #include <gst/gst.h>
21 #include <gst/rtsp/gstrtspconnection.h>
22
23 #ifndef __GST_RTSP_CLIENT_H__
24 #define __GST_RTSP_CLIENT_H__
25
26 G_BEGIN_DECLS
27
28 typedef struct _GstRTSPClient GstRTSPClient;
29 typedef struct _GstRTSPClientClass GstRTSPClientClass;
30 typedef struct _GstRTSPClientPrivate GstRTSPClientPrivate;
31
32 #include "rtsp-context.h"
33 #include "rtsp-mount-points.h"
34 #include "rtsp-sdp.h"
35 #include "rtsp-auth.h"
36
37 #define GST_TYPE_RTSP_CLIENT              (gst_rtsp_client_get_type ())
38 #define GST_IS_RTSP_CLIENT(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_CLIENT))
39 #define GST_IS_RTSP_CLIENT_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_CLIENT))
40 #define GST_RTSP_CLIENT_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
41 #define GST_RTSP_CLIENT(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_CLIENT, GstRTSPClient))
42 #define GST_RTSP_CLIENT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_CLIENT, GstRTSPClientClass))
43 #define GST_RTSP_CLIENT_CAST(obj)         ((GstRTSPClient*)(obj))
44 #define GST_RTSP_CLIENT_CLASS_CAST(klass) ((GstRTSPClientClass*)(klass))
45
46 /**
47  * GstRTSPClientSendFunc:
48  * @client: a #GstRTSPClient
49  * @message: a #GstRTSPMessage
50  * @close: close the connection
51  * @user_data: user data when registering the callback
52  *
53  * This callback is called when @client wants to send @message. When @close is
54  * %TRUE, the connection should be closed when the message has been sent.
55  *
56  * Returns: %TRUE on success.
57  */
58 typedef gboolean (*GstRTSPClientSendFunc)      (GstRTSPClient *client,
59                                                 GstRTSPMessage *message,
60                                                 gboolean close,
61                                                 gpointer user_data);
62
63 /**
64  * GstRTSPClient:
65  *
66  * The client object represents the connection and its state with a client.
67  */
68 struct _GstRTSPClient {
69   GObject       parent;
70
71   /*< private >*/
72   GstRTSPClientPrivate *priv;
73   gpointer _gst_reserved[GST_PADDING];
74 };
75
76 /**
77  * GstRTSPClientClass:
78  * @create_sdp: called when the SDP needs to be created for media.
79  * @configure_client_media: called when the stream in media needs to be configured.
80  *    The default implementation will configure the blocksize on the payloader when
81  *    spcified in the request headers.
82  * @configure_client_transport: called when the client transport needs to be
83  *    configured.
84  * @params_set: set parameters. This function should also initialize the
85  *    RTSP response(ctx->response) via a call to gst_rtsp_message_init_response()
86  * @params_get: get parameters. This function should also initialize the
87  *    RTSP response(ctx->response) via a call to gst_rtsp_message_init_response()
88  * @tunnel_http_response: called when a response to the GET request is about to
89  *   be sent for a tunneled connection. The response can be modified. Since 1.4
90  *
91  * The client class structure.
92  */
93 struct _GstRTSPClientClass {
94   GObjectClass  parent_class;
95
96   GstSDPMessage * (*create_sdp) (GstRTSPClient *client, GstRTSPMedia *media);
97   gboolean        (*configure_client_media)     (GstRTSPClient * client,
98                                                  GstRTSPMedia * media, GstRTSPStream * stream,
99                                                  GstRTSPContext * ctx);
100   gboolean        (*configure_client_transport) (GstRTSPClient * client,
101                                                  GstRTSPContext * ctx,
102                                                  GstRTSPTransport * ct);
103   GstRTSPResult   (*params_set) (GstRTSPClient *client, GstRTSPContext *ctx);
104   GstRTSPResult   (*params_get) (GstRTSPClient *client, GstRTSPContext *ctx);
105   gchar *         (*make_path_from_uri) (GstRTSPClient *client, const GstRTSPUrl *uri);
106
107   /* signals */
108   void     (*closed)                  (GstRTSPClient *client);
109   void     (*new_session)             (GstRTSPClient *client, GstRTSPSession *session);
110   void     (*options_request)         (GstRTSPClient *client, GstRTSPContext *ctx);
111   void     (*describe_request)        (GstRTSPClient *client, GstRTSPContext *ctx);
112   void     (*setup_request)           (GstRTSPClient *client, GstRTSPContext *ctx);
113   void     (*play_request)            (GstRTSPClient *client, GstRTSPContext *ctx);
114   void     (*pause_request)           (GstRTSPClient *client, GstRTSPContext *ctx);
115   void     (*teardown_request)        (GstRTSPClient *client, GstRTSPContext *ctx);
116   void     (*set_parameter_request)   (GstRTSPClient *client, GstRTSPContext *ctx);
117   void     (*get_parameter_request)   (GstRTSPClient *client, GstRTSPContext *ctx);
118   void     (*handle_response)         (GstRTSPClient *client, GstRTSPContext *ctx);
119
120   void     (*tunnel_http_response)    (GstRTSPClient * client, GstRTSPMessage * request,
121                                        GstRTSPMessage * response);
122   void     (*send_message)            (GstRTSPClient * client, GstRTSPContext *ctx,
123                                        GstRTSPMessage * response);
124
125   gboolean (*handle_sdp)              (GstRTSPClient *client, GstRTSPContext *ctx, GstRTSPMedia *media, GstSDPMessage *sdp);
126
127   void     (*announce_request)        (GstRTSPClient *client, GstRTSPContext *ctx);
128   void     (*record_request)          (GstRTSPClient *client, GstRTSPContext *ctx);
129   gchar*   (*check_requirements)      (GstRTSPClient *client, GstRTSPContext *ctx, gchar ** arr);
130
131   /*< private >*/
132   gpointer _gst_reserved[GST_PADDING_LARGE-6];
133 };
134
135 GType                 gst_rtsp_client_get_type          (void);
136
137 GstRTSPClient *       gst_rtsp_client_new               (void);
138
139 void                  gst_rtsp_client_set_session_pool  (GstRTSPClient *client,
140                                                          GstRTSPSessionPool *pool);
141 GstRTSPSessionPool *  gst_rtsp_client_get_session_pool  (GstRTSPClient *client);
142
143 void                  gst_rtsp_client_set_mount_points  (GstRTSPClient *client,
144                                                          GstRTSPMountPoints *mounts);
145 GstRTSPMountPoints *  gst_rtsp_client_get_mount_points  (GstRTSPClient *client);
146
147 void                  gst_rtsp_client_set_auth          (GstRTSPClient *client, GstRTSPAuth *auth);
148 GstRTSPAuth *         gst_rtsp_client_get_auth          (GstRTSPClient *client);
149
150 void                  gst_rtsp_client_set_thread_pool   (GstRTSPClient *client, GstRTSPThreadPool *pool);
151 GstRTSPThreadPool *   gst_rtsp_client_get_thread_pool   (GstRTSPClient *client);
152
153 gboolean              gst_rtsp_client_set_connection    (GstRTSPClient *client, GstRTSPConnection *conn);
154 GstRTSPConnection *   gst_rtsp_client_get_connection    (GstRTSPClient *client);
155
156 guint                 gst_rtsp_client_attach            (GstRTSPClient *client,
157                                                          GMainContext *context);
158 void                  gst_rtsp_client_close             (GstRTSPClient * client);
159
160 void                  gst_rtsp_client_set_send_func     (GstRTSPClient *client,
161                                                          GstRTSPClientSendFunc func,
162                                                          gpointer user_data,
163                                                          GDestroyNotify notify);
164
165 GstRTSPResult         gst_rtsp_client_handle_message    (GstRTSPClient *client,
166                                                          GstRTSPMessage *message);
167 GstRTSPResult         gst_rtsp_client_send_message      (GstRTSPClient * client,
168                                                          GstRTSPSession *session,
169                                                          GstRTSPMessage *message);
170 /**
171  * GstRTSPClientSessionFilterFunc:
172  * @client: a #GstRTSPClient object
173  * @sess: a #GstRTSPSession in @client
174  * @user_data: user data that has been given to gst_rtsp_client_session_filter()
175  *
176  * This function will be called by the gst_rtsp_client_session_filter(). An
177  * implementation should return a value of #GstRTSPFilterResult.
178  *
179  * When this function returns #GST_RTSP_FILTER_REMOVE, @sess will be removed
180  * from @client.
181  *
182  * A return value of #GST_RTSP_FILTER_KEEP will leave @sess untouched in
183  * @client.
184  *
185  * A value of #GST_RTSP_FILTER_REF will add @sess to the result #GList of
186  * gst_rtsp_client_session_filter().
187  *
188  * Returns: a #GstRTSPFilterResult.
189  */
190 typedef GstRTSPFilterResult (*GstRTSPClientSessionFilterFunc)  (GstRTSPClient *client,
191                                                                 GstRTSPSession *sess,
192                                                                 gpointer user_data);
193
194 GList *                gst_rtsp_client_session_filter    (GstRTSPClient *client,
195                                                           GstRTSPClientSessionFilterFunc func,
196                                                           gpointer user_data);
197
198
199
200 G_END_DECLS
201
202 #endif /* __GST_RTSP_CLIENT_H__ */