2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * <2006> Wim Taymans <wim@fluendo.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 * Unless otherwise indicated, Source Code is licensed under MIT license.
22 * See further explanation attached in License Statement (distributed in the file
25 * Permission is hereby granted, free of charge, to any person obtaining a copy of
26 * this software and associated documentation files (the "Software"), to deal in
27 * the Software without restriction, including without limitation the rights to
28 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
29 * of the Software, and to permit persons to whom the Software is furnished to do
30 * so, subject to the following conditions:
32 * The above copyright notice and this permission notice shall be included in all
33 * copies or substantial portions of the Software.
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44 #ifndef __GST_RTSPSRC_H__
45 #define __GST_RTSPSRC_H__
51 #include <gst/rtsp/rtsp.h>
54 #include "gstrtspext.h"
56 #define GST_TYPE_RTSPSRC \
57 (gst_rtspsrc_get_type())
58 #define GST_RTSPSRC(obj) \
59 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTSPSRC,GstRTSPSrc))
60 #define GST_RTSPSRC_CLASS(klass) \
61 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTSPSRC,GstRTSPSrcClass))
62 #define GST_IS_RTSPSRC(obj) \
63 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTSPSRC))
64 #define GST_IS_RTSPSRC_CLASS(klass) \
65 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTSPSRC))
66 #define GST_RTSPSRC_CAST(obj) \
69 typedef struct _GstRTSPSrc GstRTSPSrc;
70 typedef struct _GstRTSPSrcClass GstRTSPSrcClass;
72 #define GST_RTSP_STATE_GET_LOCK(rtsp) (&GST_RTSPSRC_CAST(rtsp)->state_rec_lock)
73 #define GST_RTSP_STATE_LOCK(rtsp) (g_rec_mutex_lock (GST_RTSP_STATE_GET_LOCK(rtsp)))
74 #define GST_RTSP_STATE_UNLOCK(rtsp) (g_rec_mutex_unlock (GST_RTSP_STATE_GET_LOCK(rtsp)))
76 #define GST_RTSP_STREAM_GET_LOCK(rtsp) (&GST_RTSPSRC_CAST(rtsp)->stream_rec_lock)
77 #define GST_RTSP_STREAM_LOCK(rtsp) (g_rec_mutex_lock (GST_RTSP_STREAM_GET_LOCK(rtsp)))
78 #define GST_RTSP_STREAM_UNLOCK(rtsp) (g_rec_mutex_unlock (GST_RTSP_STREAM_GET_LOCK(rtsp)))
80 typedef struct _GstRTSPConnInfo GstRTSPConnInfo;
82 struct _GstRTSPConnInfo {
86 GstRTSPConnection *connection;
94 typedef struct _GstRTSPStream GstRTSPStream;
96 struct _GstRTSPStream {
99 GstRTSPSrc *parent; /* parent, no extra ref to parent is taken */
101 /* pad we expose or NULL when it does not have an actual pad */
103 GstFlowReturn last_ret;
110 gboolean waiting_setup_response;
112 /* for interleaved mode */
114 GstPad *channelpad[2];
116 /* our udp sources */
117 GstElement *udpsrc[2];
122 /* our udp sinks back to the server */
123 GstElement *udpsink[2];
126 /* fakesrc for sending dummy data or appsrc for sending backchannel data */
134 GstRTSPProfile profile;
136 /* original control url */
142 GstCaps *srtcpparams;
146 /* per stream connection */
147 GstRTSPConnInfo conninfo;
152 /* srtp key management */
153 GstMIKEYMessage *mikey;
162 gboolean is_multicast;
164 gboolean is_backchannel;
166 /* A unique and stable id we will use for the stream start event */
169 GstStructure *rtx_pt_map;
171 guint32 segment_seqnum[2];
175 * GstRTSPSrcTimeoutCause:
176 * @GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP: timeout triggered by RTCP
178 * Different causes to why the rtspsrc generated the GstRTSPSrcTimeout
183 GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP
184 } GstRTSPSrcTimeoutCause;
188 * @GST_RTSP_NAT_NONE: none
189 * @GST_RTSP_NAT_DUMMY: send dummy packets
191 * Different methods for trying to traverse firewalls.
203 /* task and mutex for interleaved mode */
204 gboolean interleaved;
206 GRecMutex stream_rec_lock;
210 gboolean server_side_trickmode;
211 GstClockTime trickmode_interval;
213 gboolean need_segment;
214 gboolean clip_out_segment;
215 GstSegment out_segment;
216 GstClockTime base_time;
222 gboolean ignore_timeout;
225 /* mutex for protecting state changes */
226 GRecMutex state_rec_lock;
232 gboolean need_activate;
235 GstRTSPLowerTrans protocols;
241 gboolean drop_on_latency;
242 guint64 connection_speed;
243 GstRTSPNatMethod nat_method;
245 gboolean do_rtsp_keep_alive;
248 gchar *proxy_user; /* from url or property */
249 gchar *proxy_passwd; /* from url or property */
250 gchar *prop_proxy_id; /* set via property */
251 gchar *prop_proxy_pw; /* set via property */
256 GstRTSPRange client_port_range;
257 gint udp_buffer_size;
258 gboolean short_header;
260 gboolean udp_reconnect;
263 gboolean use_pipeline_clock;
265 GTlsCertificateFlags tls_validation_flags;
266 GTlsDatabase *tls_database;
267 GTlsInteraction *tls_interaction;
268 gboolean do_retransmission;
269 gint ntp_time_source;
271 gint max_rtcp_rtp_time_diff;
272 gboolean rfc7273_sync;
273 guint64 max_ts_offset_adjustment;
274 gint64 max_ts_offset;
275 gboolean max_ts_offset_is_set;
277 GstClockTime teardown_timeout;
279 gboolean onvif_rate_control;
281 gboolean ignore_x_server_reply;
286 GstRTSPLowerTrans cur_protocols;
287 gboolean tried_url_auth;
289 gboolean need_redirect;
290 GstRTSPTimeRange *range;
293 GstClock *provided_clock;
295 /* supported methods */
299 * -1.0 : Stream is not seekable
300 * 0.0 : seekable only to the beginning
301 * G_MAXFLOAT : Any value is possible
303 * Any other positive value indicates the longest duration
304 * between any two random access points
308 GstClockTime last_pos;
310 /* session management */
312 gulong manager_sig_id;
313 gulong manager_ptmap_id;
314 gboolean use_buffering;
316 GstRTSPConnInfo conninfo;
318 /* SET/GET PARAMETER requests queue */
319 GQueue set_get_param_q;
321 /* a list of RTSP extensions as GstElement */
322 GstRTSPExtensionList *extensions;
324 GstRTSPVersion default_version;
325 GstRTSPVersion version;
327 GstEvent *initial_seek;
333 struct _GstRTSPSrcClass {
334 GstBinClass parent_class;
337 gboolean (*get_parameter) (GstRTSPSrc *rtsp, const gchar *parameter, const gchar *content_type, GstPromise *promise);
338 gboolean (*get_parameters) (GstRTSPSrc *rtsp, gchar **parameters, const gchar *content_type, GstPromise *promise);
339 gboolean (*set_parameter) (GstRTSPSrc *rtsp, const gchar *name, const gchar *value, const gchar *content_type, GstPromise *promise);
340 GstFlowReturn (*push_backchannel_buffer) (GstRTSPSrc *src, guint id, GstSample *sample);
343 GType gst_rtspsrc_get_type(void);
347 #endif /* __GST_RTSPSRC_H__ */