More docs and small cleanups
[platform/upstream/gst-rtsp-server.git] / gst / rtsp-server / rtsp-media.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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <gst/gst.h>
21 #include <gst/rtsp/gstrtspurl.h>
22
23 #ifndef __GST_RTSP_MEDIA_H__
24 #define __GST_RTSP_MEDIA_H__
25
26 G_BEGIN_DECLS
27
28 /* types for the media */
29 #define GST_TYPE_RTSP_MEDIA              (gst_rtsp_media_get_type ())
30 #define GST_IS_RTSP_MEDIA(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA))
31 #define GST_IS_RTSP_MEDIA_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA))
32 #define GST_RTSP_MEDIA_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
33 #define GST_RTSP_MEDIA(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMedia))
34 #define GST_RTSP_MEDIA_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
35 #define GST_RTSP_MEDIA_CAST(obj)         ((GstRTSPMedia*)(obj))
36 #define GST_RTSP_MEDIA_CLASS_CAST(klass) ((GstRTSPMediaClass*)(klass))
37
38 typedef struct _GstRTSPMediaStream GstRTSPMediaStream;
39 typedef struct _GstRTSPMedia GstRTSPMedia;
40 typedef struct _GstRTSPMediaClass GstRTSPMediaClass;
41
42 /**
43  * GstRTSPMediaStream:
44  *
45  * @media: the owner #GstRTSPMedia
46  * @srcpad: the srcpad of the stream
47  * @payloader: the payloader of the format
48  * @prepared: if the stream is prepared for streaming
49  * @server_port: the server udp ports
50  * @recv_rtp_sink: sinkpad for RTP buffers
51  * @recv_rtcp_sink: sinkpad for RTCP buffers
52  * @recv_rtp_src: srcpad for RTP buffers
53  * @recv_rtcp_src: srcpad for RTCP buffers
54  * @udpsrc: the udp source elements for RTP/RTCP
55  * @udpsink: the udp sink elements for RTP/RTCP
56  * @caps_sig: the signal id for detecting caps
57  * @caps: the caps of the stream
58  *
59  * The definition of a media stream. The streams are identified by @id.
60  */
61 struct _GstRTSPMediaStream {
62   GstRTSPMedia *media;
63
64   GstPad       *srcpad;
65   GstElement   *payloader;
66   gboolean      prepared;
67
68   GstRTSPRange  server_port;
69
70   /* pads on the rtpbin */
71   GstPad       *recv_rtcp_sink;
72   GstPad       *send_rtp_sink;
73   GstPad       *send_rtp_src;
74   GstPad       *send_rtcp_src;
75
76   /* sinks used for sending and receiving RTP and RTCP, they share
77    * sockets */
78   GstElement   *udpsrc[2];
79   GstElement   *udpsink[2];
80
81   /* the caps of the stream */
82   gulong        caps_sig;
83   GstCaps      *caps;
84 };
85
86 /**
87  * GstRTSPMedia:
88  * @shared: if this media can be shared between clients
89  * @element: the data providing element
90  * @stream: the different streams provided by @element
91  * @prepared: if the media is prepared for streaming
92  * @pipeline: the toplevel pipeline
93  * @rtpbin: the rtpbin
94  * @multifdsink: multifdsink element for TCP transport
95  *
96  * A class that contains the GStreamer element along with a list of
97  * #GstRTSPediaStream objects that can produce data.
98  *
99  * This object is usually created from a #GstRTSPMediaFactory.
100  */
101 struct _GstRTSPMedia {
102   GObject       parent;
103
104   gboolean      shared;
105
106   GstElement   *element;
107   GArray       *streams;
108   gboolean      prepared;
109
110   /* the pipeline for the media */
111   GstElement   *pipeline;
112
113   /* RTP session manager */
114   GstElement   *rtpbin;
115
116   /* for TCP transport */
117   GstElement   *multifdsink;
118 };
119
120 struct _GstRTSPMediaClass {
121   GObjectClass  parent_class;
122 };
123
124 GType                 gst_rtsp_media_get_type         (void);
125
126 /* creating the media */
127 GstRTSPMedia *        gst_rtsp_media_new              (void);
128
129 void                  gst_rtsp_media_set_shared       (GstRTSPMedia *media, gboolean shared);
130 gboolean              gst_rtsp_media_is_shared        (GstRTSPMedia *media);
131
132 /* prepare the media for playback */
133 gboolean              gst_rtsp_media_prepare          (GstRTSPMedia *media);
134
135 /* dealing with the media */
136 guint                 gst_rtsp_media_n_streams        (GstRTSPMedia *media);
137 GstRTSPMediaStream *  gst_rtsp_media_get_stream       (GstRTSPMedia *media, guint idx);
138
139 /* add destinations to a stream */
140 gboolean              gst_rtsp_media_stream_add       (GstRTSPMediaStream *stream, GstRTSPTransport *ct);
141 gboolean              gst_rtsp_media_stream_remove    (GstRTSPMediaStream *stream, GstRTSPTransport *ct);
142
143 GstStateChangeReturn  gst_rtsp_media_play             (GstRTSPMedia *media);
144 GstStateChangeReturn  gst_rtsp_media_pause            (GstRTSPMedia *media);
145 GstStateChangeReturn  gst_rtsp_media_stop             (GstRTSPMedia *media);
146
147 G_END_DECLS
148
149 #endif /* __GST_RTSP_MEDIA_H__ */