2 * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
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.
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.
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.
21 #include <gst/rtsp/rtsp.h>
22 #include <gst/net/gstnet.h>
24 #ifndef __GST_RTSP_MEDIA_H__
25 #define __GST_RTSP_MEDIA_H__
29 /* types for the media */
30 #define GST_TYPE_RTSP_MEDIA (gst_rtsp_media_get_type ())
31 #define GST_IS_RTSP_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA))
32 #define GST_IS_RTSP_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA))
33 #define GST_RTSP_MEDIA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
34 #define GST_RTSP_MEDIA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMedia))
35 #define GST_RTSP_MEDIA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
36 #define GST_RTSP_MEDIA_CAST(obj) ((GstRTSPMedia*)(obj))
37 #define GST_RTSP_MEDIA_CLASS_CAST(klass) ((GstRTSPMediaClass*)(klass))
39 typedef struct _GstRTSPMedia GstRTSPMedia;
40 typedef struct _GstRTSPMediaClass GstRTSPMediaClass;
41 typedef struct _GstRTSPMediaPrivate GstRTSPMediaPrivate;
45 * @GST_RTSP_MEDIA_STATUS_UNPREPARED: media pipeline not prerolled
46 * @GST_RTSP_MEDIA_STATUS_UNPREPARING: media pipeline is busy doing a clean
48 * @GST_RTSP_MEDIA_STATUS_PREPARING: media pipeline is prerolling
49 * @GST_RTSP_MEDIA_STATUS_PREPARED: media pipeline is prerolled
50 * @GST_RTSP_MEDIA_STATUS_SUSPENDED: media is suspended
51 * @GST_RTSP_MEDIA_STATUS_ERROR: media pipeline is in error
53 * The state of the media pipeline.
56 GST_RTSP_MEDIA_STATUS_UNPREPARED = 0,
57 GST_RTSP_MEDIA_STATUS_UNPREPARING = 1,
58 GST_RTSP_MEDIA_STATUS_PREPARING = 2,
59 GST_RTSP_MEDIA_STATUS_PREPARED = 3,
60 GST_RTSP_MEDIA_STATUS_SUSPENDED = 4,
61 GST_RTSP_MEDIA_STATUS_ERROR = 5
66 * @GST_RTSP_SUSPEND_MODE_NONE: Media is not suspended
67 * @GST_RTSP_SUSPEND_MODE_PAUSE: Media is PAUSED in suspend
68 * @GST_RTSP_SUSPEND_MODE_RESET: The media is set to NULL when suspended
70 * The suspend mode of the media pipeline. A media pipeline is suspended right
71 * after creating the SDP and when the client performs a PAUSED request.
74 GST_RTSP_SUSPEND_MODE_NONE = 0,
75 GST_RTSP_SUSPEND_MODE_PAUSE = 1,
76 GST_RTSP_SUSPEND_MODE_RESET = 2
80 * GstRTSPTransportMode:
81 * @GST_RTSP_TRANSPORT_MODE_PLAY: Transport supports PLAY mode
82 * @GST_RTSP_TRANSPORT_MODE_RECORD: Transport supports RECORD mode
84 * The supported modes of the media.
87 GST_RTSP_TRANSPORT_MODE_PLAY = 1,
88 GST_RTSP_TRANSPORT_MODE_RECORD = 2,
89 } GstRTSPTransportMode;
91 #define GST_TYPE_RTSP_TRANSPORT_MODE (gst_rtsp_transport_mode_get_type())
92 GType gst_rtsp_transport_mode_get_type (void);
94 #define GST_TYPE_RTSP_SUSPEND_MODE (gst_rtsp_suspend_mode_get_type())
95 GType gst_rtsp_suspend_mode_get_type (void);
97 #include "rtsp-stream.h"
98 #include "rtsp-thread-pool.h"
99 #include "rtsp-permissions.h"
100 #include "rtsp-address-pool.h"
101 #include "rtsp-sdp.h"
106 * A class that contains the GStreamer element along with a list of
107 * #GstRTSPStream objects that can produce data.
109 * This object is usually created from a #GstRTSPMediaFactory.
111 struct _GstRTSPMedia {
115 GstRTSPMediaPrivate *priv;
116 gpointer _gst_reserved[GST_PADDING];
121 * @handle_message: handle a message
122 * @prepare: the default implementation adds all elements and sets the
123 * pipeline's state to GST_STATE_PAUSED (or GST_STATE_PLAYING
124 * in case of NO_PREROLL elements).
125 * @unprepare: the default implementation sets the pipeline's state
126 * to GST_STATE_NULL and removes all elements.
127 * @suspend: the default implementation sets the pipeline's state to
128 * GST_STATE_NULL GST_STATE_PAUSED depending on the selected
130 * @unsuspend: the default implementation reverts the suspend operation.
131 * The pipeline will be prerolled again if it's state was
132 * set to GST_STATE_NULL in suspend.
133 * @convert_range: convert a range to the given unit
134 * @query_position: query the current position in the pipeline
135 * @query_stop: query when playback will stop
137 * The RTSP media class
139 struct _GstRTSPMediaClass {
140 GObjectClass parent_class;
143 gboolean (*handle_message) (GstRTSPMedia *media, GstMessage *message);
144 gboolean (*prepare) (GstRTSPMedia *media, GstRTSPThread *thread);
145 gboolean (*unprepare) (GstRTSPMedia *media);
146 gboolean (*suspend) (GstRTSPMedia *media);
147 gboolean (*unsuspend) (GstRTSPMedia *media);
148 gboolean (*convert_range) (GstRTSPMedia *media, GstRTSPTimeRange *range,
149 GstRTSPRangeUnit unit);
150 gboolean (*query_position) (GstRTSPMedia *media, gint64 *position);
151 gboolean (*query_stop) (GstRTSPMedia *media, gint64 *stop);
152 GstElement * (*create_rtpbin) (GstRTSPMedia *media);
153 gboolean (*setup_rtpbin) (GstRTSPMedia *media, GstElement *rtpbin);
154 gboolean (*setup_sdp) (GstRTSPMedia *media, GstSDPMessage *sdp, GstSDPInfo *info);
157 void (*new_stream) (GstRTSPMedia *media, GstRTSPStream * stream);
158 void (*removed_stream) (GstRTSPMedia *media, GstRTSPStream * stream);
160 void (*prepared) (GstRTSPMedia *media);
161 void (*unprepared) (GstRTSPMedia *media);
163 void (*target_state) (GstRTSPMedia *media, GstState state);
164 void (*new_state) (GstRTSPMedia *media, GstState state);
166 gboolean (*handle_sdp) (GstRTSPMedia *media, GstSDPMessage *sdp);
169 gpointer _gst_reserved[GST_PADDING_LARGE-1];
172 GType gst_rtsp_media_get_type (void);
174 /* creating the media */
175 GstRTSPMedia * gst_rtsp_media_new (GstElement *element);
176 GstElement * gst_rtsp_media_get_element (GstRTSPMedia *media);
178 void gst_rtsp_media_take_pipeline (GstRTSPMedia *media, GstPipeline *pipeline);
180 GstRTSPMediaStatus gst_rtsp_media_get_status (GstRTSPMedia *media);
182 void gst_rtsp_media_set_permissions (GstRTSPMedia *media,
183 GstRTSPPermissions *permissions);
184 GstRTSPPermissions * gst_rtsp_media_get_permissions (GstRTSPMedia *media);
186 void gst_rtsp_media_set_shared (GstRTSPMedia *media, gboolean shared);
187 gboolean gst_rtsp_media_is_shared (GstRTSPMedia *media);
189 void gst_rtsp_media_set_transport_mode (GstRTSPMedia *media, GstRTSPTransportMode mode);
190 GstRTSPTransportMode gst_rtsp_media_get_transport_mode (GstRTSPMedia *media);
192 void gst_rtsp_media_set_reusable (GstRTSPMedia *media, gboolean reusable);
193 gboolean gst_rtsp_media_is_reusable (GstRTSPMedia *media);
195 void gst_rtsp_media_set_profiles (GstRTSPMedia *media, GstRTSPProfile profiles);
196 GstRTSPProfile gst_rtsp_media_get_profiles (GstRTSPMedia *media);
198 void gst_rtsp_media_set_protocols (GstRTSPMedia *media, GstRTSPLowerTrans protocols);
199 GstRTSPLowerTrans gst_rtsp_media_get_protocols (GstRTSPMedia *media);
201 void gst_rtsp_media_set_eos_shutdown (GstRTSPMedia *media, gboolean eos_shutdown);
202 gboolean gst_rtsp_media_is_eos_shutdown (GstRTSPMedia *media);
204 void gst_rtsp_media_set_address_pool (GstRTSPMedia *media, GstRTSPAddressPool *pool);
205 GstRTSPAddressPool * gst_rtsp_media_get_address_pool (GstRTSPMedia *media);
207 void gst_rtsp_media_set_buffer_size (GstRTSPMedia *media, guint size);
208 guint gst_rtsp_media_get_buffer_size (GstRTSPMedia *media);
210 void gst_rtsp_media_set_retransmission_time (GstRTSPMedia *media, GstClockTime time);
211 GstClockTime gst_rtsp_media_get_retransmission_time (GstRTSPMedia *media);
213 void gst_rtsp_media_set_latency (GstRTSPMedia *media, guint latency);
214 guint gst_rtsp_media_get_latency (GstRTSPMedia *media);
216 void gst_rtsp_media_use_time_provider (GstRTSPMedia *media, gboolean time_provider);
217 gboolean gst_rtsp_media_is_time_provider (GstRTSPMedia *media);
218 GstNetTimeProvider * gst_rtsp_media_get_time_provider (GstRTSPMedia *media,
219 const gchar *address, guint16 port);
221 /* prepare the media for playback */
222 gboolean gst_rtsp_media_prepare (GstRTSPMedia *media, GstRTSPThread *thread);
223 gboolean gst_rtsp_media_unprepare (GstRTSPMedia *media);
225 void gst_rtsp_media_set_suspend_mode (GstRTSPMedia *media, GstRTSPSuspendMode mode);
226 GstRTSPSuspendMode gst_rtsp_media_get_suspend_mode (GstRTSPMedia *media);
228 gboolean gst_rtsp_media_suspend (GstRTSPMedia *media);
229 gboolean gst_rtsp_media_unsuspend (GstRTSPMedia *media);
231 gboolean gst_rtsp_media_setup_sdp (GstRTSPMedia * media, GstSDPMessage * sdp,
234 gboolean gst_rtsp_media_handle_sdp (GstRTSPMedia * media, GstSDPMessage * sdp);
237 /* creating streams */
238 void gst_rtsp_media_collect_streams (GstRTSPMedia *media);
239 GstRTSPStream * gst_rtsp_media_create_stream (GstRTSPMedia *media,
240 GstElement *payloader,
243 /* dealing with the media */
244 GstClock * gst_rtsp_media_get_clock (GstRTSPMedia *media);
245 GstClockTime gst_rtsp_media_get_base_time (GstRTSPMedia *media);
247 guint gst_rtsp_media_n_streams (GstRTSPMedia *media);
248 GstRTSPStream * gst_rtsp_media_get_stream (GstRTSPMedia *media, guint idx);
249 GstRTSPStream * gst_rtsp_media_find_stream (GstRTSPMedia *media, const gchar * control);
251 gboolean gst_rtsp_media_seek (GstRTSPMedia *media, GstRTSPTimeRange *range);
252 gchar * gst_rtsp_media_get_range_string (GstRTSPMedia *media,
254 GstRTSPRangeUnit unit);
256 gboolean gst_rtsp_media_set_state (GstRTSPMedia *media, GstState state,
257 GPtrArray *transports);
258 void gst_rtsp_media_set_pipeline_state (GstRTSPMedia * media,
263 #endif /* __GST_RTSP_MEDIA_H__ */