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_toc_free (info->toc);
74 gst_structure_free (info->misc);
78 gst_discoverer_stream_info_class_init (GObjectClass * klass)
80 klass->finalize = gst_discoverer_stream_info_finalize;
83 static GstDiscovererStreamInfo *
84 gst_discoverer_stream_info_new (void)
86 return (GstDiscovererStreamInfo *)
87 g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
90 static GstDiscovererStreamInfo *
91 gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
92 GHashTable * stream_map)
94 GstDiscovererStreamInfo *ret;
97 g_return_val_if_fail (info != NULL, NULL);
99 ltyp = G_TYPE_FROM_INSTANCE (info);
101 if (ltyp == GST_TYPE_DISCOVERER_CONTAINER_INFO) {
102 ret = (GstDiscovererStreamInfo *)
103 gst_stream_container_info_copy_int (
104 (GstDiscovererContainerInfo *) info, stream_map);
105 } else if (ltyp == GST_TYPE_DISCOVERER_AUDIO_INFO) {
106 ret = (GstDiscovererStreamInfo *)
107 gst_discoverer_audio_info_copy_int ((GstDiscovererAudioInfo *) info);
109 } else if (ltyp == GST_TYPE_DISCOVERER_VIDEO_INFO) {
110 ret = (GstDiscovererStreamInfo *)
111 gst_discoverer_video_info_copy_int ((GstDiscovererVideoInfo *) info);
113 } else if (ltyp == GST_TYPE_DISCOVERER_SUBTITLE_INFO) {
114 ret = (GstDiscovererStreamInfo *)
115 gst_discoverer_subtitle_info_copy_int ((GstDiscovererSubtitleInfo *)
119 ret = gst_discoverer_stream_info_new ();
122 ret->next = gst_discoverer_info_copy_int (info->next, stream_map);
123 ret->next->previous = ret;
127 ret->caps = gst_caps_copy (info->caps);
130 ret->tags = gst_tag_list_copy (info->tags);
133 ret->toc = gst_toc_copy (info->toc);
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 g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
162 gst_discoverer_container_info_finalize (GObject * object)
164 GstDiscovererContainerInfo *info = (GstDiscovererContainerInfo *) object;
167 for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
169 g_object_unref ((GObject *) tmp->data);
171 gst_discoverer_stream_info_list_free (info->streams);
173 gst_discoverer_stream_info_finalize ((GObject *) info);
177 gst_discoverer_container_info_class_init (GObjectClass * klass)
179 klass->finalize = 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 (GObject * object)
212 GstDiscovererAudioInfo *info = (GstDiscovererAudioInfo *) object;
214 g_free (info->language);
216 G_OBJECT_CLASS (gst_discoverer_audio_info_parent_class)->finalize (object);
220 gst_discoverer_audio_info_class_init (GObjectClass * klass)
222 klass->finalize = gst_discoverer_audio_info_finalize;
226 gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
228 info->language = NULL;
231 static GstDiscovererAudioInfo *
232 gst_discoverer_audio_info_new (void)
234 return (GstDiscovererAudioInfo *)
235 g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
238 static GstDiscovererAudioInfo *
239 gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
241 GstDiscovererAudioInfo *ret;
243 ret = gst_discoverer_audio_info_new ();
245 ret->channels = ptr->channels;
246 ret->sample_rate = ptr->sample_rate;
247 ret->depth = ptr->depth;
248 ret->bitrate = ptr->bitrate;
249 ret->max_bitrate = ptr->max_bitrate;
250 ret->language = g_strdup (ptr->language);
255 /* Subtitle information */
256 G_DEFINE_TYPE (GstDiscovererSubtitleInfo, gst_discoverer_subtitle_info,
257 GST_TYPE_DISCOVERER_STREAM_INFO);
260 gst_discoverer_subtitle_info_init (GstDiscovererSubtitleInfo * info)
262 info->language = NULL;
266 gst_discoverer_subtitle_info_finalize (GObject * object)
268 GstDiscovererSubtitleInfo *info = (GstDiscovererSubtitleInfo *) object;
270 g_free (info->language);
272 G_OBJECT_CLASS (gst_discoverer_subtitle_info_parent_class)->finalize (object);
276 gst_discoverer_subtitle_info_class_init (GObjectClass * klass)
278 klass->finalize = gst_discoverer_subtitle_info_finalize;
281 static GstDiscovererSubtitleInfo *
282 gst_discoverer_subtitle_info_new (void)
284 return (GstDiscovererSubtitleInfo *)
285 g_object_new (GST_TYPE_DISCOVERER_SUBTITLE_INFO, NULL);
288 static GstDiscovererSubtitleInfo *
289 gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr)
291 GstDiscovererSubtitleInfo *ret;
293 ret = gst_discoverer_subtitle_info_new ();
295 ret->language = g_strdup (ptr->language);
300 /* Video information */
301 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
302 GST_TYPE_DISCOVERER_STREAM_INFO);
305 gst_discoverer_video_info_class_init (GObjectClass * klass)
307 /* Nothing to initialize */
311 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
313 /* Nothing to initialize */
316 static GstDiscovererVideoInfo *
317 gst_discoverer_video_info_new (void)
319 return (GstDiscovererVideoInfo *)
320 g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
323 static GstDiscovererVideoInfo *
324 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
326 GstDiscovererVideoInfo *ret;
328 ret = gst_discoverer_video_info_new ();
330 ret->width = ptr->width;
331 ret->height = ptr->height;
332 ret->depth = ptr->depth;
333 ret->framerate_num = ptr->framerate_num;
334 ret->framerate_denom = ptr->framerate_denom;
335 ret->par_num = ptr->par_num;
336 ret->par_denom = ptr->par_denom;
337 ret->interlaced = ptr->interlaced;
338 ret->bitrate = ptr->bitrate;
339 ret->max_bitrate = ptr->max_bitrate;
340 ret->is_image = ptr->is_image;
345 /* Global stream information */
346 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
349 gst_discoverer_info_init (GstDiscovererInfo * info)
351 /* Nothing needs initialization */
355 gst_discoverer_info_finalize (GObject * object)
357 GstDiscovererInfo *info = (GstDiscovererInfo *) object;
360 if (info->stream_info)
361 g_object_unref ((GObject *) info->stream_info);
364 gst_structure_free (info->misc);
366 g_list_free (info->stream_list);
369 gst_tag_list_free (info->tags);
372 gst_toc_free (info->toc);
375 static GstDiscovererInfo *
376 gst_discoverer_info_new (void)
378 return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
382 * gst_discoverer_info_copy:
383 * @ptr: (transfer none): a #GstDiscovererInfo
385 * Returns: (transfer full): A copy of the #GstDiscovererInfo
388 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
390 GstDiscovererInfo *ret;
391 GHashTable *stream_map;
394 g_return_val_if_fail (ptr != NULL, NULL);
396 stream_map = g_hash_table_new (g_direct_hash, NULL);
398 ret = gst_discoverer_info_new ();
400 ret->uri = g_strdup (ptr->uri);
401 if (ptr->stream_info) {
402 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
405 ret->duration = ptr->duration;
407 ret->misc = gst_structure_copy (ptr->misc);
409 /* We need to set up the new list of streams to correspond to old one. The
410 * list just contains a set of pointers to streams in the stream_info tree,
411 * so we keep a map of old stream info objects to the corresponding new
412 * ones and use that to figure out correspondence in stream_list. */
413 for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
414 GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
415 GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
417 g_assert (new_stream != NULL);
418 ret->stream_list = g_list_append (ret->stream_list, new_stream);
422 ret->tags = gst_tag_list_copy (ptr->tags);
425 ret->toc = gst_toc_copy (ptr->toc);
427 g_hash_table_destroy (stream_map);
432 gst_discoverer_info_class_init (GObjectClass * klass)
434 klass->finalize = gst_discoverer_info_finalize;
438 * gst_discoverer_stream_info_list_free:
439 * @infos: (element-type GstPbutils.DiscovererStreamInfo): a #GList of #GstDiscovererStreamInfo
441 * Decrements the reference count of all contained #GstDiscovererStreamInfo
442 * and fress the #GList.
445 gst_discoverer_stream_info_list_free (GList * infos)
449 for (tmp = infos; tmp; tmp = tmp->next)
450 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
455 * gst_discoverer_info_get_streams:
456 * @info: a #GstDiscovererInfo
457 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
459 * Finds the #GstDiscovererStreamInfo contained in @info that match the
462 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
463 * matching #GstDiscovererStreamInfo. The caller should free it with
464 * gst_discoverer_stream_info_list_free().
469 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
471 GList *tmp, *res = NULL;
473 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
474 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
476 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
477 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
484 * gst_discoverer_info_get_audio_streams:
485 * @info: a #GstDiscovererInfo
487 * Finds all the #GstDiscovererAudioInfo contained in @info
489 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
490 * matching #GstDiscovererStreamInfo. The caller should free it with
491 * gst_discoverer_stream_info_list_free().
496 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
498 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
502 * gst_discoverer_info_get_video_streams:
503 * @info: a #GstDiscovererInfo
505 * Finds all the #GstDiscovererVideoInfo contained in @info
507 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
508 * matching #GstDiscovererStreamInfo. The caller should free it with
509 * gst_discoverer_stream_info_list_free().
514 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
516 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
520 * gst_discoverer_info_get_subtitle_streams:
521 * @info: a #GstDiscovererInfo
523 * Finds all the #GstDiscovererSubtitleInfo contained in @info
525 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
526 * matching #GstDiscovererStreamInfo. The caller should free it with
527 * gst_discoverer_stream_info_list_free().
532 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
534 return gst_discoverer_info_get_streams (info,
535 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
539 * gst_discoverer_info_get_container_streams:
540 * @info: a #GstDiscovererInfo
542 * Finds all the #GstDiscovererContainerInfo contained in @info
544 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
545 * matching #GstDiscovererStreamInfo. The caller should free it with
546 * gst_discoverer_stream_info_list_free().
551 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
553 return gst_discoverer_info_get_streams (info,
554 GST_TYPE_DISCOVERER_CONTAINER_INFO);
558 * gst_discoverer_stream_info_get_stream_type_nick:
559 * @info: a #GstDiscovererStreamInfo
561 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
567 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
569 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
571 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
573 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
574 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
576 return "video(image)";
580 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
588 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
589 type parent##_get_##fieldname(const parenttype info) { \
590 g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
591 return (info)->fieldname; \
595 * gst_discoverer_stream_info_get_previous:
596 * @info: a #GstDiscovererStreamInfo
598 * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
599 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
604 GstDiscovererStreamInfo *
605 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
607 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
610 return gst_discoverer_stream_info_ref (info->previous);
615 * gst_discoverer_stream_info_get_next:
616 * @info: a #GstDiscovererStreamInfo
618 * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
620 * Unref with #gst_discoverer_stream_info_unref after usage.
624 GstDiscovererStreamInfo *
625 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
627 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
630 return gst_discoverer_stream_info_ref (info->next);
636 * gst_discoverer_stream_info_get_caps:
637 * @info: a #GstDiscovererStreamInfo
639 * Returns: (transfer full): the #GstCaps of the stream. Unref with
640 * #gst_caps_unref after usage.
645 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
647 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
650 return gst_caps_ref (info->caps);
655 * gst_discoverer_stream_info_get_tags:
656 * @info: a #GstDiscovererStreamInfo
658 * Returns: (transfer none): the tags contained in this stream. If you wish to
659 * use the tags after the life-time of @info you will need to copy them.
664 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
666 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
672 * gst_discoverer_stream_info_get_toc:
673 * @info: a #GstDiscovererStreamInfo
675 * Returns: (transfer none): the TOC contained in this stream. If you wish to
676 * use the TOC after the life-time of @info you will need to copy it.
681 gst_discoverer_stream_info_get_toc (GstDiscovererStreamInfo * info)
683 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
689 * gst_discoverer_stream_info_get_misc:
690 * @info: a #GstDiscovererStreamInfo
692 * Returns: (transfer none): additional information regarding the stream (for
693 * example codec version, profile, etc..). If you wish to use the #GstStructure
694 * after the life-time of @info you will need to copy it.
699 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
701 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
706 /* GstDiscovererContainerInfo */
709 * gst_discoverer_container_info_get_streams:
710 * @info: a #GstDiscovererStreamInfo
712 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
713 * #GstDiscovererStreamInfo this container stream offers.
714 * Free with gst_discoverer_stream_info_list_free() after usage.
720 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
722 GList *res = NULL, *tmp;
724 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
726 for (tmp = info->streams; tmp; tmp = tmp->next)
729 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
734 /* GstDiscovererAudioInfo */
736 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
737 GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
738 GST_TYPE_DISCOVERER_AUDIO_INFO, \
739 fieldname, type, failval)
742 * gst_discoverer_audio_info_get_channels:
743 * @info: a #GstDiscovererAudioInfo
745 * Returns: the number of channels in the stream.
750 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
753 * gst_discoverer_audio_info_get_sample_rate:
754 * @info: a #GstDiscovererAudioInfo
756 * Returns: the sample rate of the stream in Hertz.
761 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
764 * gst_discoverer_audio_info_get_depth:
765 * @info: a #GstDiscovererAudioInfo
767 * Returns: the number of bits used per sample in each channel.
772 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
775 * gst_discoverer_audio_info_get_bitrate:
776 * @info: a #GstDiscovererAudioInfo
778 * Returns: the average or nominal bitrate of the stream in bits/second.
783 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
786 * gst_discoverer_audio_info_get_max_bitrate:
787 * @info: a #GstDiscovererAudioInfo
789 * Returns: the maximum bitrate of the stream in bits/second.
794 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
797 * gst_discoverer_audio_info_get_language:
798 * @info: a #GstDiscovererAudioInfo
800 * Returns: the language of the stream, or NULL if unknown.
805 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
807 /* GstDiscovererVideoInfo */
809 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
810 GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
811 GST_TYPE_DISCOVERER_VIDEO_INFO, \
812 fieldname, type, failval)
815 * gst_discoverer_video_info_get_width:
816 * @info: a #GstDiscovererVideoInfo
818 * Returns: the width of the video stream in pixels.
823 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
826 * gst_discoverer_video_info_get_height:
827 * @info: a #GstDiscovererVideoInfo
829 * Returns: the height of the video stream in pixels.
834 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
837 * gst_discoverer_video_info_get_depth:
838 * @info: a #GstDiscovererVideoInfo
840 * Returns: the depth in bits of the video stream.
845 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
848 * gst_discoverer_video_info_get_framerate_num:
849 * @info: a #GstDiscovererVideoInfo
851 * Returns: the framerate of the video stream (numerator).
856 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
859 * gst_discoverer_video_info_get_framerate_denom:
860 * @info: a #GstDiscovererVideoInfo
862 * Returns: the framerate of the video stream (denominator).
867 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
870 * gst_discoverer_video_info_get_par_num:
871 * @info: a #GstDiscovererVideoInfo
873 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
878 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
881 * gst_discoverer_video_info_get_par_denom:
882 * @info: a #GstDiscovererVideoInfo
884 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
889 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
892 * gst_discoverer_video_info_is_interlaced:
893 * @info: a #GstDiscovererVideoInfo
895 * Returns: %TRUE if the stream is interlaced, else %FALSE.
900 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
902 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
904 return info->interlaced;
908 * gst_discoverer_video_info_get_bitrate:
909 * @info: a #GstDiscovererVideoInfo
911 * Returns: the average or nominal bitrate of the video stream in bits/second.
916 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
919 * gst_discoverer_video_info_get_max_bitrate:
920 * @info: a #GstDiscovererVideoInfo
922 * Returns: the maximum bitrate of the video stream in bits/second.
927 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
930 * gst_discoverer_video_info_is_image:
931 * @info: a #GstDiscovererVideoInfo
933 * Returns: #TRUE if the video stream corresponds to an image (i.e. only contains
939 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
941 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
943 return info->is_image;
946 /* GstDiscovererSubtitleInfo */
948 #define SUBTITLE_INFO_ACCESSOR_CODE(fieldname, type, failval) \
949 GENERIC_ACCESSOR_CODE(gst_discoverer_subtitle_info, GstDiscovererSubtitleInfo*, \
950 GST_TYPE_DISCOVERER_SUBTITLE_INFO, \
951 fieldname, type, failval)
954 * gst_discoverer_subtitle_info_get_language:
955 * @info: a #GstDiscovererSubtitleInfo
957 * Returns: the language of the stream, or NULL if unknown.
962 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
964 /* GstDiscovererInfo */
966 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval) \
967 GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*, \
968 GST_TYPE_DISCOVERER_INFO, \
969 fieldname, type, failval)
972 * gst_discoverer_info_get_uri:
973 * @info: a #GstDiscovererInfo
975 * Returns: (transfer none): the URI to which this information corresponds to.
976 * Copy it if you wish to use it after the life-time of @info.
981 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
984 * gst_discoverer_info_get_result:
985 * @info: a #GstDiscovererInfo
987 * Returns: the result of the discovery as a #GstDiscovererResult.
992 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
995 * gst_discoverer_info_get_stream_info:
996 * @info: a #GstDiscovererInfo
998 * Returns: (transfer full): the structure (or topology) of the URI as a
999 * #GstDiscovererStreamInfo.
1000 * This structure can be traversed to see the original hierarchy. Unref with
1001 * gst_discoverer_stream_info_unref() after usage.
1006 GstDiscovererStreamInfo *
1007 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
1009 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1011 if (info->stream_info)
1012 return gst_discoverer_stream_info_ref (info->stream_info);
1017 * gst_discoverer_info_get_stream_list:
1018 * @info: a #GstDiscovererInfo
1020 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
1021 * all streams contained in the #info. Free after usage
1022 * with gst_discoverer_stream_info_list_free().
1027 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
1029 GList *res = NULL, *tmp;
1031 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1033 for (tmp = info->stream_list; tmp; tmp = tmp->next)
1036 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
1042 * gst_discoverer_info_get_duration:
1043 * @info: a #GstDiscovererInfo
1045 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
1050 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1053 * gst_discoverer_info_get_seekable:
1054 * @info: a #GstDiscovererInfo
1056 * Returns: the whether the URI is seekable.
1061 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1064 * gst_discoverer_info_get_misc:
1065 * @info: a #GstDiscovererInfo
1067 * Returns: (transfer none): Miscellaneous information stored as a #GstStructure
1068 * (for example: information about missing plugins). If you wish to use the
1069 * #GstStructure after the life-time of @info, you will need to copy it.
1074 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1077 * gst_discoverer_info_get_tags:
1078 * @info: a #GstDiscovererInfo
1080 * Returns: (transfer none): all tags contained in the URI. If you wish to use
1081 * the tags after the life-time of @info, you will need to copy them.
1086 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1089 * gst_discoverer_info_get_toc:
1090 * @info: a #GstDiscovererInfo
1092 * Returns: (transfer none): TOC contained in the URI. If you wish to use
1093 * the TOC after the life-time of @info, you will need to copy it.
1098 DISCOVERER_INFO_ACCESSOR_CODE (toc, const GstToc *, NULL);
1101 * gst_discoverer_info_ref:
1102 * @info: a #GstDiscovererInfo
1104 * Increments the reference count of @info.
1106 * Returns: the same #GstDiscovererInfo object
1112 * gst_discoverer_info_unref:
1113 * @info: a #GstDiscovererInfo
1115 * Decrements the reference count of @info.
1121 * gst_discoverer_stream_info_ref:
1122 * @info: a #GstDiscovererStreamInfo
1124 * Increments the reference count of @info.
1126 * Returns: the same #GstDiscovererStreamInfo object
1132 * gst_discoverer_stream_info_unref:
1133 * @info: a #GstDiscovererStreamInfo
1135 * Decrements the reference count of @info.