API: gst_discoverer_info_get_live
[platform/upstream/gst-plugins-base.git] / gst-libs / gst / pbutils / gstdiscoverer.h
1 /* GStreamer
2  * Copyright (C) 2009 Edward Hervey <edward.hervey@collabora.co.uk>
3  *               2009 Nokia Corporation
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20
21 #ifndef _GST_DISCOVERER_H_
22 #define _GST_DISCOVERER_H_
23
24 #include <gst/gst.h>
25
26 G_BEGIN_DECLS
27
28 #define GST_TYPE_DISCOVERER_STREAM_INFO \
29   (gst_discoverer_stream_info_get_type ())
30 #define GST_DISCOVERER_STREAM_INFO(obj) \
31   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_STREAM_INFO, GstDiscovererStreamInfo))
32 #define GST_IS_DISCOVERER_STREAM_INFO(obj) \
33   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_STREAM_INFO))
34 typedef struct _GstDiscovererStreamInfo GstDiscovererStreamInfo;
35 typedef GObjectClass GstDiscovererStreamInfoClass;
36
37 GST_EXPORT
38 GType gst_discoverer_stream_info_get_type (void);
39
40 /**
41  * GstDiscovererStreamInfo:
42  *
43  * Base structure for information concerning a media stream. Depending on the
44  * stream type, one can find more media-specific information in
45  * #GstDiscovererAudioInfo, #GstDiscovererVideoInfo, and
46  * #GstDiscovererContainerInfo.
47  *
48  * The #GstDiscovererStreamInfo represents the topology of the stream. Siblings
49  * can be iterated over with gst_discoverer_stream_info_get_next() and
50  * gst_discoverer_stream_info_get_previous(). Children (sub-streams) of a
51  * stream can be accessed using the #GstDiscovererContainerInfo API.
52  *
53  * As a simple example, if you run #GstDiscoverer on an AVI file with one audio
54  * and one video stream, you will get a #GstDiscovererContainerInfo
55  * corresponding to the AVI container, which in turn will have a
56  * #GstDiscovererAudioInfo sub-stream and a #GstDiscovererVideoInfo sub-stream
57  * for the audio and video streams respectively.
58  */
59 #define gst_discoverer_stream_info_ref(info) ((GstDiscovererStreamInfo*) g_object_ref((GObject*) info))
60 #define gst_discoverer_stream_info_unref(info) (g_object_unref((GObject*) info))
61
62 GST_EXPORT
63 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_previous(GstDiscovererStreamInfo* info);
64
65 GST_EXPORT
66 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_next(GstDiscovererStreamInfo* info);
67
68 GST_EXPORT
69 GstCaps*                 gst_discoverer_stream_info_get_caps(GstDiscovererStreamInfo* info);
70
71 GST_EXPORT
72 const GstTagList*        gst_discoverer_stream_info_get_tags(GstDiscovererStreamInfo* info);
73
74 GST_EXPORT
75 const GstToc*            gst_discoverer_stream_info_get_toc(GstDiscovererStreamInfo* info);
76
77 GST_EXPORT
78 const gchar*             gst_discoverer_stream_info_get_stream_id(GstDiscovererStreamInfo* info);
79
80 GST_EXPORT
81 const GstStructure*      gst_discoverer_stream_info_get_misc(GstDiscovererStreamInfo* info);
82
83 GST_EXPORT
84 const gchar *            gst_discoverer_stream_info_get_stream_type_nick(GstDiscovererStreamInfo* info);
85
86 /**
87  * GstDiscovererContainerInfo:
88  *
89  * #GstDiscovererStreamInfo specific to container streams.
90  */
91 #define GST_TYPE_DISCOVERER_CONTAINER_INFO \
92   (gst_discoverer_container_info_get_type ())
93 #define GST_DISCOVERER_CONTAINER_INFO(obj) \
94   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO, GstDiscovererContainerInfo))
95 #define GST_IS_DISCOVERER_CONTAINER_INFO(obj) \
96   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_CONTAINER_INFO))
97 typedef struct _GstDiscovererContainerInfo GstDiscovererContainerInfo;
98 typedef GObjectClass GstDiscovererContainerInfoClass;
99
100 GST_EXPORT
101 GType gst_discoverer_container_info_get_type (void);
102
103 GST_EXPORT
104 GList *gst_discoverer_container_info_get_streams(GstDiscovererContainerInfo *info);
105
106
107 /**
108  * GstDiscovererAudioInfo:
109  *
110  * #GstDiscovererStreamInfo specific to audio streams.
111  */
112 #define GST_TYPE_DISCOVERER_AUDIO_INFO \
113   (gst_discoverer_audio_info_get_type ())
114 #define GST_DISCOVERER_AUDIO_INFO(obj) \
115   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_AUDIO_INFO, GstDiscovererAudioInfo))
116 #define GST_IS_DISCOVERER_AUDIO_INFO(obj) \
117   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_AUDIO_INFO))
118 typedef struct _GstDiscovererAudioInfo GstDiscovererAudioInfo;
119 typedef GObjectClass GstDiscovererAudioInfoClass;
120
121 GST_EXPORT
122 GType gst_discoverer_audio_info_get_type (void);
123
124 GST_EXPORT
125 guint gst_discoverer_audio_info_get_channels(const GstDiscovererAudioInfo* info);
126
127 GST_EXPORT
128 guint64 gst_discoverer_audio_info_get_channel_mask(const GstDiscovererAudioInfo* info);
129
130 GST_EXPORT
131 guint gst_discoverer_audio_info_get_sample_rate(const GstDiscovererAudioInfo* info);
132
133 GST_EXPORT
134 guint gst_discoverer_audio_info_get_depth(const GstDiscovererAudioInfo* info);
135
136 GST_EXPORT
137 guint gst_discoverer_audio_info_get_bitrate(const GstDiscovererAudioInfo* info);
138
139 GST_EXPORT
140 guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* info);
141
142 GST_EXPORT
143 const gchar * gst_discoverer_audio_info_get_language(const GstDiscovererAudioInfo* info);
144
145 /**
146  * GstDiscovererVideoInfo:
147  *
148  * #GstDiscovererStreamInfo specific to video streams (this includes images).
149  */
150 #define GST_TYPE_DISCOVERER_VIDEO_INFO \
151   (gst_discoverer_video_info_get_type ())
152 #define GST_DISCOVERER_VIDEO_INFO(obj) \
153   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_VIDEO_INFO, GstDiscovererVideoInfo))
154 #define GST_IS_DISCOVERER_VIDEO_INFO(obj) \
155   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_VIDEO_INFO))
156 typedef struct _GstDiscovererVideoInfo GstDiscovererVideoInfo;
157 typedef GObjectClass GstDiscovererVideoInfoClass;
158
159 GST_EXPORT
160 GType gst_discoverer_video_info_get_type (void);
161
162 GST_EXPORT
163 guint           gst_discoverer_video_info_get_width(const GstDiscovererVideoInfo* info);
164
165 GST_EXPORT
166 guint           gst_discoverer_video_info_get_height(const GstDiscovererVideoInfo* info);
167
168 GST_EXPORT
169 guint           gst_discoverer_video_info_get_depth(const GstDiscovererVideoInfo* info);
170
171 GST_EXPORT
172 guint           gst_discoverer_video_info_get_framerate_num(const GstDiscovererVideoInfo* info);
173
174 GST_EXPORT
175 guint           gst_discoverer_video_info_get_framerate_denom(const GstDiscovererVideoInfo* info);
176
177 GST_EXPORT
178 guint           gst_discoverer_video_info_get_par_num(const GstDiscovererVideoInfo* info);
179
180 GST_EXPORT
181 guint           gst_discoverer_video_info_get_par_denom(const GstDiscovererVideoInfo* info);
182
183 GST_EXPORT
184 gboolean        gst_discoverer_video_info_is_interlaced(const GstDiscovererVideoInfo* info);
185
186 GST_EXPORT
187 guint           gst_discoverer_video_info_get_bitrate(const GstDiscovererVideoInfo* info);
188
189 GST_EXPORT
190 guint           gst_discoverer_video_info_get_max_bitrate(const GstDiscovererVideoInfo* info);
191
192 GST_EXPORT
193 gboolean        gst_discoverer_video_info_is_image(const GstDiscovererVideoInfo* info);
194
195 /**
196  * GstDiscovererSubtitleInfo:
197  *
198  * #GstDiscovererStreamInfo specific to subtitle streams (this includes text and
199  * image based ones).
200  */
201 #define GST_TYPE_DISCOVERER_SUBTITLE_INFO \
202   (gst_discoverer_subtitle_info_get_type ())
203 #define GST_DISCOVERER_SUBTITLE_INFO(obj) \
204   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_SUBTITLE_INFO, GstDiscovererSubtitleInfo))
205 #define GST_IS_DISCOVERER_SUBTITLE_INFO(obj) \
206   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_SUBTITLE_INFO))
207 typedef struct _GstDiscovererSubtitleInfo GstDiscovererSubtitleInfo;
208 typedef GObjectClass GstDiscovererSubtitleInfoClass;
209
210 GST_EXPORT
211 GType gst_discoverer_subtitle_info_get_type (void);
212
213 GST_EXPORT
214 const gchar *   gst_discoverer_subtitle_info_get_language(const GstDiscovererSubtitleInfo* info);
215
216 /**
217  * GstDiscovererResult:
218  * @GST_DISCOVERER_OK: The discovery was successful
219  * @GST_DISCOVERER_URI_INVALID: the URI is invalid
220  * @GST_DISCOVERER_ERROR: an error happened and the GError is set
221  * @GST_DISCOVERER_TIMEOUT: the discovery timed-out
222  * @GST_DISCOVERER_BUSY: the discoverer was already discovering a file
223  * @GST_DISCOVERER_MISSING_PLUGINS: Some plugins are missing for full discovery
224  *
225  * Result values for the discovery process.
226  */
227 typedef enum {
228   GST_DISCOVERER_OK               = 0,
229   GST_DISCOVERER_URI_INVALID      = 1,
230   GST_DISCOVERER_ERROR            = 2,
231   GST_DISCOVERER_TIMEOUT          = 3,
232   GST_DISCOVERER_BUSY             = 4,
233   GST_DISCOVERER_MISSING_PLUGINS  = 5
234 } GstDiscovererResult;
235
236 /**
237  * GstDiscovererSerializeFlags:
238  * @GST_DISCOVERER_SERIALIZE_BASIC: Serialize only basic information, excluding
239  * caps, tags and miscellaneous information
240  * @GST_DISCOVERER_SERIALIZE_CAPS: Serialize the caps for each stream
241  * @GST_DISCOVERER_SERIALIZE_TAGS: Serialize the tags for each stream
242  * @GST_DISCOVERER_SERIALIZE_MISC: Serialize miscellaneous information for each stream
243  * @GST_DISCOVERER_SERIALIZE_ALL: Serialize all the available info, including
244  * caps, tags and miscellaneous information
245  *
246  * You can use these flags to control what is serialized by
247  * gst_discoverer_info_to_variant()
248  *
249  * Since: 1.6
250  */
251
252 typedef enum {
253   GST_DISCOVERER_SERIALIZE_BASIC = 0,
254   GST_DISCOVERER_SERIALIZE_CAPS  = 1 << 0,
255   GST_DISCOVERER_SERIALIZE_TAGS  = 1 << 1,
256   GST_DISCOVERER_SERIALIZE_MISC  = 1 << 2,
257   GST_DISCOVERER_SERIALIZE_ALL   = GST_DISCOVERER_SERIALIZE_CAPS | GST_DISCOVERER_SERIALIZE_TAGS | GST_DISCOVERER_SERIALIZE_MISC
258 } GstDiscovererSerializeFlags;
259
260 /**
261  * GstDiscovererInfo:
262  *
263  * Structure containing the information of a URI analyzed by #GstDiscoverer.
264  */
265 typedef struct _GstDiscovererInfo GstDiscovererInfo;
266
267 #define GST_TYPE_DISCOVERER_INFO \
268   (gst_discoverer_info_get_type ())
269 #define GST_DISCOVERER_INFO(obj) \
270   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER_INFO, GstDiscovererInfo))
271 #define GST_IS_DISCOVERER_INFO(obj) \
272   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER_INFO))
273 typedef GObjectClass GstDiscovererInfoClass;
274
275 GST_EXPORT
276 GType gst_discoverer_info_get_type (void);
277
278 #define gst_discoverer_info_unref(info) (g_object_unref((GObject*)info))
279 #define gst_discoverer_info_ref(info) (g_object_ref((GObject*)info))
280
281 GST_EXPORT
282 GstDiscovererInfo*        gst_discoverer_info_copy (GstDiscovererInfo * ptr);
283
284 GST_EXPORT
285 const gchar*              gst_discoverer_info_get_uri(const GstDiscovererInfo* info);
286
287 GST_EXPORT
288 GstDiscovererResult       gst_discoverer_info_get_result(const GstDiscovererInfo* info);
289
290 GST_EXPORT
291 GstDiscovererStreamInfo*  gst_discoverer_info_get_stream_info(GstDiscovererInfo* info);
292
293 GST_EXPORT
294 GList*                    gst_discoverer_info_get_stream_list(GstDiscovererInfo* info);
295
296 GST_EXPORT
297 GstClockTime              gst_discoverer_info_get_duration(const GstDiscovererInfo* info);
298
299 GST_EXPORT
300 gboolean                  gst_discoverer_info_get_seekable(const GstDiscovererInfo* info);
301
302 GST_EXPORT
303 gboolean                  gst_discoverer_info_get_live(const GstDiscovererInfo* info);
304
305 GST_EXPORT
306 const GstStructure*       gst_discoverer_info_get_misc(const GstDiscovererInfo* info);
307
308 GST_EXPORT
309 const GstTagList*         gst_discoverer_info_get_tags(const GstDiscovererInfo* info); 
310 GST_EXPORT
311 const GstToc*             gst_discoverer_info_get_toc(const GstDiscovererInfo* info);
312
313 GST_EXPORT
314 const gchar**             gst_discoverer_info_get_missing_elements_installer_details(const GstDiscovererInfo* info);
315
316 GST_EXPORT
317 GList *                   gst_discoverer_info_get_streams (GstDiscovererInfo *info,
318                                                            GType streamtype);
319
320 GST_EXPORT
321 GList *                   gst_discoverer_info_get_audio_streams (GstDiscovererInfo *info);
322
323 GST_EXPORT
324 GList *                   gst_discoverer_info_get_video_streams (GstDiscovererInfo *info);
325
326 GST_EXPORT
327 GList *                   gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo *info);
328
329 GST_EXPORT
330 GList *                   gst_discoverer_info_get_container_streams (GstDiscovererInfo *info);
331
332 GST_EXPORT
333 GVariant *                gst_discoverer_info_to_variant (GstDiscovererInfo *info,
334                                                           GstDiscovererSerializeFlags flags);
335
336 GST_EXPORT
337 GstDiscovererInfo *       gst_discoverer_info_from_variant (GVariant *variant);
338
339 GST_EXPORT
340 void                      gst_discoverer_stream_info_list_free (GList *infos);
341
342 #define GST_TYPE_DISCOVERER \
343   (gst_discoverer_get_type())
344 #define GST_DISCOVERER(obj) \
345   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DISCOVERER,GstDiscoverer))
346 #define GST_DISCOVERER_CLASS(klass) \
347   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DISCOVERER,GstDiscovererClass))
348 #define GST_IS_DISCOVERER(obj) \
349   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DISCOVERER))
350 #define GST_IS_DISCOVERER_CLASS(klass) \
351   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DISCOVERER))
352
353 typedef struct _GstDiscoverer GstDiscoverer;
354 typedef struct _GstDiscovererClass GstDiscovererClass;
355 typedef struct _GstDiscovererPrivate GstDiscovererPrivate;
356
357 /**
358  * GstDiscoverer:
359  *
360  * The #GstDiscoverer structure.
361  **/
362 struct _GstDiscoverer {
363   GObject parent;
364
365   /*< private >*/
366   GstDiscovererPrivate *priv;
367
368   gpointer _reserved[GST_PADDING];
369 };
370
371 struct _GstDiscovererClass {
372   GObjectClass parentclass;
373
374   /* signals */
375   void        (*finished)        (GstDiscoverer *discoverer);
376   void        (*starting)        (GstDiscoverer *discoverer);
377   void        (*discovered)      (GstDiscoverer *discoverer,
378                                   GstDiscovererInfo *info,
379                                   const GError *err);
380   void        (*source_setup)    (GstDiscoverer *discoverer,
381                                   GstElement *source);
382
383   gpointer _reserved[GST_PADDING];
384 };
385
386 GST_EXPORT
387 GType          gst_discoverer_get_type (void);
388
389 GST_EXPORT
390 GstDiscoverer *gst_discoverer_new (GstClockTime timeout, GError **err);
391
392 /* Asynchronous API */
393
394 GST_EXPORT
395 void           gst_discoverer_start (GstDiscoverer *discoverer);
396
397 GST_EXPORT
398 void           gst_discoverer_stop (GstDiscoverer *discoverer);
399
400 GST_EXPORT
401 gboolean       gst_discoverer_discover_uri_async (GstDiscoverer *discoverer,
402                                                   const gchar *uri);
403
404 /* Synchronous API */
405
406 GST_EXPORT
407 GstDiscovererInfo *
408 gst_discoverer_discover_uri (GstDiscoverer * discoverer,
409                              const gchar * uri,
410                              GError ** err);
411
412 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
413 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscoverer, gst_object_unref)
414 #endif
415
416 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
417 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererAudioInfo, gst_object_unref)
418 #endif
419
420 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
421 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererContainerInfo, gst_object_unref)
422 #endif
423
424 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
425 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererInfo, gst_object_unref)
426 #endif
427
428 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
429 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererStreamInfo, gst_object_unref)
430 #endif
431
432 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
433 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererSubtitleInfo, gst_object_unref)
434 #endif
435
436 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
437 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererVideoInfo, gst_object_unref)
438 #endif
439
440 G_END_DECLS
441
442 #endif /* _GST_DISCOVERER_H */