factory-uri: add some debug
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-stream.h
1 /* GStreamer
2  * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #include <gst/gst.h>
21 #include <gst/rtsp/gstrtsprange.h>
22 #include <gst/rtsp/gstrtspurl.h>
23
24 #ifndef __GST_RTSP_STREAM_H__
25 #define __GST_RTSP_STREAM_H__
26
27 G_BEGIN_DECLS
28
29 /* types for the media stream */
30 #define GST_TYPE_RTSP_STREAM              (gst_rtsp_stream_get_type ())
31 #define GST_IS_RTSP_STREAM(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_STREAM))
32 #define GST_IS_RTSP_STREAM_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_STREAM))
33 #define GST_RTSP_STREAM_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_STREAM, GstRTSPStreamClass))
34 #define GST_RTSP_STREAM(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_STREAM, GstRTSPStream))
35 #define GST_RTSP_STREAM_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_STREAM, GstRTSPStreamClass))
36 #define GST_RTSP_STREAM_CAST(obj)         ((GstRTSPStream*)(obj))
37 #define GST_RTSP_STREAM_CLASS_CAST(klass) ((GstRTSPStreamClass*)(klass))
38
39 typedef struct _GstRTSPStream GstRTSPStream;
40 typedef struct _GstRTSPStreamClass GstRTSPStreamClass;
41
42 #include "rtsp-stream-transport.h"
43 #include "rtsp-address-pool.h"
44
45 /**
46  * GstRTSPStream:
47  * @parent: the parent instance
48  * @lock: mutex protecting the stream
49  * @idx: the stream index
50  * @srcpad: the srcpad of the stream
51  * @payloader: the payloader of the format
52  * @is_ipv6: should this stream be IPv6
53  * @buffer_size: the UDP buffer size
54  * @is_joined: if the stream is joined in a bin
55  * @send_rtp_sink: sinkpad for sending RTP buffers
56  * @recv_sink: sinkpad for receiving RTP/RTCP buffers
57  * @send_src: srcpad for sending RTP/RTCP buffers
58  * @session: the RTP session object
59  * @udpsrc: the udp source elements for RTP/RTCP
60  * @udpsink: the udp sink elements for RTP/RTCP
61  * @appsrc: the app source elements for RTP/RTCP
62  * @appqueue: the app queue elements for RTP/RTCP
63  * @appsink: the app sink elements for RTP/RTCP
64  * @tee: tee for the sending to udpsink and appsink
65  * @funnel: tee for the receiving from udpsrc and appsrc
66  * @server_port: the server ports for this stream
67  * @pool: the address pool for this stream
68  * @addr: the address for this stream
69  * @caps_sig: the signal id for detecting caps
70  * @caps: the caps of the stream
71  * @n_active: the number of active transports in @transports
72  * @transports: list of #GstStreamTransport being streamed to
73  *
74  * The definition of a media stream. The streams are identified by @idx.
75  */
76 struct _GstRTSPStream {
77   GObject       parent;
78
79   GMutex        lock;
80   guint         idx;
81   GstPad       *srcpad;
82   GstElement   *payloader;
83   gboolean      is_ipv6;
84   guint         buffer_size;
85   gboolean      is_joined;
86
87   /* pads on the rtpbin */
88   GstPad       *send_rtp_sink;
89   GstPad       *recv_sink[2];
90   GstPad       *send_src[2];
91
92   /* the RTPSession object */
93   GObject      *session;
94
95   /* sinks used for sending and receiving RTP and RTCP, they share
96    * sockets */
97   GstElement   *udpsrc[2];
98   GstElement   *udpsink[2];
99   /* for TCP transport */
100   GstElement   *appsrc[2];
101   GstElement   *appqueue[2];
102   GstElement   *appsink[2];
103
104   GstElement   *tee[2];
105   GstElement   *funnel[2];
106
107   /* server ports for sending/receiving */
108   GstRTSPRange  server_port;
109
110   /* multicast addresses */
111   GstRTSPAddressPool *pool;
112   GstRTSPAddress     *addr;
113
114   /* the caps of the stream */
115   gulong        caps_sig;
116   GstCaps      *caps;
117
118   /* transports we stream to */
119   guint         n_active;
120   GList        *transports;
121 };
122
123 struct _GstRTSPStreamClass {
124   GObjectClass parent_class;
125 };
126
127 GType             gst_rtsp_stream_get_type         (void);
128
129 GstRTSPStream *   gst_rtsp_stream_new              (guint idx, GstElement *payloader,
130                                                     GstPad *srcpad);
131
132 void              gst_rtsp_stream_set_mtu          (GstRTSPStream * stream, guint mtu);
133 guint             gst_rtsp_stream_get_mtu          (GstRTSPStream * stream);
134
135 void              gst_rtsp_stream_set_address_pool (GstRTSPStream *stream, GstRTSPAddressPool *pool);
136 GstRTSPAddressPool *
137                   gst_rtsp_stream_get_address_pool (GstRTSPStream *stream);
138
139 GstRTSPAddress *  gst_rtsp_stream_get_address      (GstRTSPStream *stream);
140
141 gboolean          gst_rtsp_stream_join_bin         (GstRTSPStream * stream,
142                                                     GstBin *bin, GstElement *rtpbin,
143                                                     GstState state);
144 gboolean          gst_rtsp_stream_leave_bin        (GstRTSPStream * stream,
145                                                     GstBin *bin, GstElement *rtpbin);
146
147 gboolean          gst_rtsp_stream_get_rtpinfo      (GstRTSPStream * stream,
148                                                     guint *rtptime, guint * seq);
149
150 GstFlowReturn     gst_rtsp_stream_recv_rtp         (GstRTSPStream *stream,
151                                                     GstBuffer *buffer);
152 GstFlowReturn     gst_rtsp_stream_recv_rtcp        (GstRTSPStream *stream,
153                                                     GstBuffer *buffer);
154
155 gboolean          gst_rtsp_stream_add_transport    (GstRTSPStream *stream,
156                                                     GstRTSPStreamTransport *trans);
157 gboolean          gst_rtsp_stream_remove_transport (GstRTSPStream *stream,
158                                                     GstRTSPStreamTransport *trans);
159
160 G_END_DECLS
161
162 #endif /* __GST_RTSP_STREAM_H__ */