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