2 * Copyright (C) 2010 Collabora Multimedia
3 * 2010 Nokia Corporation
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.
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.
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.
26 #include "pbutils-private.h"
28 static GstDiscovererStreamInfo
29 * gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
30 GHashTable * stream_map);
32 static GstDiscovererContainerInfo
33 * gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
34 GHashTable * stream_map);
36 static GstDiscovererAudioInfo
37 * gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr);
39 static GstDiscovererVideoInfo
40 * gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr);
42 static GstDiscovererSubtitleInfo
43 * gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr);
45 /* Per-stream information */
47 G_DEFINE_TYPE (GstDiscovererStreamInfo, gst_discoverer_stream_info,
48 GST_TYPE_MINI_OBJECT);
51 gst_discoverer_stream_info_init (GstDiscovererStreamInfo * info)
53 /* Nothing needs initialization */
57 gst_discoverer_stream_info_finalize (GstDiscovererStreamInfo * info)
60 gst_mini_object_unref ((GstMiniObject *) info->next);
63 gst_caps_unref (info->caps);
66 gst_tag_list_free (info->tags);
69 gst_structure_free (info->misc);
72 static GstDiscovererStreamInfo *
73 gst_discoverer_stream_info_copy (GstDiscovererStreamInfo * info)
75 return gst_discoverer_info_copy_int (info, NULL);
79 gst_discoverer_stream_info_class_init (GstMiniObjectClass * klass)
82 (GstMiniObjectFinalizeFunction) gst_discoverer_stream_info_finalize;
83 klass->copy = (GstMiniObjectCopyFunction) gst_discoverer_stream_info_copy;
86 static GstDiscovererStreamInfo *
87 gst_discoverer_stream_info_new (void)
89 return (GstDiscovererStreamInfo *)
90 gst_mini_object_new (GST_TYPE_DISCOVERER_STREAM_INFO);
93 static GstDiscovererStreamInfo *
94 gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
95 GHashTable * stream_map)
97 GstDiscovererStreamInfo *ret;
100 g_return_val_if_fail (info != NULL, NULL);
102 ltyp = G_TYPE_FROM_INSTANCE (info);
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);
112 } else if (ltyp == GST_TYPE_DISCOVERER_VIDEO_INFO) {
113 ret = (GstDiscovererStreamInfo *)
114 gst_discoverer_video_info_copy_int ((GstDiscovererVideoInfo *) info);
116 } else if (ltyp == GST_TYPE_DISCOVERER_SUBTITLE_INFO) {
117 ret = (GstDiscovererStreamInfo *)
118 gst_discoverer_subtitle_info_copy_int ((GstDiscovererSubtitleInfo *)
122 ret = gst_discoverer_stream_info_new ();
125 ret->next = gst_discoverer_info_copy_int (info->next, stream_map);
126 ret->next->previous = ret;
130 ret->caps = gst_caps_copy (info->caps);
133 ret->tags = gst_tag_list_copy (info->tags);
136 ret->misc = gst_structure_copy (info->misc);
139 g_hash_table_insert (stream_map, info, ret);
144 /* Container information */
145 G_DEFINE_TYPE (GstDiscovererContainerInfo, gst_discoverer_container_info,
146 GST_TYPE_DISCOVERER_STREAM_INFO);
149 gst_discoverer_container_info_init (GstDiscovererContainerInfo * info)
151 /* Nothing to initialize */
154 static GstDiscovererContainerInfo *
155 gst_discoverer_container_info_new (void)
157 return (GstDiscovererContainerInfo *)
158 gst_mini_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO);
162 gst_discoverer_container_info_finalize (GstDiscovererContainerInfo * info)
166 for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
168 gst_mini_object_unref ((GstMiniObject *) tmp->data);
170 gst_discoverer_stream_info_list_free (info->streams);
172 gst_discoverer_stream_info_finalize ((GstDiscovererStreamInfo *) info);
176 gst_discoverer_container_info_class_init (GstMiniObjectClass * klass)
179 (GstMiniObjectFinalizeFunction) gst_discoverer_container_info_finalize;
182 static GstDiscovererContainerInfo *
183 gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
184 GHashTable * stream_map)
186 GstDiscovererContainerInfo *ret;
189 g_return_val_if_fail (ptr != NULL, NULL);
191 ret = gst_discoverer_container_info_new ();
193 for (tmp = ((GstDiscovererContainerInfo *) ptr)->streams; tmp;
195 GstDiscovererStreamInfo *subtop = gst_discoverer_info_copy_int (tmp->data,
197 ret->streams = g_list_append (ret->streams, subtop);
199 g_hash_table_insert (stream_map, tmp->data, subtop);
205 /* Audio information */
206 G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
207 GST_TYPE_DISCOVERER_STREAM_INFO);
210 gst_discoverer_audio_info_finalize (GstDiscovererAudioInfo * info)
212 g_free (info->language);
213 gst_discoverer_stream_info_finalize ((GstDiscovererStreamInfo *) info);
217 gst_discoverer_audio_info_class_init (GstDiscovererAudioInfoClass * klass)
220 (GstMiniObjectFinalizeFunction) gst_discoverer_audio_info_finalize;
224 gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
226 info->language = NULL;
229 static GstDiscovererAudioInfo *
230 gst_discoverer_audio_info_new (void)
232 return (GstDiscovererAudioInfo *)
233 gst_mini_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO);
236 static GstDiscovererAudioInfo *
237 gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
239 GstDiscovererAudioInfo *ret;
241 ret = gst_discoverer_audio_info_new ();
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);
253 /* Subtitle information */
254 G_DEFINE_TYPE (GstDiscovererSubtitleInfo, gst_discoverer_subtitle_info,
255 GST_TYPE_DISCOVERER_STREAM_INFO);
258 gst_discoverer_subtitle_info_init (GstDiscovererSubtitleInfo * info)
260 info->language = NULL;
264 gst_discoverer_subtitle_info_finalize (GstDiscovererSubtitleInfo * info)
266 g_free (info->language);
267 gst_discoverer_stream_info_finalize ((GstDiscovererStreamInfo *) info);
271 gst_discoverer_subtitle_info_class_init (GstMiniObjectClass * klass)
274 (GstMiniObjectFinalizeFunction) gst_discoverer_subtitle_info_finalize;
277 static GstDiscovererSubtitleInfo *
278 gst_discoverer_subtitle_info_new (void)
280 return (GstDiscovererSubtitleInfo *)
281 gst_mini_object_new (GST_TYPE_DISCOVERER_SUBTITLE_INFO);
284 static GstDiscovererSubtitleInfo *
285 gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr)
287 GstDiscovererSubtitleInfo *ret;
289 ret = gst_discoverer_subtitle_info_new ();
291 ret->language = g_strdup (ptr->language);
296 /* Video information */
297 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
298 GST_TYPE_DISCOVERER_STREAM_INFO);
301 gst_discoverer_video_info_class_init (GstMiniObjectClass * klass)
303 /* Nothing to initialize */
307 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
309 /* Nothing to initialize */
312 static GstDiscovererVideoInfo *
313 gst_discoverer_video_info_new (void)
315 return (GstDiscovererVideoInfo *)
316 gst_mini_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO);
319 static GstDiscovererVideoInfo *
320 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
322 GstDiscovererVideoInfo *ret;
324 ret = gst_discoverer_video_info_new ();
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;
341 /* Global stream information */
342 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, GST_TYPE_MINI_OBJECT);
345 gst_discoverer_info_init (GstDiscovererInfo * info)
347 /* Nothing needs initialization */
351 gst_discoverer_info_finalize (GstDiscovererInfo * info)
355 if (info->stream_info)
356 gst_mini_object_unref ((GstMiniObject *) info->stream_info);
359 gst_structure_free (info->misc);
361 g_list_free (info->stream_list);
364 gst_tag_list_free (info->tags);
367 static GstDiscovererInfo *
368 gst_discoverer_info_new (void)
370 return (GstDiscovererInfo *) gst_mini_object_new (GST_TYPE_DISCOVERER_INFO);
374 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
376 GstDiscovererInfo *ret;
377 GHashTable *stream_map;
380 g_return_val_if_fail (ptr != NULL, NULL);
382 stream_map = g_hash_table_new (g_direct_hash, NULL);
384 ret = gst_discoverer_info_new ();
386 ret->uri = g_strdup (ptr->uri);
387 if (ptr->stream_info) {
388 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
391 ret->duration = ptr->duration;
393 ret->misc = gst_structure_copy (ptr->misc);
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,
403 g_assert (new_stream != NULL);
404 ret->stream_list = g_list_append (ret->stream_list, new_stream);
408 ret->tags = gst_tag_list_copy (ptr->tags);
410 g_hash_table_destroy (stream_map);
415 gst_discoverer_info_class_init (GstMiniObjectClass * klass)
418 (GstMiniObjectFinalizeFunction) gst_discoverer_info_finalize;
419 klass->copy = (GstMiniObjectCopyFunction) gst_discoverer_info_copy;
423 * gst_discoverer_stream_info_list_free:
424 * @infos: a #GList of #GstDiscovererStreamInfo
426 * Decrements the reference count of all contained #GstDiscovererStreamInfo
427 * and fress the #GList.
430 gst_discoverer_stream_info_list_free (GList * infos)
434 for (tmp = infos; tmp; tmp = tmp->next)
435 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
440 * gst_discoverer_info_get_streams:
441 * @info: a #GstDiscovererInfo
442 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
444 * Finds the #GstDiscovererStreamInfo contained in @info that match the
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().
454 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
456 GList *tmp, *res = NULL;
458 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
459 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
461 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
462 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
469 * gst_discoverer_info_get_audio_streams:
470 * @info: a #GstDiscovererInfo
472 * Finds all the #GstDiscovererAudioInfo contained in @info
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().
481 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
483 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
487 * gst_discoverer_info_get_video_streams:
488 * @info: a #GstDiscovererInfo
490 * Finds all the #GstDiscovererVideoInfo contained in @info
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().
499 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
501 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
505 * gst_discoverer_info_get_subtitle_streams:
506 * @info: a #GstDiscovererInfo
508 * Finds all the #GstDiscovererSubtitleInfo contained in @info
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().
517 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
519 return gst_discoverer_info_get_streams (info,
520 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
524 * gst_discoverer_info_get_container_streams:
525 * @info: a #GstDiscovererInfo
527 * Finds all the #GstDiscovererContainerInfo contained in @info
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().
536 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
538 return gst_discoverer_info_get_streams (info,
539 GST_TYPE_DISCOVERER_CONTAINER_INFO);
543 * gst_discoverer_stream_info_get_stream_type_nick:
544 * @info: a #GstDiscovererStreamInfo
546 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
552 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
554 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
556 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
558 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
559 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
561 return "video(image)";
565 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
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; \
580 * gst_discoverer_stream_info_get_previous:
581 * @info: a #GstDiscovererStreamInfo
583 * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
584 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
589 GstDiscovererStreamInfo *
590 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
592 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
595 return gst_discoverer_stream_info_ref (info->previous);
600 * gst_discoverer_stream_info_get_next:
601 * @info: a #GstDiscovererStreamInfo
603 * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
605 * Unref with #gst_discoverer_stream_info_unref after usage.
609 GstDiscovererStreamInfo *
610 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
612 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
615 return gst_discoverer_stream_info_ref (info->next);
621 * gst_discoverer_stream_info_get_caps:
622 * @info: a #GstDiscovererStreamInfo
624 * Returns: (transfer full): the #GstCaps of the stream. Unref with
625 * #gst_caps_unref after usage.
630 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
632 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
635 return gst_caps_ref (info->caps);
640 * gst_discoverer_stream_info_get_tags:
641 * @info: a #GstDiscovererStreamInfo
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.
650 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
652 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
658 * gst_discoverer_stream_info_get_misc:
659 * @info: a #GstDiscovererStreamInfo
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.
668 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
670 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
675 /* GstDiscovererContainerInfo */
678 * gst_discoverer_container_info_get_streams:
679 * @info: a #GstDiscovererStreamInfo
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.
689 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
691 GList *res = NULL, *tmp;
693 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
695 for (tmp = info->streams; tmp; tmp = tmp->next)
698 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
703 /* GstDiscovererAudioInfo */
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)
711 * gst_discoverer_audio_info_get_channels:
712 * @info: a #GstDiscovererAudioInfo
714 * Returns: the number of channels in the stream.
719 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
722 * gst_discoverer_audio_info_get_sample_rate:
723 * @info: a #GstDiscovererAudioInfo
725 * Returns: the sample rate of the stream in Hertz.
730 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
733 * gst_discoverer_audio_info_get_depth:
734 * @info: a #GstDiscovererAudioInfo
736 * Returns: the number of bits used per sample in each channel.
741 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
744 * gst_discoverer_audio_info_get_bitrate:
745 * @info: a #GstDiscovererAudioInfo
747 * Returns: the average or nominal bitrate of the stream in bits/second.
752 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
755 * gst_discoverer_audio_info_get_max_bitrate:
756 * @info: a #GstDiscovererAudioInfo
758 * Returns: the maximum bitrate of the stream in bits/second.
763 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
766 * gst_discoverer_audio_info_get_language:
767 * @info: a #GstDiscovererAudioInfo
769 * Returns: the language of the stream, or NULL if unknown.
774 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
776 /* GstDiscovererVideoInfo */
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)
784 * gst_discoverer_video_info_get_width:
785 * @info: a #GstDiscovererVideoInfo
787 * Returns: the width of the video stream in pixels.
792 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
795 * gst_discoverer_video_info_get_height:
796 * @info: a #GstDiscovererVideoInfo
798 * Returns: the height of the video stream in pixels.
803 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
806 * gst_discoverer_video_info_get_depth:
807 * @info: a #GstDiscovererVideoInfo
809 * Returns: the depth in bits of the video stream.
814 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
817 * gst_discoverer_video_info_get_framerate_num:
818 * @info: a #GstDiscovererVideoInfo
820 * Returns: the framerate of the video stream (numerator).
825 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
828 * gst_discoverer_video_info_get_framerate_denom:
829 * @info: a #GstDiscovererVideoInfo
831 * Returns: the framerate of the video stream (denominator).
836 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
839 * gst_discoverer_video_info_get_par_num:
840 * @info: a #GstDiscovererVideoInfo
842 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
847 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
850 * gst_discoverer_video_info_get_par_denom:
851 * @info: a #GstDiscovererVideoInfo
853 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
858 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
861 * gst_discoverer_video_info_is_interlaced:
862 * @info: a #GstDiscovererVideoInfo
864 * Returns: %TRUE if the stream is interlaced, else %FALSE.
869 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
871 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
873 return info->interlaced;
877 * gst_discoverer_video_info_get_bitrate:
878 * @info: a #GstDiscovererVideoInfo
880 * Returns: the average or nominal bitrate of the video stream in bits/second.
885 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
888 * gst_discoverer_video_info_get_max_bitrate:
889 * @info: a #GstDiscovererVideoInfo
891 * Returns: the maximum bitrate of the video stream in bits/second.
896 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
899 * gst_discoverer_video_info_is_image:
900 * @info: a #GstDiscovererVideoInfo
902 * Returns: #TRUE if the video stream corresponds to an image (i.e. only contains
908 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
910 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
912 return info->is_image;
915 /* GstDiscovererSubtitleInfo */
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)
923 * gst_discoverer_subtitle_info_get_language:
924 * @info: a #GstDiscovererSubtitleInfo
926 * Returns: the language of the stream, or NULL if unknown.
931 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
933 /* GstDiscovererInfo */
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)
941 * gst_discoverer_info_get_uri:
942 * @info: a #GstDiscovererInfo
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.
950 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
953 * gst_discoverer_info_get_result:
954 * @info: a #GstDiscovererInfo
956 * Returns: the result of the discovery as a #GstDiscovererResult.
961 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
964 * gst_discoverer_info_get_stream_info:
965 * @info: a #GstDiscovererInfo
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.
975 GstDiscovererStreamInfo *
976 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
978 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
980 if (info->stream_info)
981 return gst_discoverer_stream_info_ref (info->stream_info);
986 * gst_discoverer_info_get_stream_list:
987 * @info: a #GstDiscovererInfo
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().
996 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
998 GList *res = NULL, *tmp;
1000 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1002 for (tmp = info->stream_list; tmp; tmp = tmp->next)
1005 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
1011 * gst_discoverer_info_get_duration:
1012 * @info: a #GstDiscovererInfo
1014 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
1019 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1022 * gst_discoverer_info_get_seekable:
1023 * @info: a #GstDiscovererInfo
1025 * Returns: the whether the URI is seekable.
1030 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1033 * gst_discoverer_info_get_misc:
1034 * @info: a #GstDiscovererInfo
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.
1043 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1046 * gst_discoverer_info_get_tags:
1047 * @info: a #GstDiscovererInfo
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.
1055 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1058 * gst_discoverer_info_ref:
1059 * @info: a #GstDiscovererInfo
1061 * Increments the reference count of @info.
1063 * Returns: the same #GstDiscovererInfo object
1069 * gst_discoverer_info_unref:
1070 * @info: a #GstDiscovererInfo
1072 * Decrements the reference count of @info.
1078 * gst_discoverer_stream_info_ref:
1079 * @info: a #GstDiscovererStreamInfo
1081 * Increments the reference count of @info.
1083 * Returns: the same #GstDiscovererStreamInfo object
1089 * gst_discoverer_stream_info_unref:
1090 * @info: a #GstDiscovererStreamInfo
1092 * Decrements the reference count of @info.