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