media: convert_range replaces get_range_times
[platform/upstream/gstreamer.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., 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 #include <gst/net/gstnet.h>
24
25 #ifndef __GST_RTSP_MEDIA_H__
26 #define __GST_RTSP_MEDIA_H__
27
28 G_BEGIN_DECLS
29
30 /* types for the media */
31 #define GST_TYPE_RTSP_MEDIA              (gst_rtsp_media_get_type ())
32 #define GST_IS_RTSP_MEDIA(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_RTSP_MEDIA))
33 #define GST_IS_RTSP_MEDIA_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_RTSP_MEDIA))
34 #define GST_RTSP_MEDIA_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
35 #define GST_RTSP_MEDIA(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_RTSP_MEDIA, GstRTSPMedia))
36 #define GST_RTSP_MEDIA_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_RTSP_MEDIA, GstRTSPMediaClass))
37 #define GST_RTSP_MEDIA_CAST(obj)         ((GstRTSPMedia*)(obj))
38 #define GST_RTSP_MEDIA_CLASS_CAST(klass) ((GstRTSPMediaClass*)(klass))
39
40 typedef struct _GstRTSPMedia GstRTSPMedia;
41 typedef struct _GstRTSPMediaClass GstRTSPMediaClass;
42 typedef struct _GstRTSPMediaPrivate GstRTSPMediaPrivate;
43
44 #include "rtsp-stream.h"
45 #include "rtsp-auth.h"
46 #include "rtsp-address-pool.h"
47
48 /**
49  * GstRTSPMediaStatus:
50  * @GST_RTSP_MEDIA_STATUS_UNPREPARED: media pipeline not prerolled
51  * @GST_RTSP_MEDIA_STATUS_UNPREPARING: media pipeline is busy doing a clean
52  *                                     shutdown.
53  * @GST_RTSP_MEDIA_STATUS_PREPARING: media pipeline is prerolling
54  * @GST_RTSP_MEDIA_STATUS_PREPARED: media pipeline is prerolled
55  * @GST_RTSP_MEDIA_STATUS_ERROR: media pipeline is in error
56  *
57  * The state of the media pipeline.
58  */
59 typedef enum {
60   GST_RTSP_MEDIA_STATUS_UNPREPARED  = 0,
61   GST_RTSP_MEDIA_STATUS_UNPREPARING = 1,
62   GST_RTSP_MEDIA_STATUS_PREPARING   = 2,
63   GST_RTSP_MEDIA_STATUS_PREPARED    = 3,
64   GST_RTSP_MEDIA_STATUS_ERROR       = 4
65 } GstRTSPMediaStatus;
66
67 /**
68  * GstRTSPMedia:
69  *
70  * A class that contains the GStreamer element along with a list of
71  * #GstRTSPStream objects that can produce data.
72  *
73  * This object is usually created from a #GstRTSPMediaFactory.
74  */
75 struct _GstRTSPMedia {
76   GObject            parent;
77
78   GstRTSPMediaPrivate *priv;
79 };
80
81 /**
82  * GstRTSPMediaClass:
83  * @context: the main context for dispatching messages
84  * @loop: the mainloop for message.
85  * @thread: the thread dispatching messages.
86  * @handle_message: handle a message
87  * @unprepare: the default implementation sets the pipeline's state
88  *             to GST_STATE_NULL and removes all elements.
89  *
90  * The RTSP media class
91  */
92 struct _GstRTSPMediaClass {
93   GObjectClass  parent_class;
94
95   /* thread for the mainloop */
96   GMainContext *context;
97   GMainLoop    *loop;
98   GThread      *thread;
99
100   /* vmethods */
101   gboolean        (*handle_message)  (GstRTSPMedia *media, GstMessage *message);
102   gboolean        (*unprepare)       (GstRTSPMedia *media);
103   gboolean        (*convert_range)   (GstRTSPMedia *media, GstRTSPTimeRange *range,
104                                       GstRTSPRangeUnit unit);
105
106   /* signals */
107   void            (*new_stream)      (GstRTSPMedia *media, GstRTSPStream * stream);
108   void            (*removed_stream)  (GstRTSPMedia *media, GstRTSPStream * stream);
109
110   void            (*prepared)        (GstRTSPMedia *media);
111   void            (*unprepared)      (GstRTSPMedia *media);
112
113   void            (*new_state)       (GstRTSPMedia *media, GstState state);
114 };
115
116 GType                 gst_rtsp_media_get_type         (void);
117
118 /* creating the media */
119 GstRTSPMedia *        gst_rtsp_media_new              (GstElement *element);
120
121 void                  gst_rtsp_media_take_pipeline    (GstRTSPMedia *media, GstPipeline *pipeline);
122
123 GstRTSPMediaStatus    gst_rtsp_media_get_status       (GstRTSPMedia *media);
124
125 void                  gst_rtsp_media_set_shared       (GstRTSPMedia *media, gboolean shared);
126 gboolean              gst_rtsp_media_is_shared        (GstRTSPMedia *media);
127
128 void                  gst_rtsp_media_set_reusable     (GstRTSPMedia *media, gboolean reusable);
129 gboolean              gst_rtsp_media_is_reusable      (GstRTSPMedia *media);
130
131 void                  gst_rtsp_media_set_protocols    (GstRTSPMedia *media, GstRTSPLowerTrans protocols);
132 GstRTSPLowerTrans     gst_rtsp_media_get_protocols    (GstRTSPMedia *media);
133
134 void                  gst_rtsp_media_set_eos_shutdown (GstRTSPMedia *media, gboolean eos_shutdown);
135 gboolean              gst_rtsp_media_is_eos_shutdown  (GstRTSPMedia *media);
136
137 void                  gst_rtsp_media_set_auth         (GstRTSPMedia *media, GstRTSPAuth *auth);
138 GstRTSPAuth *         gst_rtsp_media_get_auth         (GstRTSPMedia *media);
139
140 void                  gst_rtsp_media_set_address_pool (GstRTSPMedia *media, GstRTSPAddressPool *pool);
141 GstRTSPAddressPool *  gst_rtsp_media_get_address_pool (GstRTSPMedia *media);
142
143 void                  gst_rtsp_media_set_buffer_size  (GstRTSPMedia *media, guint size);
144 guint                 gst_rtsp_media_get_buffer_size  (GstRTSPMedia *media);
145
146 void                  gst_rtsp_media_use_time_provider (GstRTSPMedia *media, gboolean time_provider);
147 gboolean              gst_rtsp_media_is_time_provider  (GstRTSPMedia *media);
148 GstNetTimeProvider *  gst_rtsp_media_get_time_provider (GstRTSPMedia *media,
149                                                         const gchar *address, guint16 port);
150
151 /* prepare the media for playback */
152 gboolean              gst_rtsp_media_prepare          (GstRTSPMedia *media);
153 gboolean              gst_rtsp_media_unprepare        (GstRTSPMedia *media);
154
155 /* creating streams */
156 void                  gst_rtsp_media_collect_streams  (GstRTSPMedia *media);
157 GstRTSPStream *       gst_rtsp_media_create_stream    (GstRTSPMedia *media,
158                                                        GstElement *payloader,
159                                                        GstPad *srcpad);
160
161 /* dealing with the media */
162 GstClock *            gst_rtsp_media_get_clock        (GstRTSPMedia *media);
163 GstClockTime          gst_rtsp_media_get_base_time    (GstRTSPMedia *media);
164
165 guint                 gst_rtsp_media_n_streams        (GstRTSPMedia *media);
166 GstRTSPStream *       gst_rtsp_media_get_stream       (GstRTSPMedia *media, guint idx);
167
168 gboolean              gst_rtsp_media_seek             (GstRTSPMedia *media, GstRTSPTimeRange *range);
169 gchar *               gst_rtsp_media_get_range_string (GstRTSPMedia *media,
170                                                        gboolean play,
171                                                        GstRTSPRangeUnit unit);
172
173 gboolean              gst_rtsp_media_set_state        (GstRTSPMedia *media, GstState state,
174                                                        GPtrArray *transports);
175
176 G_END_DECLS
177
178 #endif /* __GST_RTSP_MEDIA_H__ */