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,
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_free (info->tags);
71 gst_structure_free (info->misc);
75 gst_discoverer_stream_info_class_init (GObjectClass * klass)
77 klass->finalize = gst_discoverer_stream_info_finalize;
80 static GstDiscovererStreamInfo *
81 gst_discoverer_stream_info_new (void)
83 return (GstDiscovererStreamInfo *)
84 g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
87 static GstDiscovererStreamInfo *
88 gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
89 GHashTable * stream_map)
91 GstDiscovererStreamInfo *ret;
94 g_return_val_if_fail (info != NULL, NULL);
96 ltyp = G_TYPE_FROM_INSTANCE (info);
98 if (ltyp == GST_TYPE_DISCOVERER_CONTAINER_INFO) {
99 ret = (GstDiscovererStreamInfo *)
100 gst_stream_container_info_copy_int (
101 (GstDiscovererContainerInfo *) info, stream_map);
102 } else if (ltyp == GST_TYPE_DISCOVERER_AUDIO_INFO) {
103 ret = (GstDiscovererStreamInfo *)
104 gst_discoverer_audio_info_copy_int ((GstDiscovererAudioInfo *) info);
106 } else if (ltyp == GST_TYPE_DISCOVERER_VIDEO_INFO) {
107 ret = (GstDiscovererStreamInfo *)
108 gst_discoverer_video_info_copy_int ((GstDiscovererVideoInfo *) info);
110 } else if (ltyp == GST_TYPE_DISCOVERER_SUBTITLE_INFO) {
111 ret = (GstDiscovererStreamInfo *)
112 gst_discoverer_subtitle_info_copy_int ((GstDiscovererSubtitleInfo *)
116 ret = gst_discoverer_stream_info_new ();
119 ret->next = gst_discoverer_info_copy_int (info->next, stream_map);
120 ret->next->previous = ret;
124 ret->caps = gst_caps_copy (info->caps);
127 ret->tags = gst_tag_list_copy (info->tags);
130 ret->misc = gst_structure_copy (info->misc);
133 g_hash_table_insert (stream_map, info, ret);
138 /* Container information */
139 G_DEFINE_TYPE (GstDiscovererContainerInfo, gst_discoverer_container_info,
140 GST_TYPE_DISCOVERER_STREAM_INFO);
143 gst_discoverer_container_info_init (GstDiscovererContainerInfo * info)
145 /* Nothing to initialize */
148 static GstDiscovererContainerInfo *
149 gst_discoverer_container_info_new (void)
151 return (GstDiscovererContainerInfo *)
152 g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
156 gst_discoverer_container_info_finalize (GObject * object)
158 GstDiscovererContainerInfo *info = (GstDiscovererContainerInfo *) object;
161 for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
163 g_object_unref ((GObject *) tmp->data);
165 gst_discoverer_stream_info_list_free (info->streams);
167 gst_discoverer_stream_info_finalize ((GObject *) info);
171 gst_discoverer_container_info_class_init (GObjectClass * klass)
173 klass->finalize = gst_discoverer_container_info_finalize;
176 static GstDiscovererContainerInfo *
177 gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
178 GHashTable * stream_map)
180 GstDiscovererContainerInfo *ret;
183 g_return_val_if_fail (ptr != NULL, NULL);
185 ret = gst_discoverer_container_info_new ();
187 for (tmp = ((GstDiscovererContainerInfo *) ptr)->streams; tmp;
189 GstDiscovererStreamInfo *subtop = gst_discoverer_info_copy_int (tmp->data,
191 ret->streams = g_list_append (ret->streams, subtop);
193 g_hash_table_insert (stream_map, tmp->data, subtop);
199 /* Audio information */
200 G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
201 GST_TYPE_DISCOVERER_STREAM_INFO);
204 gst_discoverer_audio_info_finalize (GObject * object)
206 GstDiscovererAudioInfo *info = (GstDiscovererAudioInfo *) object;
208 g_free (info->language);
210 G_OBJECT_CLASS (gst_discoverer_audio_info_parent_class)->finalize (object);
214 gst_discoverer_audio_info_class_init (GObjectClass * klass)
216 klass->finalize = gst_discoverer_audio_info_finalize;
220 gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
222 info->language = NULL;
225 static GstDiscovererAudioInfo *
226 gst_discoverer_audio_info_new (void)
228 return (GstDiscovererAudioInfo *)
229 g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
232 static GstDiscovererAudioInfo *
233 gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
235 GstDiscovererAudioInfo *ret;
237 ret = gst_discoverer_audio_info_new ();
239 ret->channels = ptr->channels;
240 ret->sample_rate = ptr->sample_rate;
241 ret->depth = ptr->depth;
242 ret->bitrate = ptr->bitrate;
243 ret->max_bitrate = ptr->max_bitrate;
244 ret->language = g_strdup (ptr->language);
249 /* Subtitle information */
250 G_DEFINE_TYPE (GstDiscovererSubtitleInfo, gst_discoverer_subtitle_info,
251 GST_TYPE_DISCOVERER_STREAM_INFO);
254 gst_discoverer_subtitle_info_init (GstDiscovererSubtitleInfo * info)
256 info->language = NULL;
260 gst_discoverer_subtitle_info_finalize (GObject * object)
262 GstDiscovererSubtitleInfo *info = (GstDiscovererSubtitleInfo *) object;
264 g_free (info->language);
266 G_OBJECT_CLASS (gst_discoverer_subtitle_info_parent_class)->finalize (object);
270 gst_discoverer_subtitle_info_class_init (GObjectClass * klass)
272 klass->finalize = gst_discoverer_subtitle_info_finalize;
275 static GstDiscovererSubtitleInfo *
276 gst_discoverer_subtitle_info_new (void)
278 return (GstDiscovererSubtitleInfo *)
279 g_object_new (GST_TYPE_DISCOVERER_SUBTITLE_INFO, NULL);
282 static GstDiscovererSubtitleInfo *
283 gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr)
285 GstDiscovererSubtitleInfo *ret;
287 ret = gst_discoverer_subtitle_info_new ();
289 ret->language = g_strdup (ptr->language);
294 /* Video information */
295 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
296 GST_TYPE_DISCOVERER_STREAM_INFO);
299 gst_discoverer_video_info_class_init (GObjectClass * klass)
301 /* Nothing to initialize */
305 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
307 /* Nothing to initialize */
310 static GstDiscovererVideoInfo *
311 gst_discoverer_video_info_new (void)
313 return (GstDiscovererVideoInfo *)
314 g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
317 static GstDiscovererVideoInfo *
318 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
320 GstDiscovererVideoInfo *ret;
322 ret = gst_discoverer_video_info_new ();
324 ret->width = ptr->width;
325 ret->height = ptr->height;
326 ret->depth = ptr->depth;
327 ret->framerate_num = ptr->framerate_num;
328 ret->framerate_denom = ptr->framerate_denom;
329 ret->par_num = ptr->par_num;
330 ret->par_denom = ptr->par_denom;
331 ret->interlaced = ptr->interlaced;
332 ret->bitrate = ptr->bitrate;
333 ret->max_bitrate = ptr->max_bitrate;
334 ret->is_image = ptr->is_image;
339 /* Global stream information */
340 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
343 gst_discoverer_info_init (GstDiscovererInfo * info)
345 /* Nothing needs initialization */
349 gst_discoverer_info_finalize (GObject * object)
351 GstDiscovererInfo *info = (GstDiscovererInfo *) object;
354 if (info->stream_info)
355 g_object_unref ((GObject *) info->stream_info);
358 gst_structure_free (info->misc);
360 g_list_free (info->stream_list);
363 gst_tag_list_free (info->tags);
366 static GstDiscovererInfo *
367 gst_discoverer_info_new (void)
369 return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
373 * gst_discoverer_info_copy:
374 * @ptr: (transfer none): a #GstDiscovererInfo
376 * Returns: (transfer full): A copy of the #GstDiscovererInfo
379 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
381 GstDiscovererInfo *ret;
382 GHashTable *stream_map;
385 g_return_val_if_fail (ptr != NULL, NULL);
387 stream_map = g_hash_table_new (g_direct_hash, NULL);
389 ret = gst_discoverer_info_new ();
391 ret->uri = g_strdup (ptr->uri);
392 if (ptr->stream_info) {
393 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
396 ret->duration = ptr->duration;
398 ret->misc = gst_structure_copy (ptr->misc);
400 /* We need to set up the new list of streams to correspond to old one. The
401 * list just contains a set of pointers to streams in the stream_info tree,
402 * so we keep a map of old stream info objects to the corresponding new
403 * ones and use that to figure out correspondence in stream_list. */
404 for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
405 GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
406 GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
408 g_assert (new_stream != NULL);
409 ret->stream_list = g_list_append (ret->stream_list, new_stream);
413 ret->tags = gst_tag_list_copy (ptr->tags);
415 g_hash_table_destroy (stream_map);
420 gst_discoverer_info_class_init (GObjectClass * klass)
422 klass->finalize = gst_discoverer_info_finalize;
426 * gst_discoverer_stream_info_list_free:
427 * @infos: (element-type GstPbutils.DiscovererStreamInfo): a #GList of #GstDiscovererStreamInfo
429 * Decrements the reference count of all contained #GstDiscovererStreamInfo
430 * and fress the #GList.
433 gst_discoverer_stream_info_list_free (GList * infos)
437 for (tmp = infos; tmp; tmp = tmp->next)
438 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
443 * gst_discoverer_info_get_streams:
444 * @info: a #GstDiscovererInfo
445 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
447 * Finds the #GstDiscovererStreamInfo contained in @info that match the
450 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
451 * matching #GstDiscovererStreamInfo. The caller should free it with
452 * gst_discoverer_stream_info_list_free().
457 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
459 GList *tmp, *res = NULL;
461 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
462 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
464 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
465 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
472 * gst_discoverer_info_get_audio_streams:
473 * @info: a #GstDiscovererInfo
475 * Finds all the #GstDiscovererAudioInfo contained in @info
477 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
478 * matching #GstDiscovererStreamInfo. The caller should free it with
479 * gst_discoverer_stream_info_list_free().
484 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
486 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
490 * gst_discoverer_info_get_video_streams:
491 * @info: a #GstDiscovererInfo
493 * Finds all the #GstDiscovererVideoInfo contained in @info
495 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
496 * matching #GstDiscovererStreamInfo. The caller should free it with
497 * gst_discoverer_stream_info_list_free().
502 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
504 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
508 * gst_discoverer_info_get_subtitle_streams:
509 * @info: a #GstDiscovererInfo
511 * Finds all the #GstDiscovererSubtitleInfo contained in @info
513 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
514 * matching #GstDiscovererStreamInfo. The caller should free it with
515 * gst_discoverer_stream_info_list_free().
520 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
522 return gst_discoverer_info_get_streams (info,
523 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
527 * gst_discoverer_info_get_container_streams:
528 * @info: a #GstDiscovererInfo
530 * Finds all the #GstDiscovererContainerInfo contained in @info
532 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
533 * matching #GstDiscovererStreamInfo. The caller should free it with
534 * gst_discoverer_stream_info_list_free().
539 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
541 return gst_discoverer_info_get_streams (info,
542 GST_TYPE_DISCOVERER_CONTAINER_INFO);
546 * gst_discoverer_stream_info_get_stream_type_nick:
547 * @info: a #GstDiscovererStreamInfo
549 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
555 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
557 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
559 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
561 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
562 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
564 return "video(image)";
568 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
576 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
577 type parent##_get_##fieldname(const parenttype info) { \
578 g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
579 return (info)->fieldname; \
583 * gst_discoverer_stream_info_get_previous:
584 * @info: a #GstDiscovererStreamInfo
586 * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
587 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
592 GstDiscovererStreamInfo *
593 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
595 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
598 return gst_discoverer_stream_info_ref (info->previous);
603 * gst_discoverer_stream_info_get_next:
604 * @info: a #GstDiscovererStreamInfo
606 * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
608 * Unref with #gst_discoverer_stream_info_unref after usage.
612 GstDiscovererStreamInfo *
613 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
615 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
618 return gst_discoverer_stream_info_ref (info->next);
624 * gst_discoverer_stream_info_get_caps:
625 * @info: a #GstDiscovererStreamInfo
627 * Returns: (transfer full): the #GstCaps of the stream. Unref with
628 * #gst_caps_unref after usage.
633 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
635 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
638 return gst_caps_ref (info->caps);
643 * gst_discoverer_stream_info_get_tags:
644 * @info: a #GstDiscovererStreamInfo
646 * Returns: (transfer none): the tags contained in this stream. If you wish to
647 * use the tags after the life-time of @info you will need to copy them.
653 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
655 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
661 * gst_discoverer_stream_info_get_misc:
662 * @info: a #GstDiscovererStreamInfo
664 * Returns: (transfer none): additional information regarding the stream (for
665 * example codec version, profile, etc..). If you wish to use the #GstStructure
666 * after the life-time of @info you will need to copy it.
671 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
673 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
678 /* GstDiscovererContainerInfo */
681 * gst_discoverer_container_info_get_streams:
682 * @info: a #GstDiscovererStreamInfo
684 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
685 * #GstDiscovererStreamInfo this container stream offers.
686 * Free with gst_discoverer_stream_info_list_free() after usage.
692 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
694 GList *res = NULL, *tmp;
696 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
698 for (tmp = info->streams; tmp; tmp = tmp->next)
701 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
706 /* GstDiscovererAudioInfo */
708 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
709 GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
710 GST_TYPE_DISCOVERER_AUDIO_INFO, \
711 fieldname, type, failval)
714 * gst_discoverer_audio_info_get_channels:
715 * @info: a #GstDiscovererAudioInfo
717 * Returns: the number of channels in the stream.
722 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
725 * gst_discoverer_audio_info_get_sample_rate:
726 * @info: a #GstDiscovererAudioInfo
728 * Returns: the sample rate of the stream in Hertz.
733 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
736 * gst_discoverer_audio_info_get_depth:
737 * @info: a #GstDiscovererAudioInfo
739 * Returns: the number of bits used per sample in each channel.
744 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
747 * gst_discoverer_audio_info_get_bitrate:
748 * @info: a #GstDiscovererAudioInfo
750 * Returns: the average or nominal bitrate of the stream in bits/second.
755 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
758 * gst_discoverer_audio_info_get_max_bitrate:
759 * @info: a #GstDiscovererAudioInfo
761 * Returns: the maximum bitrate of the stream in bits/second.
766 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
769 * gst_discoverer_audio_info_get_language:
770 * @info: a #GstDiscovererAudioInfo
772 * Returns: the language of the stream, or NULL if unknown.
777 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
779 /* GstDiscovererVideoInfo */
781 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
782 GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
783 GST_TYPE_DISCOVERER_VIDEO_INFO, \
784 fieldname, type, failval)
787 * gst_discoverer_video_info_get_width:
788 * @info: a #GstDiscovererVideoInfo
790 * Returns: the width of the video stream in pixels.
795 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
798 * gst_discoverer_video_info_get_height:
799 * @info: a #GstDiscovererVideoInfo
801 * Returns: the height of the video stream in pixels.
806 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
809 * gst_discoverer_video_info_get_depth:
810 * @info: a #GstDiscovererVideoInfo
812 * Returns: the depth in bits of the video stream.
817 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
820 * gst_discoverer_video_info_get_framerate_num:
821 * @info: a #GstDiscovererVideoInfo
823 * Returns: the framerate of the video stream (numerator).
828 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
831 * gst_discoverer_video_info_get_framerate_denom:
832 * @info: a #GstDiscovererVideoInfo
834 * 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).
850 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
853 * gst_discoverer_video_info_get_par_denom:
854 * @info: a #GstDiscovererVideoInfo
856 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
861 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
864 * gst_discoverer_video_info_is_interlaced:
865 * @info: a #GstDiscovererVideoInfo
867 * Returns: %TRUE if the stream is interlaced, else %FALSE.
872 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
874 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
876 return info->interlaced;
880 * gst_discoverer_video_info_get_bitrate:
881 * @info: a #GstDiscovererVideoInfo
883 * Returns: the average or nominal bitrate of the video stream in bits/second.
888 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
891 * gst_discoverer_video_info_get_max_bitrate:
892 * @info: a #GstDiscovererVideoInfo
894 * Returns: the maximum bitrate of the video stream in bits/second.
899 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
902 * gst_discoverer_video_info_is_image:
903 * @info: a #GstDiscovererVideoInfo
905 * Returns: #TRUE if the video stream corresponds to an image (i.e. only contains
911 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
913 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
915 return info->is_image;
918 /* GstDiscovererSubtitleInfo */
920 #define SUBTITLE_INFO_ACCESSOR_CODE(fieldname, type, failval) \
921 GENERIC_ACCESSOR_CODE(gst_discoverer_subtitle_info, GstDiscovererSubtitleInfo*, \
922 GST_TYPE_DISCOVERER_SUBTITLE_INFO, \
923 fieldname, type, failval)
926 * gst_discoverer_subtitle_info_get_language:
927 * @info: a #GstDiscovererSubtitleInfo
929 * Returns: the language of the stream, or NULL if unknown.
934 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
936 /* GstDiscovererInfo */
938 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval) \
939 GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*, \
940 GST_TYPE_DISCOVERER_INFO, \
941 fieldname, type, failval)
944 * gst_discoverer_info_get_uri:
945 * @info: a #GstDiscovererInfo
947 * Returns: (transfer none): the URI to which this information corresponds to.
948 * Copy it if you wish to use it after the life-time of @info.
953 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
956 * gst_discoverer_info_get_result:
957 * @info: a #GstDiscovererInfo
959 * Returns: the result of the discovery as a #GstDiscovererResult.
964 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
967 * gst_discoverer_info_get_stream_info:
968 * @info: a #GstDiscovererInfo
970 * Returns: (transfer full): the structure (or topology) of the URI as a
971 * #GstDiscovererStreamInfo.
972 * This structure can be traversed to see the original hierarchy. Unref with
973 * gst_discoverer_stream_info_unref() after usage.
978 GstDiscovererStreamInfo *
979 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
981 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
983 if (info->stream_info)
984 return gst_discoverer_stream_info_ref (info->stream_info);
989 * gst_discoverer_info_get_stream_list:
990 * @info: a #GstDiscovererInfo
992 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
993 * all streams contained in the #info. Free after usage
994 * with gst_discoverer_stream_info_list_free().
999 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
1001 GList *res = NULL, *tmp;
1003 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1005 for (tmp = info->stream_list; tmp; tmp = tmp->next)
1008 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
1014 * gst_discoverer_info_get_duration:
1015 * @info: a #GstDiscovererInfo
1017 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
1022 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1025 * gst_discoverer_info_get_seekable:
1026 * @info: a #GstDiscovererInfo
1028 * Returns: the whether the URI is seekable.
1033 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1036 * gst_discoverer_info_get_misc:
1037 * @info: a #GstDiscovererInfo
1039 * Returns: (transfer none): Miscellaneous information stored as a #GstStructure
1040 * (for example: information about missing plugins). If you wish to use the
1041 * #GstStructure after the life-time of @info, you will need to copy it.
1046 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1049 * gst_discoverer_info_get_tags:
1050 * @info: a #GstDiscovererInfo
1052 * Returns: (transfer none): all tags contained in the URI. If you wish to use
1053 * the tags after the life-time of @info, you will need to copy them.
1058 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1061 * gst_discoverer_info_ref:
1062 * @info: a #GstDiscovererInfo
1064 * Increments the reference count of @info.
1066 * Returns: the same #GstDiscovererInfo object
1072 * gst_discoverer_info_unref:
1073 * @info: a #GstDiscovererInfo
1075 * Decrements the reference count of @info.
1081 * gst_discoverer_stream_info_ref:
1082 * @info: a #GstDiscovererStreamInfo
1084 * Increments the reference count of @info.
1086 * Returns: the same #GstDiscovererStreamInfo object
1092 * gst_discoverer_stream_info_unref:
1093 * @info: a #GstDiscovererStreamInfo
1095 * Decrements the reference count of @info.