• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
27 G_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))
35 typedef struct _GstDiscovererStreamInfo GstDiscovererStreamInfo;
36 typedef GObjectClass GstDiscovererStreamInfoClass;
37 
38 GST_PBUTILS_API
39 GType 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 
63 GST_PBUTILS_API
64 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_previous(GstDiscovererStreamInfo* info);
65 
66 GST_PBUTILS_API
67 GstDiscovererStreamInfo* gst_discoverer_stream_info_get_next(GstDiscovererStreamInfo* info);
68 
69 GST_PBUTILS_API
70 GstCaps*                 gst_discoverer_stream_info_get_caps(GstDiscovererStreamInfo* info);
71 
72 GST_PBUTILS_API
73 const GstTagList*        gst_discoverer_stream_info_get_tags(GstDiscovererStreamInfo* info);
74 
75 GST_PBUTILS_API
76 const GstToc*            gst_discoverer_stream_info_get_toc(GstDiscovererStreamInfo* info);
77 
78 GST_PBUTILS_API
79 const gchar*             gst_discoverer_stream_info_get_stream_id(GstDiscovererStreamInfo* info);
80 
81 GST_PBUTILS_DEPRECATED_FOR(gst_discoverer_info_get_missing_elements_installer_details)
82 const GstStructure*      gst_discoverer_stream_info_get_misc(GstDiscovererStreamInfo* info);
83 
84 GST_PBUTILS_API
85 const gchar *            gst_discoverer_stream_info_get_stream_type_nick(GstDiscovererStreamInfo* info);
86 
87 GST_PBUTILS_API
88 gint                     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))
101 typedef struct _GstDiscovererContainerInfo GstDiscovererContainerInfo;
102 typedef GObjectClass GstDiscovererContainerInfoClass;
103 
104 GST_PBUTILS_API
105 GType gst_discoverer_container_info_get_type (void);
106 
107 GST_PBUTILS_API
108 GList *gst_discoverer_container_info_get_streams(GstDiscovererContainerInfo *info);
109 
110 GST_PBUTILS_API
111 const 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))
125 typedef struct _GstDiscovererAudioInfo GstDiscovererAudioInfo;
126 typedef GObjectClass GstDiscovererAudioInfoClass;
127 
128 GST_PBUTILS_API
129 GType gst_discoverer_audio_info_get_type (void);
130 
131 GST_PBUTILS_API
132 guint gst_discoverer_audio_info_get_channels(const GstDiscovererAudioInfo* info);
133 
134 GST_PBUTILS_API
135 guint64 gst_discoverer_audio_info_get_channel_mask(const GstDiscovererAudioInfo* info);
136 
137 GST_PBUTILS_API
138 guint gst_discoverer_audio_info_get_sample_rate(const GstDiscovererAudioInfo* info);
139 
140 GST_PBUTILS_API
141 guint gst_discoverer_audio_info_get_depth(const GstDiscovererAudioInfo* info);
142 
143 GST_PBUTILS_API
144 guint gst_discoverer_audio_info_get_bitrate(const GstDiscovererAudioInfo* info);
145 
146 GST_PBUTILS_API
147 guint gst_discoverer_audio_info_get_max_bitrate(const GstDiscovererAudioInfo* info);
148 
149 GST_PBUTILS_API
150 const 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))
163 typedef struct _GstDiscovererVideoInfo GstDiscovererVideoInfo;
164 typedef GObjectClass GstDiscovererVideoInfoClass;
165 
166 GST_PBUTILS_API
167 GType gst_discoverer_video_info_get_type (void);
168 
169 GST_PBUTILS_API
170 guint           gst_discoverer_video_info_get_width(const GstDiscovererVideoInfo* info);
171 
172 GST_PBUTILS_API
173 guint           gst_discoverer_video_info_get_height(const GstDiscovererVideoInfo* info);
174 
175 GST_PBUTILS_API
176 guint           gst_discoverer_video_info_get_depth(const GstDiscovererVideoInfo* info);
177 
178 GST_PBUTILS_API
179 guint           gst_discoverer_video_info_get_framerate_num(const GstDiscovererVideoInfo* info);
180 
181 GST_PBUTILS_API
182 guint           gst_discoverer_video_info_get_framerate_denom(const GstDiscovererVideoInfo* info);
183 
184 GST_PBUTILS_API
185 guint           gst_discoverer_video_info_get_par_num(const GstDiscovererVideoInfo* info);
186 
187 GST_PBUTILS_API
188 guint           gst_discoverer_video_info_get_par_denom(const GstDiscovererVideoInfo* info);
189 
190 GST_PBUTILS_API
191 gboolean        gst_discoverer_video_info_is_interlaced(const GstDiscovererVideoInfo* info);
192 
193 GST_PBUTILS_API
194 guint           gst_discoverer_video_info_get_bitrate(const GstDiscovererVideoInfo* info);
195 
196 GST_PBUTILS_API
197 guint           gst_discoverer_video_info_get_max_bitrate(const GstDiscovererVideoInfo* info);
198 
199 GST_PBUTILS_API
200 gboolean        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))
214 typedef struct _GstDiscovererSubtitleInfo GstDiscovererSubtitleInfo;
215 typedef GObjectClass GstDiscovererSubtitleInfoClass;
216 
217 GST_PBUTILS_API
218 GType gst_discoverer_subtitle_info_get_type (void);
219 
220 GST_PBUTILS_API
221 const 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  */
234 typedef 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 
259 typedef 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  */
272 typedef 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))
280 typedef GObjectClass GstDiscovererInfoClass;
281 
282 GST_PBUTILS_API
283 GType 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 
288 GST_PBUTILS_API
289 GstDiscovererInfo*        gst_discoverer_info_copy (GstDiscovererInfo * ptr);
290 
291 GST_PBUTILS_API
292 const gchar*              gst_discoverer_info_get_uri(const GstDiscovererInfo* info);
293 
294 GST_PBUTILS_API
295 GstDiscovererResult       gst_discoverer_info_get_result(const GstDiscovererInfo* info);
296 
297 GST_PBUTILS_API
298 GstDiscovererStreamInfo*  gst_discoverer_info_get_stream_info(GstDiscovererInfo* info);
299 
300 GST_PBUTILS_API
301 GList*                    gst_discoverer_info_get_stream_list(GstDiscovererInfo* info);
302 
303 GST_PBUTILS_API
304 GstClockTime              gst_discoverer_info_get_duration(const GstDiscovererInfo* info);
305 
306 GST_PBUTILS_API
307 gboolean                  gst_discoverer_info_get_seekable(const GstDiscovererInfo* info);
308 
309 GST_PBUTILS_API
310 gboolean                  gst_discoverer_info_get_live(const GstDiscovererInfo* info);
311 
312 GST_PBUTILS_DEPRECATED_FOR(gst_discoverer_info_get_missing_elements_installer_details)
313 const GstStructure*       gst_discoverer_info_get_misc(const GstDiscovererInfo* info);
314 
315 GST_PBUTILS_DEPRECATED
316 const GstTagList*         gst_discoverer_info_get_tags(const GstDiscovererInfo* info);
317 GST_PBUTILS_API
318 const GstToc*             gst_discoverer_info_get_toc(const GstDiscovererInfo* info);
319 
320 GST_PBUTILS_API
321 const gchar**             gst_discoverer_info_get_missing_elements_installer_details(const GstDiscovererInfo* info);
322 
323 GST_PBUTILS_API
324 GList *                   gst_discoverer_info_get_streams (GstDiscovererInfo *info,
325 							   GType streamtype);
326 
327 GST_PBUTILS_API
328 GList *                   gst_discoverer_info_get_audio_streams (GstDiscovererInfo *info);
329 
330 GST_PBUTILS_API
331 GList *                   gst_discoverer_info_get_video_streams (GstDiscovererInfo *info);
332 
333 GST_PBUTILS_API
334 GList *                   gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo *info);
335 
336 GST_PBUTILS_API
337 GList *                   gst_discoverer_info_get_container_streams (GstDiscovererInfo *info);
338 
339 GST_PBUTILS_API
340 GVariant *                gst_discoverer_info_to_variant (GstDiscovererInfo *info,
341                                                           GstDiscovererSerializeFlags flags);
342 
343 GST_PBUTILS_API
344 GstDiscovererInfo *       gst_discoverer_info_from_variant (GVariant *variant);
345 
346 GST_PBUTILS_API
347 void                      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 
360 typedef struct _GstDiscoverer GstDiscoverer;
361 typedef struct _GstDiscovererClass GstDiscovererClass;
362 typedef struct _GstDiscovererPrivate GstDiscovererPrivate;
363 
364 /**
365  * GstDiscoverer:
366  *
367  * The #GstDiscoverer structure.
368  **/
369 struct _GstDiscoverer {
370   GObject parent;
371 
372   /*< private >*/
373   GstDiscovererPrivate *priv;
374 
375   gpointer _reserved[GST_PADDING];
376 };
377 
378 struct _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 
393 GST_PBUTILS_API
394 GType          gst_discoverer_get_type (void);
395 
396 GST_PBUTILS_API
397 GstDiscoverer *gst_discoverer_new (GstClockTime timeout, GError **err);
398 
399 /* Asynchronous API */
400 
401 GST_PBUTILS_API
402 void           gst_discoverer_start (GstDiscoverer *discoverer);
403 
404 GST_PBUTILS_API
405 void           gst_discoverer_stop (GstDiscoverer *discoverer);
406 
407 GST_PBUTILS_API
408 gboolean       gst_discoverer_discover_uri_async (GstDiscoverer *discoverer,
409 						  const gchar *uri);
410 
411 /* Synchronous API */
412 
413 GST_PBUTILS_API
414 GstDiscovererInfo *
415 gst_discoverer_discover_uri (GstDiscoverer * discoverer,
416 			     const gchar * uri,
417 			     GError ** err);
418 
419 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscoverer, gst_object_unref)
420 
421 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererAudioInfo, gst_object_unref)
422 
423 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererContainerInfo, gst_object_unref)
424 
425 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererInfo, gst_object_unref)
426 
427 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererStreamInfo, gst_object_unref)
428 
429 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererSubtitleInfo, gst_object_unref)
430 
431 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDiscovererVideoInfo, gst_object_unref)
432 
433 G_END_DECLS
434 
435 #endif /* _GST_DISCOVERER_H */
436