rtsp-stream: obtain stream position from pad
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-stream.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/rtsp.h>
22 #include <gio/gio.h>
23
24 #ifndef __GST_RTSP_STREAM_H__
25 #define __GST_RTSP_STREAM_H__
26
27 G_BEGIN_DECLS
28
29 /* types for the media stream */
30 #define GST_TYPE_RTSP_STREAM              (gst_rtsp_stream_get_type ())
31 #define GST_IS_RTSP_STREAM(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_STREAM))
32 #define GST_IS_RTSP_STREAM_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_STREAM))
33 #define GST_RTSP_STREAM_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_STREAM, GstRTSPStreamClass))
34 #define GST_RTSP_STREAM(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_STREAM, GstRTSPStream))
35 #define GST_RTSP_STREAM_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_STREAM, GstRTSPStreamClass))
36 #define GST_RTSP_STREAM_CAST(obj)         ((GstRTSPStream*)(obj))
37 #define GST_RTSP_STREAM_CLASS_CAST(klass) ((GstRTSPStreamClass*)(klass))
38
39 typedef struct _GstRTSPStream GstRTSPStream;
40 typedef struct _GstRTSPStreamClass GstRTSPStreamClass;
41 typedef struct _GstRTSPStreamPrivate GstRTSPStreamPrivate;
42
43 #include "rtsp-stream-transport.h"
44 #include "rtsp-address-pool.h"
45 #include "rtsp-session.h"
46 #include "rtsp-media.h"
47
48 /**
49  * GstRTSPStream:
50  *
51  * The definition of a media stream.
52  */
53 struct _GstRTSPStream {
54   GObject       parent;
55
56   /*< private >*/
57   GstRTSPStreamPrivate *priv;
58   gpointer _gst_reserved[GST_PADDING];
59 };
60
61 struct _GstRTSPStreamClass {
62   GObjectClass parent_class;
63
64   /*< private >*/
65   gpointer _gst_reserved[GST_PADDING];
66 };
67
68 GST_EXPORT
69 GType             gst_rtsp_stream_get_type         (void);
70
71 GST_EXPORT
72 GstRTSPStream *   gst_rtsp_stream_new              (guint idx, GstElement *payloader,
73                                                     GstPad *pad);
74
75 GST_EXPORT
76 guint             gst_rtsp_stream_get_index        (GstRTSPStream *stream);
77
78 GST_EXPORT
79 guint             gst_rtsp_stream_get_pt           (GstRTSPStream *stream);
80
81 GST_EXPORT
82 GstPad *          gst_rtsp_stream_get_srcpad       (GstRTSPStream *stream);
83
84 GST_EXPORT
85 GstPad *          gst_rtsp_stream_get_sinkpad      (GstRTSPStream *stream);
86
87 GST_EXPORT
88 void              gst_rtsp_stream_set_control      (GstRTSPStream *stream, const gchar *control);
89
90 GST_EXPORT
91 gchar *           gst_rtsp_stream_get_control      (GstRTSPStream *stream);
92
93 GST_EXPORT
94 gboolean          gst_rtsp_stream_has_control      (GstRTSPStream *stream, const gchar *control);
95
96 GST_EXPORT
97 void              gst_rtsp_stream_set_mtu          (GstRTSPStream *stream, guint mtu);
98
99 GST_EXPORT
100 guint             gst_rtsp_stream_get_mtu          (GstRTSPStream *stream);
101
102 GST_EXPORT
103 void              gst_rtsp_stream_set_dscp_qos     (GstRTSPStream *stream, gint dscp_qos);
104
105 GST_EXPORT
106 gint              gst_rtsp_stream_get_dscp_qos     (GstRTSPStream *stream);
107
108 GST_EXPORT
109 gboolean          gst_rtsp_stream_is_transport_supported  (GstRTSPStream *stream,
110                                                            GstRTSPTransport *transport);
111
112 GST_EXPORT
113 void              gst_rtsp_stream_set_profiles     (GstRTSPStream *stream, GstRTSPProfile profiles);
114
115 GST_EXPORT
116 GstRTSPProfile    gst_rtsp_stream_get_profiles     (GstRTSPStream *stream);
117
118 GST_EXPORT
119 void              gst_rtsp_stream_set_protocols    (GstRTSPStream *stream, GstRTSPLowerTrans protocols);
120
121 GST_EXPORT
122 GstRTSPLowerTrans gst_rtsp_stream_get_protocols    (GstRTSPStream *stream);
123
124 GST_EXPORT
125 void              gst_rtsp_stream_set_address_pool (GstRTSPStream *stream, GstRTSPAddressPool *pool);
126
127 GST_EXPORT
128 GstRTSPAddressPool *
129                   gst_rtsp_stream_get_address_pool (GstRTSPStream *stream);
130
131 GST_EXPORT
132 void              gst_rtsp_stream_set_multicast_iface (GstRTSPStream *stream, const gchar * multicast_iface);
133
134 GST_EXPORT
135 gchar *           gst_rtsp_stream_get_multicast_iface (GstRTSPStream *stream);
136
137 GST_EXPORT
138 GstRTSPAddress *  gst_rtsp_stream_reserve_address  (GstRTSPStream *stream,
139                                                     const gchar * address,
140                                                     guint port,
141                                                     guint n_ports,
142                                                     guint ttl);
143
144 GST_EXPORT
145 gboolean          gst_rtsp_stream_join_bin         (GstRTSPStream *stream,
146                                                     GstBin *bin, GstElement *rtpbin,
147                                                     GstState state);
148
149 GST_EXPORT
150 gboolean          gst_rtsp_stream_leave_bin        (GstRTSPStream *stream,
151                                                     GstBin *bin, GstElement *rtpbin);
152
153 GST_EXPORT
154 GstBin *          gst_rtsp_stream_get_joined_bin   (GstRTSPStream *stream);
155
156 GST_EXPORT
157 gboolean          gst_rtsp_stream_set_blocked      (GstRTSPStream * stream,
158                                                     gboolean blocked);
159
160 GST_EXPORT
161 gboolean          gst_rtsp_stream_is_blocking      (GstRTSPStream * stream);
162
163 GST_EXPORT
164 void              gst_rtsp_stream_set_client_side (GstRTSPStream *stream, gboolean client_side);
165
166 GST_EXPORT
167 gboolean          gst_rtsp_stream_is_client_side (GstRTSPStream *stream);
168
169 GST_EXPORT
170 void              gst_rtsp_stream_get_server_port  (GstRTSPStream *stream,
171                                                     GstRTSPRange *server_port,
172                                                     GSocketFamily family);
173
174 GST_EXPORT
175 GstRTSPAddress *  gst_rtsp_stream_get_multicast_address (GstRTSPStream *stream,
176                                                          GSocketFamily family);
177
178
179 GST_EXPORT
180 GObject *         gst_rtsp_stream_get_rtpsession   (GstRTSPStream *stream);
181
182 GST_EXPORT
183 GstElement *      gst_rtsp_stream_get_srtp_encoder (GstRTSPStream *stream);
184
185 GST_EXPORT
186 void              gst_rtsp_stream_get_ssrc         (GstRTSPStream *stream,
187                                                     guint *ssrc);
188
189 GST_EXPORT
190 gboolean          gst_rtsp_stream_get_rtpinfo      (GstRTSPStream *stream,
191                                                     guint *rtptime, guint *seq,
192                                                     guint *clock_rate,
193                                                     GstClockTime *running_time);
194
195 GST_EXPORT
196 GstCaps *         gst_rtsp_stream_get_caps         (GstRTSPStream *stream);
197
198 GST_EXPORT
199 GstFlowReturn     gst_rtsp_stream_recv_rtp         (GstRTSPStream *stream,
200                                                     GstBuffer *buffer);
201
202 GST_EXPORT
203 GstFlowReturn     gst_rtsp_stream_recv_rtcp        (GstRTSPStream *stream,
204                                                     GstBuffer *buffer);
205
206 GST_EXPORT
207 gboolean          gst_rtsp_stream_add_transport    (GstRTSPStream *stream,
208                                                     GstRTSPStreamTransport *trans);
209
210 GST_EXPORT
211 gboolean          gst_rtsp_stream_remove_transport (GstRTSPStream *stream,
212                                                     GstRTSPStreamTransport *trans);
213
214 GST_EXPORT
215 GSocket *         gst_rtsp_stream_get_rtp_socket   (GstRTSPStream *stream,
216                                                     GSocketFamily family);
217
218 GST_EXPORT
219 GSocket *         gst_rtsp_stream_get_rtcp_socket  (GstRTSPStream *stream,
220                                                     GSocketFamily family);
221
222 GST_EXPORT
223 GSocket *         gst_rtsp_stream_get_rtp_multicast_socket (GstRTSPStream *stream,
224                                                             GSocketFamily family);
225
226 GST_EXPORT
227 GSocket *         gst_rtsp_stream_get_rtcp_multicast_socket (GstRTSPStream *stream,
228                                                              GSocketFamily family);
229
230 GST_EXPORT
231 gboolean          gst_rtsp_stream_update_crypto    (GstRTSPStream * stream,
232                                                     guint ssrc, GstCaps * crypto);
233
234 GST_EXPORT
235 gboolean          gst_rtsp_stream_query_position   (GstRTSPStream * stream,
236                                                     gint64 * position);
237
238 GST_EXPORT
239 gboolean          gst_rtsp_stream_query_stop       (GstRTSPStream * stream,
240                                                     gint64 * stop);
241
242 GST_EXPORT
243 void              gst_rtsp_stream_set_seqnum_offset          (GstRTSPStream *stream, guint16 seqnum);
244
245 GST_EXPORT
246 guint16           gst_rtsp_stream_get_current_seqnum          (GstRTSPStream *stream);
247
248 GST_EXPORT
249 void              gst_rtsp_stream_set_retransmission_time     (GstRTSPStream *stream, GstClockTime time);
250
251 GST_EXPORT
252 GstClockTime      gst_rtsp_stream_get_retransmission_time     (GstRTSPStream *stream);
253
254 GST_EXPORT
255 guint             gst_rtsp_stream_get_retransmission_pt       (GstRTSPStream * stream);
256
257 GST_EXPORT
258 void              gst_rtsp_stream_set_retransmission_pt       (GstRTSPStream * stream,
259                                                                guint rtx_pt);
260
261 GST_EXPORT
262 void              gst_rtsp_stream_set_buffer_size  (GstRTSPStream *stream, guint size);
263
264 GST_EXPORT
265 guint             gst_rtsp_stream_get_buffer_size  (GstRTSPStream *stream);
266
267 GST_EXPORT
268 void              gst_rtsp_stream_set_pt_map                 (GstRTSPStream * stream, guint pt, GstCaps * caps);
269
270 GST_EXPORT
271 GstElement *      gst_rtsp_stream_request_aux_sender         (GstRTSPStream * stream, guint sessid);
272
273 GST_EXPORT
274 gboolean          gst_rtsp_stream_allocate_udp_sockets       (GstRTSPStream * stream, GSocketFamily family,
275                                                               GstRTSPTransport *transport, gboolean use_client_setttings);
276
277 GST_EXPORT
278 void                    gst_rtsp_stream_set_publish_clock_mode (GstRTSPStream * stream, GstRTSPPublishClockMode mode);
279
280 GST_EXPORT
281 GstRTSPPublishClockMode gst_rtsp_stream_get_publish_clock_mode (GstRTSPStream * stream);
282
283 /**
284  * GstRTSPStreamTransportFilterFunc:
285  * @stream: a #GstRTSPStream object
286  * @trans: a #GstRTSPStreamTransport in @stream
287  * @user_data: user data that has been given to gst_rtsp_stream_transport_filter()
288  *
289  * This function will be called by the gst_rtsp_stream_transport_filter(). An
290  * implementation should return a value of #GstRTSPFilterResult.
291  *
292  * When this function returns #GST_RTSP_FILTER_REMOVE, @trans will be removed
293  * from @stream.
294  *
295  * A return value of #GST_RTSP_FILTER_KEEP will leave @trans untouched in
296  * @stream.
297  *
298  * A value of #GST_RTSP_FILTER_REF will add @trans to the result #GList of
299  * gst_rtsp_stream_transport_filter().
300  *
301  * Returns: a #GstRTSPFilterResult.
302  */
303 typedef GstRTSPFilterResult (*GstRTSPStreamTransportFilterFunc) (GstRTSPStream *stream,
304                                                                  GstRTSPStreamTransport *trans,
305                                                                  gpointer user_data);
306
307 GST_EXPORT
308 GList *                gst_rtsp_stream_transport_filter  (GstRTSPStream *stream,
309                                                           GstRTSPStreamTransportFilterFunc func,
310                                                           gpointer user_data);
311
312 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
313 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPStream, gst_object_unref)
314 #endif
315
316 G_END_DECLS
317
318 #endif /* __GST_RTSP_STREAM_H__ */