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

source code of include/gstreamer-1.0/gst/pbutils/gstdiscoverer.h