gstrtspsrc.h 8.32 KB
Newer Older
Wim Taymans's avatar
Wim Taymans committed
1 2
/* GStreamer
 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3
 *               <2006> Wim Taymans <wim@fluendo.com>
Wim Taymans's avatar
Wim Taymans committed
4 5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
Tim-Philipp Müller's avatar
Tim-Philipp Müller committed
17 18
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
Wim Taymans's avatar
Wim Taymans committed
19
 */
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/*
 * Unless otherwise indicated, Source Code is licensed under MIT license.
 * See further explanation attached in License Statement (distributed in the file
 * LICENSE).
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
Wim Taymans's avatar
Wim Taymans committed
43 44 45 46 47 48

#ifndef __GST_RTSPSRC_H__
#define __GST_RTSPSRC_H__

#include <gst/gst.h>

49
G_BEGIN_DECLS
Wim Taymans's avatar
Wim Taymans committed
50

51
#include <gst/rtsp/rtsp.h>
52
#include <gio/gio.h>
53 54

#include "gstrtspext.h"
Wim Taymans's avatar
Wim Taymans committed
55 56 57 58 59 60

#define GST_TYPE_RTSPSRC \
  (gst_rtspsrc_get_type())
#define GST_RTSPSRC(obj) \
  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTSPSRC,GstRTSPSrc))
#define GST_RTSPSRC_CLASS(klass) \
61
  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTSPSRC,GstRTSPSrcClass))
Wim Taymans's avatar
Wim Taymans committed
62 63
#define GST_IS_RTSPSRC(obj) \
  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTSPSRC))
64
#define GST_IS_RTSPSRC_CLASS(klass) \
Wim Taymans's avatar
Wim Taymans committed
65
  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTSPSRC))
66 67
#define GST_RTSPSRC_CAST(obj) \
  ((GstRTSPSrc *)(obj))
Wim Taymans's avatar
Wim Taymans committed
68 69 70 71

typedef struct _GstRTSPSrc GstRTSPSrc;
typedef struct _GstRTSPSrcClass GstRTSPSrcClass;

Wim Taymans's avatar
Wim Taymans committed
72 73 74
#define GST_RTSP_STATE_GET_LOCK(rtsp)    (&GST_RTSPSRC_CAST(rtsp)->state_rec_lock)
#define GST_RTSP_STATE_LOCK(rtsp)        (g_rec_mutex_lock (GST_RTSP_STATE_GET_LOCK(rtsp)))
#define GST_RTSP_STATE_UNLOCK(rtsp)      (g_rec_mutex_unlock (GST_RTSP_STATE_GET_LOCK(rtsp)))
75

Wim Taymans's avatar
Wim Taymans committed
76 77 78
#define GST_RTSP_STREAM_GET_LOCK(rtsp)   (&GST_RTSPSRC_CAST(rtsp)->stream_rec_lock)
#define GST_RTSP_STREAM_LOCK(rtsp)       (g_rec_mutex_lock (GST_RTSP_STREAM_GET_LOCK(rtsp)))
#define GST_RTSP_STREAM_UNLOCK(rtsp)     (g_rec_mutex_unlock (GST_RTSP_STREAM_GET_LOCK(rtsp)))
79

80 81 82 83 84 85 86 87
typedef struct _GstRTSPConnInfo GstRTSPConnInfo;

struct _GstRTSPConnInfo {
  gchar              *location;
  GstRTSPUrl         *url;
  gchar              *url_str;
  GstRTSPConnection  *connection;
  gboolean            connected;
Wim Taymans's avatar
Wim Taymans committed
88
  gboolean            flushing;
89 90
};

Wim Taymans's avatar
Wim Taymans committed
91 92 93
typedef struct _GstRTSPStream GstRTSPStream;

struct _GstRTSPStream {
94
  gint          id;
95

96
  GstRTSPSrc   *parent; /* parent, no extra ref to parent is taken */
97

98 99
  /* pad we expose or NULL when it does not have an actual pad */
  GstPad       *srcpad;
100
  GstFlowReturn last_ret;
101
  gboolean      added;
102 103
  gboolean      setup;
  gboolean      skipped;
104
  gboolean      eos;
105
  gboolean      discont;
106 107

  /* for interleaved mode */
108
  guint8        channel[2];
109
  GstPad       *channelpad[2];
Wim Taymans's avatar
Wim Taymans committed
110

111 112
  /* our udp sources */
  GstElement   *udpsrc[2];
113
  GstPad       *blockedpad;
Wim Taymans's avatar
Wim Taymans committed
114
  gulong        blockid;
115
  gboolean      is_ipv6;
Wim Taymans's avatar
Wim Taymans committed
116

117 118
  /* our udp sinks back to the server */
  GstElement   *udpsink[2];
119
  GstPad       *rtcppad;
Wim Taymans's avatar
Wim Taymans committed
120

121 122 123
  /* fakesrc for sending dummy data */
  GstElement   *fakesrc;

124
  /* state */
125
  guint         port;
126
  gboolean      container;
127 128 129 130
  gboolean      is_real;
  guint8        default_pt;
  GstRTSPProfile profile;
  GArray       *ptmap;
131 132
  /* original control url */
  gchar        *control_url;
Wim Taymans's avatar
Wim Taymans committed
133
  guint32       ssrc;
134
  guint32       seqbase;
135
  guint64       timebase;
Wim Taymans's avatar
Wim Taymans committed
136
  GstElement   *srtpdec;
137
  GstCaps      *srtcpparams;
138
  GstElement   *srtpenc;
