Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / pbutils / gstdiscoverer-types.c
1 /* GStreamer
2  * Copyright (C) 2010 Collabora Multimedia
3  *               2010 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., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include "pbutils.h"
26 #include "pbutils-private.h"
27
28 static GstDiscovererStreamInfo
29     * gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
30     GHashTable * stream_map);
31
32 static GstDiscovererContainerInfo
33     * gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
34     GHashTable * stream_map);
35
36 static GstDiscovererAudioInfo
37     * gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr);
38
39 static GstDiscovererVideoInfo
40     * gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr);
41
42 /* Per-stream information */
43
44 G_DEFINE_TYPE (GstDiscovererStreamInfo, gst_discoverer_stream_info,
45     GST_TYPE_MINI_OBJECT);
46
47 static void
48 gst_discoverer_stream_info_init (GstDiscovererStreamInfo * info)
49 {
50   /* Nothing needs initialization */
51 }
52
53 static void
54 gst_discoverer_stream_info_finalize (GstDiscovererStreamInfo * info)
55 {
56   if (info->next)
57     gst_mini_object_unref ((GstMiniObject *) info->next);
58
59   if (info->caps)
60     gst_caps_unref (info->caps);
61
62   if (info->tags)
63     gst_tag_list_free (info->tags);
64
65   if (info->misc)
66     gst_structure_free (info->misc);
67 }
68
69 static GstDiscovererStreamInfo *
70 gst_discoverer_stream_info_copy (GstDiscovererStreamInfo * info)
71 {
72   return gst_discoverer_info_copy_int (info, NULL);
73 }
74
75 static void
76 gst_discoverer_stream_info_class_init (GstMiniObjectClass * klass)
77 {
78   klass->finalize =
79       (GstMiniObjectFinalizeFunction) gst_discoverer_stream_info_finalize;
80   klass->copy = (GstMiniObjectCopyFunction) gst_discoverer_stream_info_copy;
81 }
82
83 static GstDiscovererStreamInfo *
84 gst_discoverer_stream_info_new (void)
85 {
86   return (GstDiscovererStreamInfo *)
87       gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
88 }
89
90 static GstDiscovererStreamInfo *
91 gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
92     GHashTable * stream_map)
93 {
94   GstDiscovererStreamInfo *ret;
95   GType ltyp;
96
97   g_return_val_if_fail (info != NULL, NULL);
98
99   ltyp = G_TYPE_FROM_INSTANCE (info);
100
101   if (ltyp == GST_TYPE_DISCOVERER_CONTAINER_INFO) {
102     ret = (GstDiscovererStreamInfo *)
103         gst_stream_container_info_copy_int (
104         (GstDiscovererContainerInfo *) info, stream_map);
105   } else if (ltyp == GST_TYPE_DISCOVERER_AUDIO_INFO) {
106     ret = (GstDiscovererStreamInfo *)
107         gst_discoverer_audio_info_copy_int ((GstDiscovererAudioInfo *) info);
108
109   } else if (ltyp == GST_TYPE_DISCOVERER_VIDEO_INFO) {
110     ret = (GstDiscovererStreamInfo *)
111         gst_discoverer_video_info_copy_int ((GstDiscovererVideoInfo *) info);
112
113   } else
114     ret = gst_discoverer_stream_info_new ();
115
116   if (info->next) {
117     ret->next = gst_discoverer_info_copy_int (info->next, stream_map);
118     ret->next->previous = ret;
119   }
120
121   if (info->caps)
122     ret->caps = gst_caps_copy (info->caps);
123
124   if (info->tags)
125     ret->tags = gst_tag_list_copy (info->tags);
126
127   if (info->misc)
128     ret->misc = gst_structure_copy (info->misc);
129
130   if (stream_map)
131     g_hash_table_insert (stream_map, info, ret);
132
133   return ret;
134 }
135
136 /* Container information */
137 G_DEFINE_TYPE (GstDiscovererContainerInfo, gst_discoverer_container_info,
138     GST_TYPE_DISCOVERER_STREAM_INFO);
139
140 static void
141 gst_discoverer_container_info_init (GstDiscovererContainerInfo * info)
142 {
143   /* Nothing to initialize */
144 }
145
146 static GstDiscovererContainerInfo *
147 gst_discoverer_container_info_new (void)
148 {
149   return (GstDiscovererContainerInfo *)
150       gst_mini_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO);
151 }
152
153 static void
154 gst_discoverer_container_info_finalize (GstDiscovererContainerInfo * info)
155 {
156   GList *tmp;
157
158   for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
159       tmp = tmp->next)
160     gst_mini_object_unref ((GstMiniObject *) tmp->data);
161
162   gst_discoverer_stream_info_list_free (info->streams);
163
164   gst_discoverer_stream_info_finalize ((GstDiscovererStreamInfo *) info);
165 }
166
167 static void
168 gst_discoverer_container_info_class_init (GstMiniObjectClass * klass)
169 {
170   klass->finalize =
171       (GstMiniObjectFinalizeFunction) gst_discoverer_container_info_finalize;
172 }
173
174 static GstDiscovererContainerInfo *
175 gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
176     GHashTable * stream_map)
177 {
178   GstDiscovererContainerInfo *ret;
179   GList *tmp;
180
181   g_return_val_if_fail (ptr != NULL, NULL);
182
183   ret = gst_discoverer_container_info_new ();
184
185   for (tmp = ((GstDiscovererContainerInfo *) ptr)->streams; tmp;
186       tmp = tmp->next) {
187     GstDiscovererStreamInfo *subtop = gst_discoverer_info_copy_int (tmp->data,
188         stream_map);
189     ret->streams = g_list_append (ret->streams, subtop);
190     if (stream_map)
191       g_hash_table_insert (stream_map, tmp->data, subtop);
192   }
193
194   return ret;
195 }
196
197 /* Audio information */
198 G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
199     GST_TYPE_DISCOVERER_STREAM_INFO);
200
201 static void
202 gst_discoverer_audio_info_class_init (GstDiscovererAudioInfoClass * klass)
203 {
204   /* Nothing to initialize */
205 }
206
207 static void
208 gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
209 {
210   /* Nothing to initialize */
211 }
212
213 static GstDiscovererAudioInfo *
214 gst_discoverer_audio_info_new (void)
215 {
216   return (GstDiscovererAudioInfo *)
217       gst_mini_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO);
218 }
219
220 static GstDiscovererAudioInfo *
221 gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
222 {
223   GstDiscovererAudioInfo *ret;
224
225   ret = gst_discoverer_audio_info_new ();
226
227   ret->channels = ptr->channels;
228   ret->sample_rate = ptr->sample_rate;
229   ret->depth = ptr->depth;
230   ret->bitrate = ptr->bitrate;
231   ret->max_bitrate = ptr->max_bitrate;
232
233   return ret;
234 }
235
236 /* Video information */
237 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
238     GST_TYPE_DISCOVERER_STREAM_INFO);
239
240 static void
241 gst_discoverer_video_info_class_init (GstMiniObjectClass * klass)
242 {
243   /* Nothing to initialize */
244 }
245
246 static void
247 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
248 {
249   /* Nothing to initialize */
250 }
251
252 static GstDiscovererVideoInfo *
253 gst_discoverer_video_info_new (void)
254 {
255   return (GstDiscovererVideoInfo *)
256       gst_mini_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO);
257 }
258
259 static GstDiscovererVideoInfo *
260 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
261 {
262   GstDiscovererVideoInfo *ret;
263
264   ret = gst_discoverer_video_info_new ();
265
266   ret->width = ptr->width;
267   ret->height = ptr->height;
268   ret->depth = ptr->depth;
269   ret->framerate_num = ptr->framerate_num;
270   ret->framerate_denom = ptr->framerate_denom;
271   ret->par_num = ptr->par_num;
272   ret->par_denom = ptr->par_denom;
273   ret->interlaced = ptr->interlaced;
274   ret->bitrate = ptr->bitrate;
275   ret->max_bitrate = ptr->max_bitrate;
276   ret->is_image = ptr->is_image;
277
278   return ret;
279 }
280
281 /* Global stream information */
282 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, GST_TYPE_MINI_OBJECT);
283
284 static void
285 gst_discoverer_info_init (GstDiscovererInfo * info)
286 {
287   /* Nothing needs initialization */
288 }
289
290 static void
291 gst_discoverer_info_finalize (GstDiscovererInfo * info)
292 {
293   g_free (info->uri);
294
295   if (info->stream_info)
296     gst_mini_object_unref ((GstMiniObject *) info->stream_info);
297
298   if (info->misc)
299     gst_structure_free (info->misc);
300
301   g_list_free (info->stream_list);
302
303   if (info->tags)
304     gst_tag_list_free (info->tags);
305 }
306
307 static GstDiscovererInfo *
308 gst_discoverer_info_new (void)
309 {
310   return (GstDiscovererInfo *) gst_mini_object_new (GST_TYPE_DISCOVERER_INFO);
311 }
312
313 GstDiscovererInfo *
314 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
315 {
316   GstDiscovererInfo *ret;
317   GHashTable *stream_map = g_hash_table_new (g_direct_hash, NULL);
318   GList *tmp;
319
320   g_return_val_if_fail (ptr != NULL, NULL);
321
322   ret = gst_discoverer_info_new ();
323
324   ret->uri = g_strdup (ptr->uri);
325   if (ptr->stream_info) {
326     ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
327         stream_map);
328   }
329   ret->duration = ptr->duration;
330   if (ptr->misc)
331     ret->misc = gst_structure_copy (ptr->misc);
332
333   /* We need to set up the new list of streams to correspond to old one. The
334    * list just contains a set of pointers to streams in the stream_info tree,
335    * so we keep a map of old stream info objects to the corresponding new
336    * ones and use that to figure out correspondence in stream_list. */
337   for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
338     GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
339     GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
340         old_stream);
341     g_assert (new_stream != NULL);
342     ret->stream_list = g_list_append (ret->stream_list, new_stream);
343   }
344
345   if (ptr->tags)
346     ret->tags = gst_tag_list_copy (ptr->tags);
347
348   g_hash_table_destroy (stream_map);
349   return ret;
350 }
351
352 static void
353 gst_discoverer_info_class_init (GstMiniObjectClass * klass)
354 {
355   klass->finalize =
356       (GstMiniObjectFinalizeFunction) gst_discoverer_info_finalize;
357   klass->copy = (GstMiniObjectCopyFunction) gst_discoverer_info_copy;
358 }
359
360 /**
361  * gst_discoverer_stream_info_list_free:
362  * @infos: a #GList of #GstDiscovererStreamInfo
363  *
364  * Decrements the reference count of all contained #GstDiscovererStreamInfo
365  * and fress the #GList.
366  */
367 void
368 gst_discoverer_stream_info_list_free (GList * infos)
369 {
370   GList *tmp;
371
372   for (tmp = infos; tmp; tmp = tmp->next)
373     gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
374   g_list_free (infos);
375 }
376
377 /**
378  * gst_discoverer_info_get_streams:
379  * @info: a #GstDiscovererInfo
380  * @streamtype: a #GType derived from #GstDiscovererStreamInfo
381  *
382  * Finds the #GstDiscovererStreamInfo contained in @info that match the
383  * given @streamtype.
384  *
385  * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): A #GList of
386  * matching #GstDiscovererStreamInfo. The caller should free it with
387  * gst_discoverer_stream_info_list_free().
388  *
389  * Since: 0.10.31
390  */
391 GList *
392 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
393 {
394   GList *tmp, *res = NULL;
395
396   for (tmp = info->stream_list; tmp; tmp = tmp->next) {
397     GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
398
399     if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
400       res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
401   }
402
403   return res;
404 }
405
406 /**
407  * gst_discoverer_info_get_audio_streams:
408  * @info: a #GstDiscovererInfo
409  *
410  * Finds all the #GstDiscovererAudioInfo contained in @info
411  *
412  * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): A #GList of
413  * matching #GstDiscovererStreamInfo. The caller should free it with
414  * gst_discoverer_stream_info_list_free().
415  *
416  * Since: 0.10.31
417  */
418 GList *
419 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
420 {
421   return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
422 }
423
424 /**
425  * gst_discoverer_info_get_video_streams:
426  * @info: a #GstDiscovererInfo
427  *
428  * Finds all the #GstDiscovererVideoInfo contained in @info
429  *
430  * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): A #GList of
431  * matching #GstDiscovererStreamInfo. The caller should free it with
432  * gst_discoverer_stream_info_list_free().
433  *
434  * Since: 0.10.31
435  */
436 GList *
437 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
438 {
439   return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
440 }
441
442 /**
443  * gst_discoverer_info_get_container_streams:
444  * @info: a #GstDiscovererInfo
445  *
446  * Finds all the #GstDiscovererContainerInfo contained in @info
447  *
448  * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): A #GList of
449  * matching #GstDiscovererStreamInfo. The caller should free it with
450  * gst_discoverer_stream_info_list_free().
451  *
452  * Since: 0.10.31
453  */
454 GList *
455 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
456 {
457   return gst_discoverer_info_get_streams (info,
458       GST_TYPE_DISCOVERER_CONTAINER_INFO);
459 }
460
461 /**
462  * gst_discoverer_stream_info_get_stream_type_nick:
463  * @info: a #GstDiscovererStreamInfo
464  *
465  * Returns: a human readable name for the stream type of the given @info (ex : "audio",
466  * "container",...).
467  *
468  * Since: 0.10.31
469  */
470 const gchar *
471 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
472 {
473   if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
474     return "container";
475   if (GST_IS_DISCOVERER_AUDIO_INFO (info))
476     return "audio";
477   if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
478     if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
479             info))
480       return "video(image)";
481     else
482       return "video";
483   }
484   return "unknown";
485 }
486
487 /* ACCESSORS */
488
489
490 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
491   type parent##_get_##fieldname(const parenttype info) {                        \
492     g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
493     return (info)->fieldname;                           \
494   }
495
496 /**
497  * gst_discoverer_stream_info_get_previous:
498  * @info: a #GstDiscovererStreamInfo
499  *
500  * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
501  * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
502  * after usage.
503  *
504  * Since: 0.10.31
505  */
506 GstDiscovererStreamInfo *
507 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
508 {
509   g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
510
511   if (info->previous)
512     return gst_discoverer_stream_info_ref (info->previous);
513   return NULL;
514 }
515
516 /**
517  * gst_discoverer_stream_info_get_next:
518  * @info: a #GstDiscovererStreamInfo
519  *
520  * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
521  * for final streams.
522  * Unref with #gst_discoverer_stream_info_unref after usage.
523  *
524  * Since: 0.10.31
525  */
526 GstDiscovererStreamInfo *
527 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
528 {
529   g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
530
531   if (info->next)
532     return gst_discoverer_stream_info_ref (info->next);
533   return NULL;
534 }
535
536
537 /**
538  * gst_discoverer_stream_info_get_caps:
539  * @info: a #GstDiscovererStreamInfo
540  *
541  * Returns: (transfer full): the #GstCaps of the stream. Unref with
542  * #gst_caps_unref after usage.
543  *
544  * Since: 0.10.31
545  */
546 GstCaps *
547 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
548 {
549   g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
550
551   if (info->caps)
552     return gst_caps_ref (info->caps);
553   return NULL;
554 }
555
556 /**
557  * gst_discoverer_stream_info_get_tags:
558  * @info: a #GstDiscovererStreamInfo
559  *
560  * Returns: (transfer none): the tags contained in this stream. If you wish to
561  * use the tags after the life-time of @info you will need to copy them.
562  *
563  * Since: 0.10.31
564  */
565
566 const GstTagList *
567 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
568 {
569   g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
570
571   return info->tags;
572 }
573
574 /**
575  * gst_discoverer_stream_info_get_misc:
576  * @info: a #GstDiscovererStreamInfo
577  *
578  * Returns: (transfer none): additional information regarding the stream (for
579  * example codec version, profile, etc..). If you wish to use the #GstStructure
580  * after the life-time of @info you will need to copy it.
581  *
582  * Since: 0.10.31
583  */
584 const GstStructure *
585 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
586 {
587   g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
588
589   return info->misc;
590 }
591
592 /* GstDiscovererContainerInfo */
593
594 /**
595  * gst_discoverer_container_info_get_streams:
596  * @info: a #GstDiscovererStreamInfo
597  *
598  * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): the list of
599  * #GstDiscovererStreamInfo this container stream offers.
600  * Free with gst_discoverer_stream_info_list_free() after usage.
601  *
602  * Since: 0.10.31
603  */
604
605 GList *
606 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
607 {
608   GList *res = NULL, *tmp;
609
610   g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
611
612   for (tmp = info->streams; tmp; tmp = tmp->next)
613     res =
614         g_list_append (res,
615         gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
616
617   return res;
618 }
619
620 /* GstDiscovererAudioInfo */
621
622 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval)              \
623   GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
624                         GST_TYPE_DISCOVERER_AUDIO_INFO,         \
625                         fieldname, type, failval)
626
627 /**
628  * gst_discoverer_audio_info_get_channels:
629  * @info: a #GstDiscovererAudioInfo
630  *
631  * Returns: the number of channels in the stream.
632  *
633  * Since: 0.10.31
634  */
635
636 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
637
638 /**
639  * gst_discoverer_audio_info_get_sample_rate:
640  * @info: a #GstDiscovererAudioInfo
641  *
642  * Returns: the sample rate of the stream in Hertz.
643  *
644  * Since: 0.10.31
645  */
646
647 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
648
649 /**
650  * gst_discoverer_audio_info_get_depth:
651  * @info: a #GstDiscovererAudioInfo
652  *
653  * Returns: the number of bits used per sample in each channel.
654  *
655  * Since: 0.10.31
656  */
657
658 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
659
660 /**
661  * gst_discoverer_audio_info_get_bitrate:
662  * @info: a #GstDiscovererAudioInfo
663  *
664  * Returns: the average or nominal bitrate of the stream in bits/second.
665  *
666  * Since: 0.10.31
667  */
668
669 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
670
671 /**
672  * gst_discoverer_audio_info_get_max_bitrate:
673  * @info: a #GstDiscovererAudioInfo
674  *
675  * Returns: the maximum bitrate of the stream in bits/second.
676  *
677  * Since: 0.10.31
678  */
679
680 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
681
682 /* GstDiscovererVideoInfo */
683
684 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval)              \
685   GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
686                         GST_TYPE_DISCOVERER_VIDEO_INFO,                 \
687                         fieldname, type, failval)
688
689 /**
690  * gst_discoverer_video_info_get_width:
691  * @info: a #GstDiscovererVideoInfo
692  *
693  * Returns: the width of the video stream in pixels.
694  *
695  * Since: 0.10.31
696  */
697
698 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
699
700 /**
701  * gst_discoverer_video_info_get_height:
702  * @info: a #GstDiscovererVideoInfo
703  *
704  * Returns: the height of the video stream in pixels.
705  *
706  * Since: 0.10.31
707  */
708
709 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
710
711 /**
712  * gst_discoverer_video_info_get_depth:
713  * @info: a #GstDiscovererVideoInfo
714  *
715  * Returns: the depth in bits of the video stream.
716  *
717  * Since: 0.10.31
718  */
719
720 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
721
722 /**
723  * gst_discoverer_video_info_get_framerate_num:
724  * @info: a #GstDiscovererVideoInfo
725  *
726  * Returns: the framerate of the video stream (numerator).
727  *
728  * Since: 0.10.31
729  */
730
731 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
732
733 /**
734  * gst_discoverer_video_info_get_framerate_denom:
735  * @info: a #GstDiscovererVideoInfo
736  *
737  * Returns: the framerate of the video stream (denominator).
738  *
739  * Since: 0.10.31
740  */
741
742 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
743
744 /**
745  * gst_discoverer_video_info_get_par_num:
746  * @info: a #GstDiscovererVideoInfo
747  *
748  * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
749  *
750  * Since: 0.10.31
751  */
752
753 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
754
755 /**
756  * gst_discoverer_video_info_get_par_denom:
757  * @info: a #GstDiscovererVideoInfo
758  *
759  * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
760  *
761  * Since: 0.10.31
762  */
763
764 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
765
766 /**
767  * gst_discoverer_video_info_is_interlaced:
768  * @info: a #GstDiscovererVideoInfo
769  *
770  * Returns: %TRUE if the stream is interlaced, else %FALSE.
771  *
772  * Since: 0.10.31
773  */
774 gboolean
775 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
776 {
777   g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
778
779   return info->interlaced;
780 }
781
782 /**
783  * gst_discoverer_video_info_get_bitrate:
784  * @info: a #GstDiscovererVideoInfo
785  *
786  * Returns: the average or nominal bitrate of the video stream in bits/second.
787  *
788  * Since: 0.10.31
789  */
790
791 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
792
793 /**
794  * gst_discoverer_video_info_get_max_bitrate:
795  * @info: a #GstDiscovererVideoInfo
796  *
797  * Returns: the maximum bitrate of the video stream in bits/second.
798  *
799  * Since: 0.10.31
800  */
801
802 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
803
804 /**
805  * gst_discoverer_video_info_is_image:
806  * @info: a #GstDiscovererVideoInfo
807  *
808  * Returns: #TRUE if the video stream corresponds to an image (i.e. only contains
809  * one frame).
810  *
811  * Since: 0.10.31
812  */
813 gboolean
814 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
815 {
816   g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
817
818   return info->is_image;
819 }
820
821 /* GstDiscovererInfo */
822
823 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval)         \
824   GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*,        \
825                         GST_TYPE_DISCOVERER_INFO,                       \
826                         fieldname, type, failval)
827
828 /**
829  * gst_discoverer_info_get_uri:
830  * @info: a #GstDiscovererInfo
831  *
832  * Returns: (transfer none): the URI to which this information corresponds to.
833  * Copy it if you wish to use it after the life-time of @info.
834  *
835  * Since: 0.10.31
836  */
837
838 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
839
840 /**
841  * gst_discoverer_info_get_result:
842  * @info: a #GstDiscovererInfo
843  *
844  * Returns: the result of the discovery as a #GstDiscovererResult.
845  *
846  * Since: 0.10.31
847  */
848
849 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
850
851 /**
852  * gst_discoverer_info_get_stream_info:
853  * @info: a #GstDiscovererInfo
854  *
855  * Returns: (transfer full): the structure (or topology) of the URI as a
856  * #GstDiscovererStreamInfo.
857  * This structure can be traversed to see the original hierarchy. Unref with
858  * gst_discoverer_stream_info_unref() after usage.
859  *
860  * Since: 0.10.31
861  */
862
863 GstDiscovererStreamInfo *
864 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
865 {
866   g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
867
868   if (info->stream_info)
869     return gst_discoverer_stream_info_ref (info->stream_info);
870   return NULL;
871 }
872
873 /**
874  * gst_discoverer_info_get_stream_list:
875  * @info: a #GstDiscovererInfo
876  *
877  * Returns: (transfer full) (element-type Gst.DiscovererStreamInfo): the list of
878  * all streams contained in the #info. Free after usage
879  * with gst_discoverer_stream_info_list_free().
880  *
881  * Since: 0.10.31
882  */
883 GList *
884 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
885 {
886   GList *res = NULL, *tmp;
887
888   g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
889
890   for (tmp = info->stream_list; tmp; tmp = tmp->next)
891     res =
892         g_list_append (res,
893         gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
894
895   return res;
896 }
897
898 /**
899  * gst_discoverer_info_get_duration:
900  * @info: a #GstDiscovererInfo
901  *
902  * Returns: the duration of the URI in #GstClockTime (nanoseconds).
903  *
904  * Since: 0.10.31
905  */
906
907 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
908
909 /**
910  * gst_discoverer_info_get_seekable:
911  * @info: a #GstDiscovererInfo
912  *
913  * Returns: the wheter the URI is seekable.
914  *
915  * Since: 0.10.32
916  */
917
918 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
919
920 /**
921  * gst_discoverer_info_get_misc:
922  * @info: a #GstDiscovererInfo
923  *
924  * Returns: (transfer none): Miscellaneous information stored as a #GstStructure
925  * (for example: information about missing plugins). If you wish to use the
926  * #GstStructure after the life-time of @info, you will need to copy it.
927  *
928  * Since: 0.10.31
929  */
930
931 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
932
933 /**
934  * gst_discoverer_info_get_tags:
935  * @info: a #GstDiscovererInfo
936  *
937  * Returns: (transfer none): all tags contained in the %URI. If you wish to use
938  * the tags after the life-time of @info, you will need to copy them.
939  *
940  * Since: 0.10.31
941  */
942
943 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
944
945 /**
946  * gst_discoverer_info_ref:
947  * @info: a #GstDiscovererInfo
948  *
949  * Increments the reference count of @info.
950  *
951  * Returns: the same #GstDiscovererInfo object
952  *
953  * Since: 0.10.31
954  */
955
956 /**
957  * gst_discoverer_info_unref:
958  * @info: a #GstDiscovererInfo
959  *
960  * Decrements the reference count of @info.
961  *
962  * Since: 0.10.31
963  */
964
965 /**
966  * gst_discoverer_stream_info_ref:
967  * @info: a #GstDiscovererStreamInfo
968  *
969  * Increments the reference count of @info.
970  *
971  * Returns: the same #GstDiscovererStreamInfo object
972  *
973  * Since: 0.10.31
974  */
975
976 /**
977  * gst_discoverer_stream_info_unref:
978  * @info: a #GstDiscovererStreamInfo
979  *
980  * Decrements the reference count of @info.
981  *
982  * Since: 0.10.31
983  */