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 info->missing_elements_details = g_ptr_array_new_with_free_func (g_free);
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);
379 g_ptr_array_unref (info->missing_elements_details);
382 static GstDiscovererInfo *
383 gst_discoverer_info_new (void)
385 return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
389 * gst_discoverer_info_copy:
390 * @ptr: (transfer none): a #GstDiscovererInfo
392 * Returns: (transfer full): A copy of the #GstDiscovererInfo
395 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
397 GstDiscovererInfo *ret;
398 GHashTable *stream_map;
401 g_return_val_if_fail (ptr != NULL, NULL);
403 stream_map = g_hash_table_new (g_direct_hash, NULL);
405 ret = gst_discoverer_info_new ();
407 ret->uri = g_strdup (ptr->uri);
408 if (ptr->stream_info) {
409 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
412 ret->duration = ptr->duration;
414 ret->misc = gst_structure_copy (ptr->misc);
416 /* We need to set up the new list of streams to correspond to old one. The
417 * list just contains a set of pointers to streams in the stream_info tree,
418 * so we keep a map of old stream info objects to the corresponding new
419 * ones and use that to figure out correspondence in stream_list. */
420 for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
421 GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
422 GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
424 g_assert (new_stream != NULL);
425 ret->stream_list = g_list_append (ret->stream_list, new_stream);
429 ret->tags = gst_tag_list_copy (ptr->tags);
432 ret->toc = gst_toc_ref (ptr->toc);
434 g_hash_table_destroy (stream_map);
439 gst_discoverer_info_class_init (GObjectClass * klass)
441 klass->finalize = gst_discoverer_info_finalize;
445 * gst_discoverer_stream_info_list_free:
446 * @infos: (element-type GstPbutils.DiscovererStreamInfo): a #GList of #GstDiscovererStreamInfo
448 * Decrements the reference count of all contained #GstDiscovererStreamInfo
449 * and fress the #GList.
452 gst_discoverer_stream_info_list_free (GList * infos)
456 for (tmp = infos; tmp; tmp = tmp->next)
457 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
462 * gst_discoverer_info_get_streams:
463 * @info: a #GstDiscovererInfo
464 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
466 * Finds the #GstDiscovererStreamInfo contained in @info that match the
469 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
470 * matching #GstDiscovererStreamInfo. The caller should free it with
471 * gst_discoverer_stream_info_list_free().
474 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
476 GList *tmp, *res = NULL;
478 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
479 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
481 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
482 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
489 * gst_discoverer_info_get_audio_streams:
490 * @info: a #GstDiscovererInfo
492 * Finds all the #GstDiscovererAudioInfo contained in @info
494 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
495 * matching #GstDiscovererStreamInfo. The caller should free it with
496 * gst_discoverer_stream_info_list_free().
499 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
501 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
505 * gst_discoverer_info_get_video_streams:
506 * @info: a #GstDiscovererInfo
508 * Finds all the #GstDiscovererVideoInfo contained in @info
510 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
511 * matching #GstDiscovererStreamInfo. The caller should free it with
512 * gst_discoverer_stream_info_list_free().
515 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
517 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
521 * gst_discoverer_info_get_subtitle_streams:
522 * @info: a #GstDiscovererInfo
524 * Finds all the #GstDiscovererSubtitleInfo contained in @info
526 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
527 * matching #GstDiscovererStreamInfo. The caller should free it with
528 * gst_discoverer_stream_info_list_free().
531 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
533 return gst_discoverer_info_get_streams (info,
534 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
538 * gst_discoverer_info_get_container_streams:
539 * @info: a #GstDiscovererInfo
541 * Finds all the #GstDiscovererContainerInfo contained in @info
543 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
544 * matching #GstDiscovererStreamInfo. The caller should free it with
545 * gst_discoverer_stream_info_list_free().
548 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
550 return gst_discoverer_info_get_streams (info,
551 GST_TYPE_DISCOVERER_CONTAINER_INFO);
555 * gst_discoverer_stream_info_get_stream_type_nick:
556 * @info: a #GstDiscovererStreamInfo
558 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
562 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
564 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
566 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
568 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
569 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
571 return "video(image)";
575 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
583 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
584 type parent##_get_##fieldname(const parenttype info) { \
585 g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
586 return (info)->fieldname; \
590 * gst_discoverer_stream_info_get_previous:
591 * @info: a #GstDiscovererStreamInfo
593 * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
594 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
597 GstDiscovererStreamInfo *
598 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
600 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
603 return gst_discoverer_stream_info_ref (info->previous);
608 * gst_discoverer_stream_info_get_next:
609 * @info: a #GstDiscovererStreamInfo
611 * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
613 * Unref with #gst_discoverer_stream_info_unref after usage.
615 GstDiscovererStreamInfo *
616 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
618 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
621 return gst_discoverer_stream_info_ref (info->next);
627 * gst_discoverer_stream_info_get_caps:
628 * @info: a #GstDiscovererStreamInfo
630 * Returns: (transfer full): the #GstCaps of the stream. Unref with
631 * #gst_caps_unref after usage.
634 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
636 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
639 return gst_caps_ref (info->caps);
644 * gst_discoverer_stream_info_get_tags:
645 * @info: a #GstDiscovererStreamInfo
647 * Returns: (transfer none): the tags contained in this stream. If you wish to
648 * use the tags after the life-time of @info you will need to copy them.
651 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
653 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
659 * gst_discoverer_stream_info_get_toc:
660 * @info: a #GstDiscovererStreamInfo
662 * Returns: (transfer none): the TOC contained in this stream. If you wish to
663 * use the TOC after the life-time of @info you will need to copy it.
666 gst_discoverer_stream_info_get_toc (GstDiscovererStreamInfo * info)
668 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
674 * gst_discoverer_stream_info_get_stream_id:
675 * @info: a #GstDiscovererStreamInfo
677 * Returns: (transfer none): the stream ID of this stream. If you wish to
678 * use the stream ID after the life-time of @info you will need to copy it.
681 gst_discoverer_stream_info_get_stream_id (GstDiscovererStreamInfo * info)
683 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
685 return info->stream_id;
689 * gst_discoverer_stream_info_get_misc:
690 * @info: a #GstDiscovererStreamInfo
692 * Deprecated: This functions is deprecated since version 1.4, use
693 * gst_discoverer_stream_get_missing_elements_installer_details
695 * Returns: (transfer none): additional information regarding the stream (for
696 * example codec version, profile, etc..). If you wish to use the #GstStructure
697 * after the life-time of @info you will need to copy it.
700 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
702 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
707 /* GstDiscovererContainerInfo */
710 * gst_discoverer_container_info_get_streams:
711 * @info: a #GstDiscovererStreamInfo
713 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
714 * #GstDiscovererStreamInfo this container stream offers.
715 * Free with gst_discoverer_stream_info_list_free() after usage.
719 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
721 GList *res = NULL, *tmp;
723 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
725 for (tmp = info->streams; tmp; tmp = tmp->next)
728 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
733 /* GstDiscovererAudioInfo */
735 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
736 GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
737 GST_TYPE_DISCOVERER_AUDIO_INFO, \
738 fieldname, type, failval)
741 * gst_discoverer_audio_info_get_channels:
742 * @info: a #GstDiscovererAudioInfo
744 * Returns: the number of channels in the stream.
747 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
750 * gst_discoverer_audio_info_get_sample_rate:
751 * @info: a #GstDiscovererAudioInfo
753 * Returns: the sample rate of the stream in Hertz.
756 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
759 * gst_discoverer_audio_info_get_depth:
760 * @info: a #GstDiscovererAudioInfo
762 * Returns: the number of bits used per sample in each channel.
765 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
768 * gst_discoverer_audio_info_get_bitrate:
769 * @info: a #GstDiscovererAudioInfo
771 * Returns: the average or nominal bitrate of the stream in bits/second.
774 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
777 * gst_discoverer_audio_info_get_max_bitrate:
778 * @info: a #GstDiscovererAudioInfo
780 * Returns: the maximum bitrate of the stream in bits/second.
783 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
786 * gst_discoverer_audio_info_get_language:
787 * @info: a #GstDiscovererAudioInfo
789 * Returns: the language of the stream, or NULL if unknown.
792 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
794 /* GstDiscovererVideoInfo */
796 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
797 GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
798 GST_TYPE_DISCOVERER_VIDEO_INFO, \
799 fieldname, type, failval)
802 * gst_discoverer_video_info_get_width:
803 * @info: a #GstDiscovererVideoInfo
805 * Returns: the width of the video stream in pixels.
808 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
811 * gst_discoverer_video_info_get_height:
812 * @info: a #GstDiscovererVideoInfo
814 * Returns: the height of the video stream in pixels.
817 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
820 * gst_discoverer_video_info_get_depth:
821 * @info: a #GstDiscovererVideoInfo
823 * Returns: the depth in bits of the video stream.
826 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
829 * gst_discoverer_video_info_get_framerate_num:
830 * @info: a #GstDiscovererVideoInfo
832 * Returns: the framerate of the video stream (numerator).
835 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
838 * gst_discoverer_video_info_get_framerate_denom:
839 * @info: a #GstDiscovererVideoInfo
841 * Returns: the framerate of the video stream (denominator).
844 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
847 * gst_discoverer_video_info_get_par_num:
848 * @info: a #GstDiscovererVideoInfo
850 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
853 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
856 * gst_discoverer_video_info_get_par_denom:
857 * @info: a #GstDiscovererVideoInfo
859 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
862 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
865 * gst_discoverer_video_info_is_interlaced:
866 * @info: a #GstDiscovererVideoInfo
868 * Returns: %TRUE if the stream is interlaced, else %FALSE.
871 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
873 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
875 return info->interlaced;
879 * gst_discoverer_video_info_get_bitrate:
880 * @info: a #GstDiscovererVideoInfo
882 * 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.
894 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
897 * gst_discoverer_video_info_is_image:
898 * @info: a #GstDiscovererVideoInfo
900 * Returns: #TRUE if the video stream corresponds to an image (i.e. only contains
904 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
906 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
908 return info->is_image;
911 /* GstDiscovererSubtitleInfo */
913 #define SUBTITLE_INFO_ACCESSOR_CODE(fieldname, type, failval) \
914 GENERIC_ACCESSOR_CODE(gst_discoverer_subtitle_info, GstDiscovererSubtitleInfo*, \
915 GST_TYPE_DISCOVERER_SUBTITLE_INFO, \
916 fieldname, type, failval)
919 * gst_discoverer_subtitle_info_get_language:
920 * @info: a #GstDiscovererSubtitleInfo
922 * Returns: the language of the stream, or NULL if unknown.
925 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
927 /* GstDiscovererInfo */
929 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval) \
930 GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*, \
931 GST_TYPE_DISCOVERER_INFO, \
932 fieldname, type, failval)
935 * gst_discoverer_info_get_uri:
936 * @info: a #GstDiscovererInfo
938 * Returns: (transfer none): the URI to which this information corresponds to.
939 * Copy it if you wish to use it after the life-time of @info.
942 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
945 * gst_discoverer_info_get_result:
946 * @info: a #GstDiscovererInfo
948 * Returns: the result of the discovery as a #GstDiscovererResult.
951 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
954 * gst_discoverer_info_get_stream_info:
955 * @info: a #GstDiscovererInfo
957 * Returns: (transfer full): the structure (or topology) of the URI as a
958 * #GstDiscovererStreamInfo.
959 * This structure can be traversed to see the original hierarchy. Unref with
960 * gst_discoverer_stream_info_unref() after usage.
963 GstDiscovererStreamInfo *
964 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
966 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
968 if (info->stream_info)
969 return gst_discoverer_stream_info_ref (info->stream_info);
974 * gst_discoverer_info_get_stream_list:
975 * @info: a #GstDiscovererInfo
977 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
978 * all streams contained in the #info. Free after usage
979 * with gst_discoverer_stream_info_list_free().
982 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
984 GList *res = NULL, *tmp;
986 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
988 for (tmp = info->stream_list; tmp; tmp = tmp->next)
991 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
997 * gst_discoverer_info_get_duration:
998 * @info: a #GstDiscovererInfo
1000 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
1003 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1006 * gst_discoverer_info_get_seekable:
1007 * @info: a #GstDiscovererInfo
1009 * Returns: the whether the URI is seekable.
1012 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1015 * gst_discoverer_info_get_misc:
1016 * @info: a #GstDiscovererInfo
1018 * Deprecated: This functions is deprecated since version 1.4, use
1019 * gst_discoverer_info_get_missing_elements_installer_details
1021 * Returns: (transfer none): Miscellaneous information stored as a #GstStructure
1022 * (for example: information about missing plugins). If you wish to use the
1023 * #GstStructure after the life-time of @info, you will need to copy it.
1026 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1029 * gst_discoverer_info_get_tags:
1030 * @info: a #GstDiscovererInfo
1032 * Returns: (transfer none): all tags contained in the URI. If you wish to use
1033 * the tags after the life-time of @info, you will need to copy them.
1036 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1039 * gst_discoverer_info_get_toc:
1040 * @info: a #GstDiscovererInfo
1042 * Returns: (transfer none): TOC contained in the URI. If you wish to use
1043 * the TOC after the life-time of @info, you will need to copy it.
1046 DISCOVERER_INFO_ACCESSOR_CODE (toc, const GstToc *, NULL);
1049 * gst_discoverer_info_ref:
1050 * @info: a #GstDiscovererInfo
1052 * Increments the reference count of @info.
1054 * Returns: the same #GstDiscovererInfo object
1058 * gst_discoverer_info_unref:
1059 * @info: a #GstDiscovererInfo
1061 * Decrements the reference count of @info.
1065 * gst_discoverer_stream_info_ref:
1066 * @info: a #GstDiscovererStreamInfo
1068 * Increments the reference count of @info.
1070 * Returns: the same #GstDiscovererStreamInfo object
1074 * gst_discoverer_stream_info_unref:
1075 * @info: a #GstDiscovererStreamInfo
1077 * Decrements the reference count of @info.
1082 * gst_discoverer_info_get_missing_elements_installer_details:
1083 * @info: a #GstDiscovererStreamInfo to retrieve installer detail
1084 * for the missing element
1086 * Get the installer details for missing elements
1088 * Returns: (transfer full): (array zero-terminated=1): An array of strings
1089 * containing informations about how to install the various missing elements
1090 * for @info to be usable. Free with g_strfreev.
1095 gst_discoverer_info_get_missing_elements_installer_details (const
1096 GstDiscovererInfo * info)
1099 if (info->result != GST_DISCOVERER_MISSING_PLUGINS) {
1100 GST_WARNING_OBJECT (info, "Trying to get missing element installed details "
1101 "but result is not 'MISSING_PLUGINS'");
1106 if (info->missing_elements_details->pdata[info->missing_elements_details->
1108 GST_DEBUG ("Adding NULL pointer to the end of missing_elements_details");
1109 g_ptr_array_add (info->missing_elements_details, NULL);
1112 return (const gchar **) info->missing_elements_details->pdata;