139
  guint32       send_ssrc;
140

141 142 143
  /* per stream connection */
  GstRTSPConnInfo  conninfo;

144 145 146
  /* session */
  GObject      *session;

147 148 149 150
  /* bandwidth */
  guint         as_bandwidth;
  guint         rs_bandwidth;
  guint         rr_bandwidth;
151 152 153

  /* destination */
  gchar        *destination;
154
  gboolean      is_multicast;
155
  guint         ttl;
156

157
  GstStructure     *rtx_pt_map;
Wim Taymans's avatar
Wim Taymans committed
158 159
};

160 161 162 163 164 165 166 167 168 169 170 171 172
/**
 * GstRTSPNatMethod:
 * @GST_RTSP_NAT_NONE: none
 * @GST_RTSP_NAT_DUMMY: send dummy packets
 *
 * Different methods for trying to traverse firewalls.
 */
typedef enum
{
  GST_RTSP_NAT_NONE,
  GST_RTSP_NAT_DUMMY
} GstRTSPNatMethod;

Wim Taymans's avatar
Wim Taymans committed
173
struct _GstRTSPSrc {
174
  GstBin           parent;
Wim Taymans's avatar
Wim Taymans committed
175

176 177 178
  /* task and mutex for interleaved mode */
  gboolean         interleaved;
  GstTask         *task;
Wim Taymans's avatar
Wim Taymans committed
179
  GRecMutex        stream_rec_lock;
180 181
  GstSegment       segment;
  gboolean         running;
182
  gboolean         need_range;
183
  gboolean         skip;
184
  gint             free_channel;
185
  gboolean         need_segment;
186
  GstClockTime     base_time;
Wim Taymans's avatar
Wim Taymans committed
187

188
  /* UDP mode loop */
189 190
  gint             pending_cmd;
  gint             busy_cmd;
191
  gboolean         ignore_timeout;
192
  gboolean         open_error;
193 194

  /* mutex for protecting state changes */
Wim Taymans's avatar
Wim Taymans committed
195
  GRecMutex        state_rec_lock;
196

197
  GstSDPMessage   *sdp;
198
  gboolean         from_sdp;
199
  GList           *streams;
200
  GstStructure    *props;
201
  gboolean         need_activate;
Wim Taymans's avatar
Wim Taymans committed
202

203
  /* properties */
204 205
  GstRTSPLowerTrans protocols;
  gboolean          debug;
Wim Taymans's avatar
Wim Taymans committed
206
  guint             retry;
207 208
  guint64           udp_timeout;
  GTimeVal          tcp_timeout;
209
  GTimeVal         *ptcp_timeout;
210
  guint             latency;
211
  gboolean          drop_on_latency;
212
  guint64           connection_speed;
213
  GstRTSPNatMethod  nat_method;
214
  gboolean          do_rtcp;
215
  gboolean          do_rtsp_keep_alive;
Wim Taymans's avatar
Wim Taymans committed
216 217
  gchar            *proxy_host;
  guint             proxy_port;
218 219 220 221
  gchar            *proxy_user;        /* from url or property */
  gchar            *proxy_passwd;      /* from url or property */
  gchar            *prop_proxy_id;     /* set via property */
  gchar            *prop_proxy_pw;     /* set via property */
222
  guint             rtp_blocksize;
223 224
  gchar            *user_id;
  gchar            *user_pw;
225
  gint              buffer_mode;
226
  GstRTSPRange      client_port_range;
227
  gint              udp_buffer_size;
228
  gboolean          short_header;
229
  guint             probation;
230
  gboolean          udp_reconnect;
231
  gchar            *multi_iface;
232
  gboolean          ntp_sync;
233
  gboolean          use_pipeline_clock;
234
  GstStructure     *sdes;
235
  GTlsCertificateFlags tls_validation_flags;
236
  GTlsDatabase     *tls_database;
237
  GTlsInteraction  *tls_interaction;
238
  gboolean          do_retransmission;
239
  gint              ntp_time_source;
240
  gchar            *user_agent;
241
  GstClockTime      max_rtcp_rtp_time_diff;
Wim Taymans's avatar
Wim Taymans committed
242

243
  /* state */
244 245 246 247 248
  GstRTSPState       state;
  gchar             *content_base;
  GstRTSPLowerTrans  cur_protocols;
  gboolean           tried_url_auth;
  gchar             *addr;
249
  gboolean           need_redirect;
Wim Taymans's avatar
Wim Taymans committed
250
  GstRTSPTimeRange  *range;
251
  gchar             *control;
252
  guint              next_port_num;
253
  GstClock          *provided_clock;
254

255
  /* supported methods */
256
  gint               methods;
257

258
  gboolean           seekable;
259
  GstClockTime       last_pos;
Wim Taymans's avatar
Wim Taymans committed
260

261
  /* session management */
262 263 264
  GstElement      *manager;
  gulong           manager_sig_id;
  gulong           manager_ptmap_id;
265
  gboolean         use_buffering;
266

267
  GstRTSPConnInfo  conninfo;
268

269 270
  /* a list of RTSP extensions as GstElement */
  GstRTSPExtensionList  *extensions;
Wim Taymans's avatar
Wim Taymans committed
271 272 273
};

struct _GstRTSPSrcClass {
274
  GstBinClass parent_class;
Wim Taymans's avatar
Wim Taymans committed
275 276 277 278
};

GType gst_rtspsrc_get_type(void);

279
G_END_DECLS
Wim Taymans's avatar
Wim Taymans committed
280 281

#endif /* __GST_RTSPSRC_H__ */