rtsp-stream: Add functions for using rtsp-stream from the client
[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
47 /**
48  * GstRTSPStream:
49  *
50  * The definition of a media stream.
51  */
52 struct _GstRTSPStream {
53   GObject       parent;
54
55   /*< private >*/
56   GstRTSPStreamPrivate *priv;
57   gpointer _gst_reserved[GST_PADDING];
58 };
59
60 struct _GstRTSPStreamClass {
61   GObjectClass parent_class;
62
63   /*< private >*/
64   gpointer _gst_reserved[GST_PADDING];
65 };
66
67 GType             gst_rtsp_stream_get_type         (void);
68
69 GstRTSPStream *   gst_rtsp_stream_new              (guint idx, GstElement *payloader,
70                                                     GstPad *pad);
71 guint             gst_rtsp_stream_get_index        (GstRTSPStream *stream);
72 guint             gst_rtsp_stream_get_pt           (GstRTSPStream *stream);
73 GstPad *          gst_rtsp_stream_get_srcpad       (GstRTSPStream *stream);
74 GstPad *          gst_rtsp_stream_get_sinkpad      (GstRTSPStream *stream);
75
76 void              gst_rtsp_stream_set_control      (GstRTSPStream *stream, const gchar *control);
77 gchar *           gst_rtsp_stream_get_control      (GstRTSPStream *stream);
78 gboolean          gst_rtsp_stream_has_control      (GstRTSPStream *stream, const gchar *control);
79
80 void              gst_rtsp_stream_set_mtu          (GstRTSPStream *stream, guint mtu);
81 guint             gst_rtsp_stream_get_mtu          (GstRTSPStream *stream);
82
83 void              gst_rtsp_stream_set_dscp_qos     (GstRTSPStream *stream, gint dscp_qos);
84 gint              gst_rtsp_stream_get_dscp_qos     (GstRTSPStream *stream);
85
86 gboolean          gst_rtsp_stream_is_transport_supported  (GstRTSPStream *stream,
87                                                            GstRTSPTransport *transport);
88
89 void              gst_rtsp_stream_set_profiles     (GstRTSPStream *stream, GstRTSPProfile profiles);
90 GstRTSPProfile    gst_rtsp_stream_get_profiles     (GstRTSPStream *stream);
91
92 void              gst_rtsp_stream_set_protocols    (GstRTSPStream *stream, GstRTSPLowerTrans protocols);
93 GstRTSPLowerTrans gst_rtsp_stream_get_protocols    (GstRTSPStream *stream);
94
95 void              gst_rtsp_stream_set_address_pool (GstRTSPStream *stream, GstRTSPAddressPool *pool);
96 GstRTSPAddressPool *
97                   gst_rtsp_stream_get_address_pool (GstRTSPStream *stream);
98
99 GstRTSPAddress *  gst_rtsp_stream_reserve_address  (GstRTSPStream *stream,
100                                                     const gchar * address,
101                                                     guint port,
102                                                     guint n_ports,
103                                                     guint ttl);
104
105 gboolean          gst_rtsp_stream_join_bin         (GstRTSPStream *stream,
106                                                     GstBin *bin, GstElement *rtpbin,
107                                                     GstState state);
108 gboolean          gst_rtsp_stream_leave_bin        (GstRTSPStream *stream,
109                                                     GstBin *bin, GstElement *rtpbin);
110
111 gboolean          gst_rtsp_stream_set_blocked      (GstRTSPStream * stream,
112                                                     gboolean blocked);
113 gboolean          gst_rtsp_stream_is_blocking      (GstRTSPStream * stream);
114
115 void              gst_rtsp_stream_set_client_side (GstRTSPStream *stream, gboolean client_side);
116 gboolean          gst_rtsp_stream_is_client_side (GstRTSPStream *stream);
117
118 void              gst_rtsp_stream_get_server_port  (GstRTSPStream *stream,
119                                                     GstRTSPRange *server_port,
120                                                     GSocketFamily family);
121 GstRTSPAddress *  gst_rtsp_stream_get_multicast_address (GstRTSPStream *stream,
122                                                          GSocketFamily family);
123
124
125 GObject *         gst_rtsp_stream_get_rtpsession   (GstRTSPStream *stream);
126
127 void              gst_rtsp_stream_get_ssrc         (GstRTSPStream *stream,
128                                                     guint *ssrc);
129
130 gboolean          gst_rtsp_stream_get_rtpinfo      (GstRTSPStream *stream,
131                                                     guint *rtptime, guint *seq,
132                                                     guint *clock_rate,
133                                                     GstClockTime *running_time);
134 GstCaps *         gst_rtsp_stream_get_caps         (GstRTSPStream *stream);
135
136 GstFlowReturn     gst_rtsp_stream_recv_rtp         (GstRTSPStream *stream,
137                                                     GstBuffer *buffer);
138 GstFlowReturn     gst_rtsp_stream_recv_rtcp        (GstRTSPStream *stream,
139                                                     GstBuffer *buffer);
140
141 gboolean          gst_rtsp_stream_add_transport    (GstRTSPStream *stream,
142                                                     GstRTSPStreamTransport *trans);
143 gboolean          gst_rtsp_stream_remove_transport (GstRTSPStream *stream,
144                                                     GstRTSPStreamTransport *trans);
145
146 GSocket *         gst_rtsp_stream_get_rtp_socket   (GstRTSPStream *stream,
147                                                     GSocketFamily family);
148 GSocket *         gst_rtsp_stream_get_rtcp_socket  (GstRTSPStream *stream,
149                                                     GSocketFamily family);
150
151 gboolean          gst_rtsp_stream_update_crypto    (GstRTSPStream * stream,
152                                                     guint ssrc, GstCaps * crypto);
153
154 gboolean          gst_rtsp_stream_query_position   (GstRTSPStream * stream,
155                                                     gint64 * position);
156 gboolean          gst_rtsp_stream_query_stop       (GstRTSPStream * stream,
157                                                     gint64 * stop);
158
159 void              gst_rtsp_stream_set_seqnum_offset          (GstRTSPStream *stream, guint16 seqnum);
160 guint16           gst_rtsp_stream_get_current_seqnum          (GstRTSPStream *stream);
161 void              gst_rtsp_stream_set_retransmission_time     (GstRTSPStream *stream, GstClockTime time);
162 GstClockTime      gst_rtsp_stream_get_retransmission_time     (GstRTSPStream *stream);
163 guint             gst_rtsp_stream_get_retransmission_pt       (GstRTSPStream * stream);
164 void              gst_rtsp_stream_set_retransmission_pt       (GstRTSPStream * stream,
165                                                                guint rtx_pt);
166 void              gst_rtsp_stream_set_buffer_size  (GstRTSPStream *stream, guint size);
167 guint             gst_rtsp_stream_get_buffer_size  (GstRTSPStream *stream);
168
169 void              gst_rtsp_stream_set_pt_map                 (GstRTSPStream * stream, guint pt, GstCaps * caps);
170 GstElement *      gst_rtsp_stream_request_aux_sender         (GstRTSPStream * stream, guint sessid);
171 /**
172  * GstRTSPStreamTransportFilterFunc:
173  * @stream: a #GstRTSPStream object
174  * @trans: a #GstRTSPStreamTransport in @stream
175  * @user_data: user data that has been given to gst_rtsp_stream_transport_filter()
176  *
177  * This function will be called by the gst_rtsp_stream_transport_filter(). An
178  * implementation should return a value of #GstRTSPFilterResult.
179  *
180  * When this function returns #GST_RTSP_FILTER_REMOVE, @trans will be removed
181  * from @stream.
182  *
183  * A return value of #GST_RTSP_FILTER_KEEP will leave @trans untouched in
184  * @stream.
185  *
186  * A value of #GST_RTSP_FILTER_REF will add @trans to the result #GList of
187  * gst_rtsp_stream_transport_filter().
188  *
189  * Returns: a #GstRTSPFilterResult.
190  */
191 typedef GstRTSPFilterResult (*GstRTSPStreamTransportFilterFunc) (GstRTSPStream *stream,
192                                                                  GstRTSPStreamTransport *trans,
193                                                                  gpointer user_data);
194
195 GList *                gst_rtsp_stream_transport_filter  (GstRTSPStream *stream,
196                                                           GstRTSPStreamTransportFilterFunc func,
197                                                           gpointer user_data);
198
199 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
200 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTSPStream, gst_object_unref)
201 #endif
202
203 G_END_DECLS
204
205 #endif /* __GST_RTSP_STREAM_H__ */