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 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
82 GST_RTSPSRC_ERROR_NONE = 0,
83 GST_RTSPSRC_ERROR_UNSUPPORTED_AUDIO,
84 GST_RTSPSRC_ERROR_UNSUPPORTED_VIDEO,
85 GST_RTSPSRC_ERROR_CONNECTION_FAIL,
86 GST_RTSPSRC_ERROR_DNS_FAIL,
87 GST_RTSPSRC_ERROR_SERVER_DISCONNECTED,
88 GST_RTSPSRC_ERROR_BAD_SERVER,
89 GST_RTSPSRC_ERROR_INVALID_PROTOCOL,
90 GST_RTSPSRC_ERROR_INVALID_URL,
91 GST_RTSPSRC_ERROR_UNEXPECTED_MSG,
92 GST_RTSPSRC_ERROR_OUT_OF_MEMORIES,
93 GST_RTSPSRC_ERROR_RTSP_TIMEOUT,
94 GST_RTSPSRC_ERROR_BAD_REQUEST,
95 GST_RTSPSRC_ERROR_NOT_AUTHORIZED,
96 GST_RTSPSRC_ERROR_PAYMENT_REQUIRED,
97 GST_RTSPSRC_ERROR_FORBIDDEN,
98 GST_RTSPSRC_ERROR_CONTENT_NOT_FOUND,
99 GST_RTSPSRC_ERROR_METHOD_NOT_ALLOWED,
100 GST_RTSPSRC_ERROR_NOT_ACCEPTABLE,
101 GST_RTSPSRC_ERROR_PROXY_AUTHENTICATION_REQUIRED,
102 GST_RTSPSRC_ERROR_SERVER_TIMEOUT,
103 GST_RTSPSRC_ERROR_GONE,
104 GST_RTSPSRC_ERROR_LENGTH_REQUIRED,
105 GST_RTSPSRC_ERROR_PRECONDITION_FAILED,
106 GST_RTSPSRC_ERROR_REQUEST_ENTITY_TOO_LARGE,
107 GST_RTSPSRC_ERROR_REQUEST_URI_TOO_LARGE,
108 GST_RTSPSRC_ERROR_UNSUPPORTED_MEDIA_TYPE,
109 GST_RTSPSRC_ERROR_PARAMETER_NOT_UNDERSTOOD,
110 GST_RTSPSRC_ERROR_CONFERENCE_NOT_FOUND,
111 GST_RTSPSRC_ERROR_NOT_ENOUGH_BANDWIDTH,
112 GST_RTSPSRC_ERROR_NO_SESSION_ID,
113 GST_RTSPSRC_ERROR_METHOD_NOT_VALID_IN_THIS_STATE,
114 GST_RTSPSRC_ERROR_HEADER_FIELD_NOT_VALID_FOR_SOURCE,
115 GST_RTSPSRC_ERROR_INVALID_RANGE,
116 GST_RTSPSRC_ERROR_PARAMETER_IS_READONLY,
117 GST_RTSPSRC_ERROR_AGGREGATE_OP_NOT_ALLOWED,
118 GST_RTSPSRC_ERROR_ONLY_AGGREGATE_OP_ALLOWED,
119 GST_RTSPSRC_ERROR_BAD_TRANSPORT,
120 GST_RTSPSRC_ERROR_DESTINATION_UNREACHABLE,
121 GST_RTSPSRC_ERROR_INTERNAL_SERVER_ERROR,
122 GST_RTSPSRC_ERROR_NOT_IMPLEMENTED,
123 GST_RTSPSRC_ERROR_BAD_GATEWAY,
124 GST_RTSPSRC_ERROR_SERVICE_UNAVAILABLE,
125 GST_RTSPSRC_ERROR_GATEWAY_TIME_OUT ,
126 GST_RTSPSRC_ERROR_RTSP_VERSION_NOT_SUPPORTED,
127 GST_RTSPSRC_ERROR_OPTION_NOT_SUPPORTED,
129 typedef _GstRTSPSrcError GstRTSPSrcError;
132 typedef struct _GstRTSPConnInfo GstRTSPConnInfo;
134 struct _GstRTSPConnInfo {
138 GstRTSPConnection *connection;
146 typedef struct _GstRTSPStream GstRTSPStream;
148 struct _GstRTSPStream {
151 GstRTSPSrc *parent; /* parent, no extra ref to parent is taken */
153 /* pad we expose or NULL when it does not have an actual pad */
155 GstFlowReturn last_ret;
162 gboolean waiting_setup_response;
164 /* for interleaved mode */
166 GstPad *channelpad[2];
168 /* our udp sources */
169 GstElement *udpsrc[2];
174 /* our udp sinks back to the server */
175 GstElement *udpsink[2];
178 /* fakesrc for sending dummy data or appsrc for sending backchannel data */
186 GstRTSPProfile profile;
188 /* original control url */
194 GstCaps *srtcpparams;
198 /* per stream connection */
199 GstRTSPConnInfo conninfo;
204 /* srtp key management */
205 GstMIKEYMessage *mikey;
214 gboolean is_multicast;
216 gboolean is_backchannel;
218 /* A unique and stable id we will use for the stream start event */
221 GstStructure *rtx_pt_map;
223 guint32 segment_seqnum[2];
227 * GstRTSPSrcTimeoutCause:
228 * @GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP: timeout triggered by RTCP
230 * Different causes to why the rtspsrc generated the GstRTSPSrcTimeout
235 GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP
236 } GstRTSPSrcTimeoutCause;
240 * @GST_RTSP_NAT_NONE: none
241 * @GST_RTSP_NAT_DUMMY: send dummy packets
243 * Different methods for trying to traverse firewalls.
255 /* task and mutex for interleaved mode */
256 gboolean interleaved;
258 GRecMutex stream_rec_lock;
264 gboolean need_segment;
265 GstClockTime base_time;
271 gboolean ignore_timeout;
274 /* mutex for protecting state changes */
275 GRecMutex state_rec_lock;
281 gboolean need_activate;
284 GstRTSPLowerTrans protocols;
288 GTimeVal tcp_timeout;
289 GTimeVal *ptcp_timeout;
291 gboolean drop_on_latency;
292 guint64 connection_speed;
293 GstRTSPNatMethod nat_method;
295 gboolean do_rtsp_keep_alive;
298 gchar *proxy_user; /* from url or property */
299 gchar *proxy_passwd; /* from url or property */
300 gchar *prop_proxy_id; /* set via property */
301 gchar *prop_proxy_pw; /* set via property */
306 GstRTSPRange client_port_range;
307 gint udp_buffer_size;
308 gboolean short_header;
310 gboolean udp_reconnect;
313 gboolean use_pipeline_clock;
315 GTlsCertificateFlags tls_validation_flags;
316 GTlsDatabase *tls_database;
317 GTlsInteraction *tls_interaction;
318 gboolean do_retransmission;
319 gint ntp_time_source;
321 GstClockTime max_rtcp_rtp_time_diff;
322 gboolean rfc7273_sync;
323 guint64 max_ts_offset_adjustment;
324 gint64 max_ts_offset;
325 gboolean max_ts_offset_is_set;
327 GstClockTime teardown_timeout;
332 GstRTSPLowerTrans cur_protocols;
333 gboolean tried_url_auth;
335 gboolean need_redirect;
336 GstRTSPTimeRange *range;
339 GstClock *provided_clock;
341 /* supported methods */
345 * -1.0 : Stream is not seekable
346 * 0.0 : seekable only to the beginning
347 * G_MAXFLOAT : Any value is possible
349 * Any other positive value indicates the longest duration
350 * between any two random access points
353 GstClockTime last_pos;
355 /* session management */
357 gulong manager_sig_id;
358 gulong manager_ptmap_id;
359 gboolean use_buffering;
361 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
363 gboolean is_audio_codec_supported;
364 gboolean is_video_codec_supported;
367 gchar *video_frame_size;
370 GstRTSPConnInfo conninfo;
372 /* SET/GET PARAMETER requests queue */
373 GQueue set_get_param_q;
375 /* a list of RTSP extensions as GstElement */
376 GstRTSPExtensionList *extensions;
378 GstRTSPVersion default_version;
379 GstRTSPVersion version;
381 #ifdef TIZEN_FEATURE_RTSP_MODIFICATION
384 guint64 start_position;
388 struct _GstRTSPSrcClass {
389 GstBinClass parent_class;
392 gboolean (*get_parameter) (GstRTSPSrc *rtsp, const gchar *parameter, const gchar *content_type, GstPromise *promise);
393 gboolean (*get_parameters) (GstRTSPSrc *rtsp, gchar **parameters, const gchar *content_type, GstPromise *promise);
394 gboolean (*set_parameter) (GstRTSPSrc *rtsp, const gchar *name, const gchar *value, const gchar *content_type, GstPromise *promise);
395 GstFlowReturn (*push_backchannel_buffer) (GstRTSPSrc *src, guint id, GstSample *sample);
398 GType gst_rtspsrc_get_type(void);
402 #endif /* __GST_RTSPSRC_H__ */