stream: add locking
[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
44 /**
45  * GstRTSPStream:
46  * @parent: the parent instance
47  * @lock: mutex protecting the stream
48  * @idx: the stream index
49  * @srcpad: the srcpad of the stream
50  * @payloader: the payloader of the format
51  * @is_ipv6: should this stream be IPv6
52  * @buffer_size: the UDP buffer size
53  * @is_joined: if the stream is joined in a bin
54  * @send_rtp_sink: sinkpad for sending RTP buffers
55  * @recv_sink: sinkpad for receiving RTP/RTCP buffers
56  * @send_src: srcpad for sending RTP/RTCP buffers
57  * @session: the RTP session object
58  * @udpsrc: the udp source elements for RTP/RTCP
59  * @udpsink: the udp sink elements for RTP/RTCP
60  * @appsrc: the app source elements for RTP/RTCP
61  * @appqueue: the app queue elements for RTP/RTCP
62  * @appsink: the app sink elements for RTP/RTCP
63  * @tee: tee for the sending to udpsink and appsink
64  * @funnel: tee for the receiving from udpsrc and appsrc
65  * @server_port: the server ports for this stream
66  * @caps_sig: the signal id for detecting caps
67  * @caps: the caps of the stream
68  * @n_active: the number of active transports in @transports
69  * @transports: list of #GstStreamTransport being streamed to
70  *
71  * The definition of a media stream. The streams are identified by @idx.
72  */
73 struct _GstRTSPStream {
74   GObject       parent;
75
76   GMutex        lock;
77   guint         idx;
78   GstPad       *srcpad;
79   GstElement   *payloader;
80   gboolean      is_ipv6;
81   guint         buffer_size;
82   gboolean      is_joined;
83
84   /* pads on the rtpbin */
85   GstPad       *send_rtp_sink;
86   GstPad       *recv_sink[2];
87   GstPad       *send_src[2];
88
89   /* the RTPSession object */
90   GObject      *session;
91
92   /* sinks used for sending and receiving RTP and RTCP, they share
93    * sockets */
94   GstElement   *udpsrc[2];
95   GstElement   *udpsink[2];
96   /* for TCP transport */
97   GstElement   *appsrc[2];
98   GstElement   *appqueue[2];
99   GstElement   *appsink[2];
100
101   GstElement   *tee[2];
102   GstElement   *funnel[2];
103
104   /* server ports for sending/receiving */
105   GstRTSPRange  server_port;
106
107   /* the caps of the stream */
108   gulong        caps_sig;
109   GstCaps      *caps;
110
111   /* transports we stream to */
112   guint         n_active;
113   GList        *transports;
114 };
115
116 struct _GstRTSPStreamClass {
117   GObjectClass parent_class;
118 };
119
120 GType             gst_rtsp_stream_get_type         (void);
121
122 GstRTSPStream *   gst_rtsp_stream_new              (guint idx, GstElement *payloader,
123                                                     GstPad *srcpad);
124
125 void              gst_rtsp_stream_set_mtu          (GstRTSPStream * stream, guint mtu);
126 guint             gst_rtsp_stream_get_mtu          (GstRTSPStream * stream);
127
128 gboolean          gst_rtsp_stream_join_bin         (GstRTSPStream * stream,
129                                                     GstBin *bin, GstElement *rtpbin,
130                                                     GstState state);
131 gboolean          gst_rtsp_stream_leave_bin        (GstRTSPStream * stream,
132                                                     GstBin *bin, GstElement *rtpbin);
133
134 gboolean          gst_rtsp_stream_get_rtpinfo      (GstRTSPStream * stream,
135                                                     guint *rtptime, guint * seq);
136
137 GstFlowReturn     gst_rtsp_stream_recv_rtp         (GstRTSPStream *stream,
138                                                     GstBuffer *buffer);
139 GstFlowReturn     gst_rtsp_stream_recv_rtcp        (GstRTSPStream *stream,
140                                                     GstBuffer *buffer);
141
142 gboolean          gst_rtsp_stream_add_transport    (GstRTSPStream *stream,
143                                                     GstRTSPStreamTransport *trans);
144 gboolean          gst_rtsp_stream_remove_transport (GstRTSPStream *stream,
145                                                     GstRTSPStreamTransport *trans);
146
147 G_END_DECLS
148
149 #endif /* __GST_RTSP_STREAM_H__ */