Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / rtsp / gstrtspsrc.h
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *               <2006> Wim Taymans <wim@fluendo.com>
4  *
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.
9  *
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.
14  *
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., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 /*
21  * Unless otherwise indicated, Source Code is licensed under MIT license.
22  * See further explanation attached in License Statement (distributed in the file
23  * LICENSE).
24  *
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:
31  *
32  * The above copyright notice and this permission notice shall be included in all
33  * copies or substantial portions of the Software.
34  *
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
41  * SOFTWARE.
42  */
43
44 #ifndef __GST_RTSPSRC_H__
45 #define __GST_RTSPSRC_H__
46
47 #include <gst/gst.h>
48
49 G_BEGIN_DECLS
50
51 #include <gst/rtsp/gstrtspconnection.h>
52 #include <gst/rtsp/gstrtspmessage.h>
53 #include <gst/rtsp/gstrtspurl.h>
54 #include <gst/rtsp/gstrtsprange.h>
55
56 #include "gstrtspext.h"
57
58 #define GST_TYPE_RTSPSRC \
59   (gst_rtspsrc_get_type())
60 #define GST_RTSPSRC(obj) \
61   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTSPSRC,GstRTSPSrc))
62 #define GST_RTSPSRC_CLASS(klass) \
63   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTSPSRC,GstRTSPSrcClass))
64 #define GST_IS_RTSPSRC(obj) \
65   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTSPSRC))
66 #define GST_IS_RTSPSRC_CLASS(klass) \
67   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTSPSRC))
68 #define GST_RTSPSRC_CAST(obj) \
69   ((GstRTSPSrc *)(obj))
70
71 typedef struct _GstRTSPSrc GstRTSPSrc;
72 typedef struct _GstRTSPSrcClass GstRTSPSrcClass;
73
74 #define GST_RTSP_STATE_GET_LOCK(rtsp)    (GST_RTSPSRC_CAST(rtsp)->state_rec_lock)
75 #define GST_RTSP_STATE_LOCK(rtsp)        (g_static_rec_mutex_lock (GST_RTSP_STATE_GET_LOCK(rtsp)))
76 #define GST_RTSP_STATE_UNLOCK(rtsp)      (g_static_rec_mutex_unlock (GST_RTSP_STATE_GET_LOCK(rtsp)))
77
78 #define GST_RTSP_STREAM_GET_LOCK(rtsp)   (GST_RTSPSRC_CAST(rtsp)->stream_rec_lock)
79 #define GST_RTSP_STREAM_LOCK(rtsp)       (g_static_rec_mutex_lock (GST_RTSP_STREAM_GET_LOCK(rtsp)))
80 #define GST_RTSP_STREAM_UNLOCK(rtsp)     (g_static_rec_mutex_unlock (GST_RTSP_STREAM_GET_LOCK(rtsp)))
81
82 typedef struct _GstRTSPConnInfo GstRTSPConnInfo;
83
84 struct _GstRTSPConnInfo {
85   gchar              *location;
86   GstRTSPUrl         *url;
87   gchar              *url_str;
88   GstRTSPConnection  *connection;
89   gboolean            connected;
90 };
91
92 typedef struct _GstRTSPStream GstRTSPStream;
93
94 struct _GstRTSPStream {
95   gint          id;
96
97   GstRTSPSrc   *parent; /* parent, no extra ref to parent is taken */
98
99   /* pad we expose or NULL when it does not have an actual pad */
100   GstPad       *srcpad;
101   GstFlowReturn last_ret;
102   gboolean      added;
103   gboolean      disabled;
104   gboolean      eos;
105   gboolean      discont;
106
107   /* for interleaved mode */
108   guint8        channel[2];
109   GstCaps      *caps;
110   GstPad       *channelpad[2];
111
112   /* our udp sources */
113   GstElement   *udpsrc[2];
114   GstPad       *blockedpad;
115   gboolean      is_ipv6;
116
117   /* our udp sinks back to the server */
118   GstElement   *udpsink[2];
119   GstPad       *rtcppad;
120
121   /* fakesrc for sending dummy data */
122   GstElement   *fakesrc;
123
124   /* state */
125   gint          pt;
126   guint         port;
127   gboolean      container;
128   /* original control url */
129   gchar        *control_url;
130   guint32       ssrc;
131   guint32       seqbase;
132   guint64       timebase;
133
134   /* per stream connection */
135   GstRTSPConnInfo  conninfo;
136
137   /* session */
138   GObject      *session;
139
140   /* bandwidth */
141   guint         as_bandwidth;
142   guint         rs_bandwidth;
143   guint         rr_bandwidth;
144
145   /* destination */
146   gchar        *destination;
147   gboolean      is_multicast;
148   guint         ttl;
149 };
150
151 /**
152  * GstRTSPNatMethod:
153  * @GST_RTSP_NAT_NONE: none
154  * @GST_RTSP_NAT_DUMMY: send dummy packets
155  *
156  * Different methods for trying to traverse firewalls.
157  */
158 typedef enum
159 {
160   GST_RTSP_NAT_NONE,
161   GST_RTSP_NAT_DUMMY
162 } GstRTSPNatMethod;
163
164 struct _GstRTSPSrc {
165   GstBin           parent;
166
167   /* task and mutex for interleaved mode */
168   gboolean         interleaved;
169   GstTask         *task;
170   GStaticRecMutex *stream_rec_lock;
171   GstSegment       segment;
172   gboolean         running;
173   gboolean         need_range;
174   gboolean         skip;
175   gint             free_channel;
176   GstEvent        *close_segment;
177   GstEvent        *start_segment;
178   GstClockTime     base_time;
179
180   /* UDP mode loop */
181   gint             loop_cmd;
182   gboolean         ignore_timeout;
183   gboolean         waiting;
184   gboolean         open_error;
185
186   /* mutex for protecting state changes */
187   GStaticRecMutex *state_rec_lock;
188
189   GstSDPMessage   *sdp;
190   gboolean         from_sdp;
191   gint             numstreams;
192   GList           *streams;
193   GstStructure    *props;
194   gboolean         need_activate;
195
196   /* properties */
197   GstRTSPLowerTrans protocols;
198   gboolean          debug;
199   guint             retry;
200   guint64           udp_timeout;
201   GTimeVal          tcp_timeout;
202   GTimeVal         *ptcp_timeout;
203   guint             latency;
204   guint             connection_speed;
205   GstRTSPNatMethod  nat_method;
206   gboolean          do_rtcp;
207   gchar            *proxy_host;
208   guint             proxy_port;
209   gchar            *proxy_user;
210   gchar            *proxy_passwd;
211   guint             rtp_blocksize;
212   gchar            *user_id;
213   gchar            *user_pw;
214   gint              buffer_mode;
215   GstRTSPRange      client_port_range;
216   gint              udp_buffer_size;
217   gboolean          short_header;
218
219   /* state */
220   GstRTSPState       state;
221   gchar             *content_base;
222   GstRTSPLowerTrans  cur_protocols;
223   gboolean           tried_url_auth;
224   gchar             *addr;
225   gboolean           need_redirect;
226   GstRTSPTimeRange  *range;
227   gchar             *control;
228   guint              next_port_num;
229
230 #ifdef GST_EXT_RTSPSRC_MODIFICATION
231   gboolean          wait_pause_response;
232 #endif
233  
234
235   /* supported methods */
236   gint               methods;
237
238   gboolean           seekable;
239   GstClockTime       last_pos;
240
241   /* session management */
242   GstElement      *manager;
243   gulong           manager_sig_id;
244   gulong           manager_ptmap_id;
245
246   GstRTSPConnInfo  conninfo;
247
248   /* a list of RTSP extensions as GstElement */
249   GstRTSPExtensionList  *extensions;
250 };
251
252 struct _GstRTSPSrcClass {
253   GstBinClass parent_class;
254 };
255
256 GType gst_rtspsrc_get_type(void);
257
258 G_END_DECLS
259
260 #endif /* __GST_RTSPSRC_H__ */