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., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, 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,
51 gst_discoverer_stream_info_init (GstDiscovererStreamInfo * info)
53 /* Nothing needs initialization */
57 gst_discoverer_stream_info_finalize (GObject * object)
59 GstDiscovererStreamInfo *info = (GstDiscovererStreamInfo *) object;
62 g_object_unref ((GObject *) info->next);
65 gst_caps_unref (info->caps);
68 gst_tag_list_unref (info->tags);
71 gst_toc_unref (info->toc);
73 g_free (info->stream_id);
76 gst_structure_free (info->misc);
80 gst_discoverer_stream_info_class_init (GObjectClass * klass)
82 klass->finalize = gst_discoverer_stream_info_finalize;
85 static GstDiscovererStreamInfo *
86 gst_discoverer_stream_info_new (void)
88 return (GstDiscovererStreamInfo *)
89 g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
92 static GstDiscovererStreamInfo *
93 gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
94 GHashTable * stream_map)
96 GstDiscovererStreamInfo *ret;
99 g_return_val_if_fail (info != NULL, NULL);
101 ltyp = G_TYPE_FROM_INSTANCE (info);
103 if (ltyp == GST_TYPE_DISCOVERER_CONTAINER_INFO) {
104 ret = (GstDiscovererStreamInfo *)
105 gst_stream_container_info_copy_int (
106 (GstDiscovererContainerInfo *) info, stream_map);
107 } else if (ltyp == GST_TYPE_DISCOVERER_AUDIO_INFO) {
108 ret = (GstDiscovererStreamInfo *)
109 gst_discoverer_audio_info_copy_int ((GstDiscovererAudioInfo *) info);
111 } else if (ltyp == GST_TYPE_DISCOVERER_VIDEO_INFO) {
112 ret = (GstDiscovererStreamInfo *)
113 gst_discoverer_video_info_copy_int ((GstDiscovererVideoInfo *) info);
115 } else if (ltyp == GST_TYPE_DISCOVERER_SUBTITLE_INFO) {
116 ret = (GstDiscovererStreamInfo *)
117 gst_discoverer_subtitle_info_copy_int ((GstDiscovererSubtitleInfo *)
121 ret = gst_discoverer_stream_info_new ();
124 ret->next = gst_discoverer_info_copy_int (info->next, stream_map);
125 ret->next->previous = ret;
129 ret->caps = gst_caps_copy (info->caps);
132 ret->tags = gst_tag_list_copy (info->tags);
135 ret->toc = gst_toc_ref (info->toc);
138 ret->stream_id = g_strdup (info->stream_id);
141 ret->misc = gst_structure_copy (info->misc);
144 g_hash_table_insert (stream_map, info, ret);
149 /* Container information */
150 G_DEFINE_TYPE (GstDiscovererContainerInfo, gst_discoverer_container_info,
151 GST_TYPE_DISCOVERER_STREAM_INFO);
154 gst_discoverer_container_info_init (GstDiscovererContainerInfo * info)
156 /* Nothing to initialize */
159 static GstDiscovererContainerInfo *
160 gst_discoverer_container_info_new (void)
162 return (GstDiscovererContainerInfo *)
163 g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
167 gst_discoverer_container_info_finalize (GObject * object)
169 GstDiscovererContainerInfo *info = (GstDiscovererContainerInfo *) object;
172 for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
174 g_object_unref ((GObject *) tmp->data);
176 gst_discoverer_stream_info_list_free (info->streams);
178 gst_discoverer_stream_info_finalize ((GObject *) info);
182 gst_discoverer_container_info_class_init (GObjectClass * klass)
184 klass->finalize = gst_discoverer_container_info_finalize;
187 static GstDiscovererContainerInfo *
188 gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
189 GHashTable * stream_map)
191 GstDiscovererContainerInfo *ret;
194 g_return_val_if_fail (ptr != NULL, NULL);
196 ret = gst_discoverer_container_info_new ();
198 for (tmp = ((GstDiscovererContainerInfo *) ptr)->streams; tmp;
200 GstDiscovererStreamInfo *subtop = gst_discoverer_info_copy_int (tmp->data,
202 ret->streams = g_list_append (ret->streams, subtop);
204 g_hash_table_insert (stream_map, tmp->data, subtop);
210 /* Audio information */
211 G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
212 GST_TYPE_DISCOVERER_STREAM_INFO);
215 gst_discoverer_audio_info_finalize (GObject * object)
217 GstDiscovererAudioInfo *info = (GstDiscovererAudioInfo *) object;
219 g_free (info->language);
221 G_OBJECT_CLASS (gst_discoverer_audio_info_parent_class)->finalize (object);
225 gst_discoverer_audio_info_class_init (GObjectClass * klass)
227 klass->finalize = gst_discoverer_audio_info_finalize;
231 gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
233 info->language = NULL;
236 static GstDiscovererAudioInfo *
237 gst_discoverer_audio_info_new (void)
239 return (GstDiscovererAudioInfo *)
240 g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
243 static GstDiscovererAudioInfo *
244 gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
246 GstDiscovererAudioInfo *ret;
248 ret = gst_discoverer_audio_info_new ();
250 ret->channels = ptr->channels;
251 ret->sample_rate = ptr->sample_rate;
252 ret->depth = ptr->depth;
253 ret->bitrate = ptr->bitrate;
254 ret->max_bitrate = ptr->max_bitrate;
255 ret->language = g_strdup (ptr->language);
260 /* Subtitle information */
261 G_DEFINE_TYPE (GstDiscovererSubtitleInfo, gst_discoverer_subtitle_info,
262 GST_TYPE_DISCOVERER_STREAM_INFO);
265 gst_discoverer_subtitle_info_init (GstDiscovererSubtitleInfo * info)
267 info->language = NULL;
271 gst_discoverer_subtitle_info_finalize (GObject * object)
273 GstDiscovererSubtitleInfo *info = (GstDiscovererSubtitleInfo *) object;
275 g_free (info->language);
277 G_OBJECT_CLASS (gst_discoverer_subtitle_info_parent_class)->finalize (object);
281 gst_discoverer_subtitle_info_class_init (GObjectClass * klass)
283 klass->finalize = gst_discoverer_subtitle_info_finalize;
286 static GstDiscovererSubtitleInfo *
287 gst_discoverer_subtitle_info_new (void)
289 return (GstDiscovererSubtitleInfo *)
290 g_object_new (GST_TYPE_DISCOVERER_SUBTITLE_INFO, NULL);
293 static GstDiscovererSubtitleInfo *
294 gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr)
296 GstDiscovererSubtitleInfo *ret;
298 ret = gst_discoverer_subtitle_info_new ();
300 ret->language = g_strdup (ptr->language);
305 /* Video information */
306 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
307 GST_TYPE_DISCOVERER_STREAM_INFO);
310 gst_discoverer_video_info_class_init (GObjectClass * klass)
312 /* Nothing to initialize */
316 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
318 /* Nothing to initialize */
321 static GstDiscovererVideoInfo *
322 gst_discoverer_video_info_new (void)
324 return (GstDiscovererVideoInfo *)
325 g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
328 static GstDiscovererVideoInfo *
329 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
331 GstDiscovererVideoInfo *ret;
333 ret = gst_discoverer_video_info_new ();
335 ret->width = ptr->width;
336 ret->height = ptr->height;
337 ret->depth = ptr->depth;
338 ret->framerate_num = ptr->framerate_num;
339 ret->framerate_denom = ptr->framerate_denom;
340 ret->par_num = ptr->par_num;
341 ret->par_denom = ptr->par_denom;
342 ret->interlaced = ptr->interlaced;
343 ret->bitrate = ptr->bitrate;
344 ret->max_bitrate = ptr->max_bitrate;
345 ret->is_image = ptr->is_image;
350 /* Global stream information */
351 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
354 gst_discoverer_info_init (GstDiscovererInfo * info)
356 /* Nothing needs initialization */
360 gst_discoverer_info_finalize (GObject * object)
362 GstDiscovererInfo *info = (GstDiscovererInfo *) object;
365 if (info->stream_info)
366 g_object_unref ((GObject *) info->stream_info);
369 gst_structure_free (info->misc);
371 g_list_free (info->stream_list);
374 gst_tag_list_unref (info->tags);
377 gst_toc_unref (info->toc);
380 static GstDiscovererInfo *
381 gst_discoverer_info_new (void)
383 return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
387 * gst_discoverer_info_copy:
388 * @ptr: (transfer none): a #GstDiscovererInfo
390 * Returns: (transfer full): A copy of the #GstDiscovererInfo
393 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
395 GstDiscovererInfo *ret;
396 GHashTable *stream_map;
399 g_return_val_if_fail (ptr != NULL, NULL);
401 stream_map = g_hash_table_new (g_direct_hash, NULL);
403 ret = gst_discoverer_info_new ();
405 ret->uri = g_strdup (ptr->uri);
406 if (ptr->stream_info) {
407 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
410 ret->duration = ptr->duration;
412 ret->misc = gst_structure_copy (ptr->misc);
414 /* We need to set up the new list of streams to correspond to old one. The
415 * list just contains a set of pointers to streams in the stream_info tree,
416 * so we keep a map of old stream info objects to the corresponding new
417 * ones and use that to figure out correspondence in stream_list. */
418 for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
419 GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
420 GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
422 g_assert (new_stream != NULL);
423 ret->stream_list = g_list_append (ret->stream_list, new_stream);
427 ret->tags = gst_tag_list_copy (ptr->tags);
430 ret->toc = gst_toc_ref (ptr->toc);
432 g_hash_table_destroy (stream_map);
437 gst_discoverer_info_class_init (GObjectClass * klass)
439 klass->finalize = gst_discoverer_info_finalize;
443 * gst_discoverer_stream_info_list_free:
444 * @infos: (element-type GstPbutils.DiscovererStreamInfo): a #GList of #GstDiscovererStreamInfo
446 * Decrements the reference count of all contained #GstDiscovererStreamInfo
447 * and fress the #GList.
450 gst_discoverer_stream_info_list_free (GList * infos)
454 for (tmp = infos; tmp; tmp = tmp->next)
455 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
460 * gst_discoverer_info_get_streams:
461 * @info: a #GstDiscovererInfo
462 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
464 * Finds the #GstDiscovererStreamInfo contained in @info that match the
467 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
468 * matching #GstDiscovererStreamInfo. The caller should free it with
469 * gst_discoverer_stream_info_list_free().
472 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
474 GList *tmp, *res = NULL;
476 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
477 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
479 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
480 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
487 * gst_discoverer_info_get_audio_streams:
488 * @info: a #GstDiscovererInfo
490 * Finds all the #GstDiscovererAudioInfo contained in @info
492 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
493 * matching #GstDiscovererStreamInfo. The caller should free it with
494 * gst_discoverer_stream_info_list_free().
497 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
499 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
503 * gst_discoverer_info_get_video_streams:
504 * @info: a #GstDiscovererInfo
506 * Finds all the #GstDiscovererVideoInfo contained in @info
508 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
509 * matching #GstDiscovererStreamInfo. The caller should free it with
510 * gst_discoverer_stream_info_list_free().
513 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
515 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
519 * gst_discoverer_info_get_subtitle_streams:
520 * @info: a #GstDiscovererInfo
522 * Finds all the #GstDiscovererSubtitleInfo contained in @info
524 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
525 * matching #GstDiscovererStreamInfo. The caller should free it with
526 * gst_discoverer_stream_info_list_free().
529 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
531 return gst_discoverer_info_get_streams (info,
532 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
536 * gst_discoverer_info_get_container_streams:
537 * @info: a #GstDiscovererInfo
539 * Finds all the #GstDiscovererContainerInfo contained in @info
541 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
542 * matching #GstDiscovererStreamInfo. The caller should free it with
543 * gst_discoverer_stream_info_list_free().
546 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
548 return gst_discoverer_info_get_streams (info,
549 GST_TYPE_DISCOVERER_CONTAINER_INFO);
553 * gst_discoverer_stream_info_get_stream_type_nick:
554 * @info: a #GstDiscovererStreamInfo
556 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
560 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
562 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
564 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
566 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
567 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
569 return "video(image)";
573 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
581 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
582 type parent##_get_##fieldname(const parenttype info) { \
583 g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
584 return (info)->fieldname; \
588 * gst_discoverer_stream_info_get_previous:
589 * @info: a #GstDiscovererStreamInfo
591 * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
592 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
595 GstDiscovererStreamInfo *
596 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
598 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
601 return gst_discoverer_stream_info_ref (info->previous);
606 * gst_discoverer_stream_info_get_next:
607 * @info: a #GstDiscovererStreamInfo
609 * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
611 * Unref with #gst_discoverer_stream_info_unref after usage.
613 GstDiscovererStreamInfo *
614 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
616 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
619 return gst_discoverer_stream_info_ref (info->next);
625 * gst_discoverer_stream_info_get_caps:
626 * @info: a #GstDiscovererStreamInfo
628 * Returns: (transfer full): the #GstCaps of the stream. Unref with
629 * #gst_caps_unref after usage.
632 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
634 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
637 return gst_caps_ref (info->caps);
642 * gst_discoverer_stream_info_get_tags:
643 * @info: a #GstDiscovererStreamInfo
645 * Returns: (transfer none): the tags contained in this stream. If you wish to
646 * use the tags after the life-time of @info you will need to copy them.
649 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
651 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
657 * gst_discoverer_stream_info_get_toc:
658 * @info: a #GstDiscovererStreamInfo
660 * Returns: (transfer none): the TOC contained in this stream. If you wish to
661 * use the TOC after the life-time of @info you will need to copy it.
664 gst_discoverer_stream_info_get_toc (GstDiscovererStreamInfo * info)
666 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
672 * gst_discoverer_stream_info_get_stream_id:
673 * @info: a #GstDiscovererStreamInfo
675 * Returns: (transfer none): the stream ID of this stream. If you wish to
676 * use the stream ID after the life-time of @info you will need to copy it.
679 gst_discoverer_stream_info_get_stream_id (GstDiscovererStreamInfo * info)
681 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
683 return info->stream_id;
687 * gst_discoverer_stream_info_get_misc:
688 * @info: a #GstDiscovererStreamInfo
690 * Returns: (transfer none): additional information regarding the stream (for
691 * example codec version, profile, etc..). If you wish to use the #GstStructure
692 * after the life-time of @info you will need to copy it.
695 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
697 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
702 /* GstDiscovererContainerInfo */
705 * gst_discoverer_container_info_get_streams:
706 * @info: a #GstDiscovererStreamInfo
708 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
709 * #GstDiscovererStreamInfo this container stream offers.
710 * Free with gst_discoverer_stream_info_list_free() after usage.
714 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
716 GList *res = NULL, *tmp;
718 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
720 for (tmp = info->streams; tmp; tmp = tmp->next)
723 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
728 /* GstDiscovererAudioInfo */
730 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
731 GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
732 GST_TYPE_DISCOVERER_AUDIO_INFO, \
733 fieldname, type, failval)
736 * gst_discoverer_audio_info_get_channels:
737 * @info: a #GstDiscovererAudioInfo
739 * Returns: the number of channels in the stream.
742 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
745 * gst_discoverer_audio_info_get_sample_rate:
746 * @info: a #GstDiscovererAudioInfo
748 * Returns: the sample rate of the stream in Hertz.
751 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
754 * gst_discoverer_audio_info_get_depth:
755 * @info: a #GstDiscovererAudioInfo
757 * Returns: the number of bits used per sample in each channel.
760 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
763 * gst_discoverer_audio_info_get_bitrate:
764 * @info: a #GstDiscovererAudioInfo
766 * Returns: the average or nominal bitrate of the stream in bits/second.
769 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
772 * gst_discoverer_audio_info_get_max_bitrate:
773 * @info: a #GstDiscovererAudioInfo
775 * Returns: the maximum bitrate of the stream in bits/second.
778 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
781 * gst_discoverer_audio_info_get_language:
782 * @info: a #GstDiscovererAudioInfo
784 * Returns: the language of the stream, or NULL if unknown.
787 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
789 /* GstDiscovererVideoInfo */
791 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
792 GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
793 GST_TYPE_DISCOVERER_VIDEO_INFO, \
794 fieldname, type, failval)
797 * gst_discoverer_video_info_get_width:
798 * @info: a #GstDiscovererVideoInfo
800 * Returns: the width of the video stream in pixels.
803 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
806 * gst_discoverer_video_info_get_height:
807 * @info: a #GstDiscovererVideoInfo
809 * Returns: the height of the video stream in pixels.
812 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
815 * gst_discoverer_video_info_get_depth:
816 * @info: a #GstDiscovererVideoInfo
818 * Returns: the depth in bits of the video stream.
821 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
824 * gst_discoverer_video_info_get_framerate_num:
825 * @info: a #GstDiscovererVideoInfo
827 * Returns: the framerate of the video stream (numerator).
830 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
833 * gst_discoverer_video_info_get_framerate_denom:
834 * @info: a #GstDiscovererVideoInfo
836 * Returns: the framerate of the video stream (denominator).
839 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
842 * gst_discoverer_video_info_get_par_num:
843 * @info: a #GstDiscovererVideoInfo
845 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
848 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
851 * gst_discoverer_video_info_get_par_denom:
852 * @info: a #GstDiscovererVideoInfo
854 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
857 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
860 * gst_discoverer_video_info_is_interlaced:
861 * @info: a #GstDiscovererVideoInfo
863 * Returns: %TRUE if the stream is interlaced, else %FALSE.
866 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
868 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
870 return info->interlaced;
874 * gst_discoverer_video_info_get_bitrate:
875 * @info: a #GstDiscovererVideoInfo
877 * Returns: the average or nominal bitrate of the video stream in bits/second.
880 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
883 * gst_discoverer_video_info_get_max_bitrate:
884 * @info: a #GstDiscovererVideoInfo
886 * Returns: the maximum bitrate of the video stream in bits/second.
889 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
892 * gst_discoverer_video_info_is_image:
893 * @info: a #GstDiscovererVideoInfo
895 * Returns: #TRUE if the video stream corresponds to an image (i.e. only contains
899 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
901 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
903 return info->is_image;
906 /* GstDiscovererSubtitleInfo */
908 #define SUBTITLE_INFO_ACCESSOR_CODE(fieldname, type, failval) \
909 GENERIC_ACCESSOR_CODE(gst_discoverer_subtitle_info, GstDiscovererSubtitleInfo*, \
910 GST_TYPE_DISCOVERER_SUBTITLE_INFO, \
911 fieldname, type, failval)
914 * gst_discoverer_subtitle_info_get_language:
915 * @info: a #GstDiscovererSubtitleInfo
917 * Returns: the language of the stream, or NULL if unknown.
920 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
922 /* GstDiscovererInfo */
924 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval) \
925 GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*, \
926 GST_TYPE_DISCOVERER_INFO, \
927 fieldname, type, failval)
930 * gst_discoverer_info_get_uri:
931 * @info: a #GstDiscovererInfo
933 * Returns: (transfer none): the URI to which this information corresponds to.
934 * Copy it if you wish to use it after the life-time of @info.
937 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
940 * gst_discoverer_info_get_result:
941 * @info: a #GstDiscovererInfo
943 * Returns: the result of the discovery as a #GstDiscovererResult.
946 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
949 * gst_discoverer_info_get_stream_info:
950 * @info: a #GstDiscovererInfo
952 * Returns: (transfer full): the structure (or topology) of the URI as a
953 * #GstDiscovererStreamInfo.
954 * This structure can be traversed to see the original hierarchy. Unref with
955 * gst_discoverer_stream_info_unref() after usage.
958 GstDiscovererStreamInfo *
959 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
961 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
963 if (info->stream_info)
964 return gst_discoverer_stream_info_ref (info->stream_info);
969 * gst_discoverer_info_get_stream_list:
970 * @info: a #GstDiscovererInfo
972 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
973 * all streams contained in the #info. Free after usage
974 * with gst_discoverer_stream_info_list_free().
977 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
979 GList *res = NULL, *tmp;
981 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
983 for (tmp = info->stream_list; tmp; tmp = tmp->next)
986 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
992 * gst_discoverer_info_get_duration:
993 * @info: a #GstDiscovererInfo
995 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
998 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1001 * gst_discoverer_info_get_seekable:
1002 * @info: a #GstDiscovererInfo
1004 * Returns: the whether the URI is seekable.
1007 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1010 * gst_discoverer_info_get_misc:
1011 * @info: a #GstDiscovererInfo
1013 * Returns: (transfer none): Miscellaneous information stored as a #GstStructure
1014 * (for example: information about missing plugins). If you wish to use the
1015 * #GstStructure after the life-time of @info, you will need to copy it.
1018 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1021 * gst_discoverer_info_get_tags:
1022 * @info: a #GstDiscovererInfo
1024 * Returns: (transfer none): all tags contained in the URI. If you wish to use
1025 * the tags after the life-time of @info, you will need to copy them.
1028 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1031 * gst_discoverer_info_get_toc:
1032 * @info: a #GstDiscovererInfo
1034 * Returns: (transfer none): TOC contained in the URI. If you wish to use
1035 * the TOC after the life-time of @info, you will need to copy it.
1038 DISCOVERER_INFO_ACCESSOR_CODE (toc, const GstToc *, NULL);
1041 * gst_discoverer_info_ref:
1042 * @info: a #GstDiscovererInfo
1044 * Increments the reference count of @info.
1046 * Returns: the same #GstDiscovererInfo object
1050 * gst_discoverer_info_unref:
1051 * @info: a #GstDiscovererInfo
1053 * Decrements the reference count of @info.
1057 * gst_discoverer_stream_info_ref:
1058 * @info: a #GstDiscovererStreamInfo
1060 * Increments the reference count of @info.
1062 * Returns: the same #GstDiscovererStreamInfo object
1066 * gst_discoverer_stream_info_unref:
1067 * @info: a #GstDiscovererStreamInfo
1069 * Decrements the reference count of @info.