upload tizen1.0 source
[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 #define GST_RTSP_CONN_GET_LOCK(rtsp)     (GST_RTSPSRC_CAST(rtsp)->conn_rec_lock)
83 #define GST_RTSP_CONN_LOCK(rtsp)         (g_static_rec_mutex_lock (GST_RTSP_CONN_GET_LOCK(rtsp)))
84 #define GST_RTSP_CONN_UNLOCK(rtsp)       (g_static_rec_mutex_unlock (GST_RTSP_CONN_GET_LOCK(rtsp)))
85
86 typedef struct _GstRTSPConnInfo GstRTSPConnInfo;
87
88 struct _GstRTSPConnInfo {
89   gchar              *location;
90   GstRTSPUrl         *url;
91   gchar              *url_str;
92   GstRTSPConnection  *connection;
93   gboolean            connected;
94 };
95
96 typedef struct _GstRTSPStream GstRTSPStream;
97
98 struct _GstRTSPStream {
99   gint          id;
100
101   GstRTSPSrc   *parent; /* parent, no extra ref to parent is taken */
102
103   /* pad we expose or NULL when it does not have an actual pad */
104   GstPad       *srcpad;
105   GstFlowReturn last_ret;
106   gboolean      added;
107   gboolean      disabled;
108   gboolean      eos;
109   gboolean      discont;
110
111   /* for interleaved mode */
112   guint8        channel[2];
113   GstCaps      *caps;
114   GstPad       *channelpad[2];
115
116   /* our udp sources */
117   GstElement   *udpsrc[2];
118   GstPad       *blockedpad;
119   gboolean      is_ipv6;
120
121   /* our udp sinks back to the server */
122   GstElement   *udpsink[2];
123   GstPad       *rtcppad;
124
125   /* fakesrc for sending dummy data */
126   GstElement   *fakesrc;
127
128   /* state */
129   gint          pt;
130   guint         port;
131   gboolean      container;
132   /* original control url */
133   gchar        *control_url;
134   guint32       ssrc; 
135   guint32       seqbase;
136   guint64       timebase;
137
138   /* per stream connection */
139   GstRTSPConnInfo  conninfo;
140
141   /* session */
142   GObject      *session;
143
144   /* bandwidth */
145   guint         as_bandwidth;
146   guint         rs_bandwidth;
147   guint         rr_bandwidth;
148
149   /* destination */
150   gchar        *destination;
151   gboolean      is_multicast;
152   guint         ttl;
153 };
154
155 /**
156  * GstRTSPNatMethod:
157  * @GST_RTSP_NAT_NONE: none
158  * @GST_RTSP_NAT_DUMMY: send dummy packets
159  *
160  * Different methods for trying to traverse firewalls.
161  */
162 typedef enum
163 {
164   GST_RTSP_NAT_NONE,
165   GST_RTSP_NAT_DUMMY
166 } GstRTSPNatMethod;
167
168 struct _GstRTSPSrc {
169   GstBin           parent;
170
171   /* task and mutex for interleaved mode */
172   gboolean         interleaved;
173   GstTask         *task;
174   GStaticRecMutex *stream_rec_lock;
175   GstSegment       segment;
176   gboolean         running;
177   gboolean         need_range;
178   gboolean         skip;
179   gint             free_channel;
180   GstEvent        *close_segment;
181   GstEvent        *start_segment;
182   GstClockTime     base_time;
183
184   /* UDP mode loop */
185   gint             loop_cmd;
186   gboolean         ignore_timeout;
187
188   /* mutex for protecting state changes */
189   GStaticRecMutex *state_rec_lock;
190
191   /* mutex for protecting the connection */
192   GStaticRecMutex *conn_rec_lock;
193
194   GstSDPMessage   *sdp;
195   gboolean         from_sdp;
196   gint             numstreams;
197   GList           *streams;
198   GstStructure    *props;
199   gboolean         need_activate;
200
201   /* properties */
202   GstRTSPLowerTrans protocols;
203   gboolean          debug;
204   guint             retry;
205   guint64           udp_timeout;
206   GTimeVal          tcp_timeout;
207   GTimeVal         *ptcp_timeout;
208   guint             latency;
209   guint             connection_speed;
210   GstRTSPNatMethod  nat_method;
211   gboolean          do_rtcp;
212   gchar            *proxy_host;
213   guint             proxy_port;
214   gchar            *proxy_user;
215   gchar            *proxy_passwd;
216   guint             rtp_blocksize;
217   gchar            *user_id;
218   gchar            *user_pw;
219   gint              buffer_mode;
220   GstRTSPRange      client_port_range;
221   gint              udp_buffer_size;
222
223   /* state */
224   GstRTSPState       state;
225   gchar             *content_base;
226   GstRTSPLowerTrans  cur_protocols;
227   gboolean           tried_url_auth;
228   gchar             *addr;
229   gboolean           need_redirect;
230   GstRTSPTimeRange  *range;
231   gchar             *control;
232   guint              next_port_num;
233
234   /* supported methods */
235   gint               methods;
236
237   gboolean           seekable;
238   GstClockTime       last_pos;
239
240   /* session management */
241   GstElement      *manager;
242   gulong           manager_sig_id;
243   gulong           manager_ptmap_id;
244
245   GstRTSPConnInfo  conninfo;
246
247   /* a list of RTSP extensions as GstElement */
248   GstRTSPExtensionList  *extensions;
249 };
250
251 struct _GstRTSPSrcClass {
252   GstBinClass parent_class;
253 };
254
255 GType gst_rtspsrc_get_type(void);
256
257 G_END_DECLS
258
259 #endif /* __GST_RTSPSRC_H__ */