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