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->channel_mask = ptr->channel_mask;
252 ret->sample_rate = ptr->sample_rate;
253 ret->depth = ptr->depth;
254 ret->bitrate = ptr->bitrate;
255 ret->max_bitrate = ptr->max_bitrate;
256 ret->language = g_strdup (ptr->language);
261 /* Subtitle information */
262 G_DEFINE_TYPE (GstDiscovererSubtitleInfo, gst_discoverer_subtitle_info,
263 GST_TYPE_DISCOVERER_STREAM_INFO);
266 gst_discoverer_subtitle_info_init (GstDiscovererSubtitleInfo * info)
268 info->language = NULL;
272 gst_discoverer_subtitle_info_finalize (GObject * object)
274 GstDiscovererSubtitleInfo *info = (GstDiscovererSubtitleInfo *) object;
276 g_free (info->language);
278 G_OBJECT_CLASS (gst_discoverer_subtitle_info_parent_class)->finalize (object);
282 gst_discoverer_subtitle_info_class_init (GObjectClass * klass)
284 klass->finalize = gst_discoverer_subtitle_info_finalize;
287 static GstDiscovererSubtitleInfo *
288 gst_discoverer_subtitle_info_new (void)
290 return (GstDiscovererSubtitleInfo *)
291 g_object_new (GST_TYPE_DISCOVERER_SUBTITLE_INFO, NULL);
294 static GstDiscovererSubtitleInfo *
295 gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr)
297 GstDiscovererSubtitleInfo *ret;
299 ret = gst_discoverer_subtitle_info_new ();
301 ret->language = g_strdup (ptr->language);
306 /* Video information */
307 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
308 GST_TYPE_DISCOVERER_STREAM_INFO);
311 gst_discoverer_video_info_class_init (GObjectClass * klass)
313 /* Nothing to initialize */
317 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
319 /* Nothing to initialize */
322 static GstDiscovererVideoInfo *
323 gst_discoverer_video_info_new (void)
325 return (GstDiscovererVideoInfo *)
326 g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
329 static GstDiscovererVideoInfo *
330 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
332 GstDiscovererVideoInfo *ret;
334 ret = gst_discoverer_video_info_new ();
336 ret->width = ptr->width;
337 ret->height = ptr->height;
338 ret->depth = ptr->depth;
339 ret->framerate_num = ptr->framerate_num;
340 ret->framerate_denom = ptr->framerate_denom;
341 ret->par_num = ptr->par_num;
342 ret->par_denom = ptr->par_denom;
343 ret->interlaced = ptr->interlaced;
344 ret->bitrate = ptr->bitrate;
345 ret->max_bitrate = ptr->max_bitrate;
346 ret->is_image = ptr->is_image;
351 /* Global stream information */
352 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
355 gst_discoverer_info_init (GstDiscovererInfo * info)
357 info->missing_elements_details = g_ptr_array_new_with_free_func (g_free);
361 gst_discoverer_info_finalize (GObject * object)
363 GstDiscovererInfo *info = (GstDiscovererInfo *) object;
366 if (info->stream_info)
367 g_object_unref ((GObject *) info->stream_info);
370 gst_structure_free (info->misc);
372 g_list_free (info->stream_list);
375 gst_tag_list_unref (info->tags);
378 gst_toc_unref (info->toc);
380 g_free (info->cachefile);
382 g_ptr_array_unref (info->missing_elements_details);
385 static GstDiscovererInfo *
386 gst_discoverer_info_new (void)
388 return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
392 * gst_discoverer_info_copy:
393 * @ptr: (transfer none): a #GstDiscovererInfo
395 * Returns: (transfer full): A copy of the #GstDiscovererInfo
398 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
400 GstDiscovererInfo *ret;
401 GHashTable *stream_map;
404 g_return_val_if_fail (ptr != NULL, NULL);
406 stream_map = g_hash_table_new (g_direct_hash, NULL);
408 ret = gst_discoverer_info_new ();
410 ret->uri = g_strdup (ptr->uri);
411 if (ptr->stream_info) {
412 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
415 ret->duration = ptr->duration;
416 ret->result = ptr->result;
417 ret->seekable = ptr->seekable;
418 ret->live = ptr->live;
420 ret->misc = gst_structure_copy (ptr->misc);
422 /* We need to set up the new list of streams to correspond to old one. The
423 * list just contains a set of pointers to streams in the stream_info tree,
424 * so we keep a map of old stream info objects to the corresponding new
425 * ones and use that to figure out correspondence in stream_list. */
426 for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
427 GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
428 GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
430 g_assert (new_stream != NULL);
431 ret->stream_list = g_list_append (ret->stream_list, new_stream);
435 ret->tags = gst_tag_list_copy (ptr->tags);
438 ret->toc = gst_toc_ref (ptr->toc);
440 g_hash_table_destroy (stream_map);
445 gst_discoverer_info_class_init (GObjectClass * klass)
447 klass->finalize = gst_discoverer_info_finalize;
451 * gst_discoverer_stream_info_list_free:
452 * @infos: (element-type GstPbutils.DiscovererStreamInfo): a #GList of #GstDiscovererStreamInfo
454 * Decrements the reference count of all contained #GstDiscovererStreamInfo
455 * and fress the #GList.
458 gst_discoverer_stream_info_list_free (GList * infos)
462 for (tmp = infos; tmp; tmp = tmp->next)
463 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
468 * gst_discoverer_info_get_streams:
469 * @info: a #GstDiscovererInfo
470 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
472 * Finds the #GstDiscovererStreamInfo contained in @info that match the
475 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
476 * matching #GstDiscovererStreamInfo. The caller should free it with
477 * gst_discoverer_stream_info_list_free().
480 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
482 GList *tmp, *res = NULL;
484 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
485 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
487 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
488 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
495 * gst_discoverer_info_get_audio_streams:
496 * @info: a #GstDiscovererInfo
498 * Finds all the #GstDiscovererAudioInfo contained in @info
500 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
501 * matching #GstDiscovererStreamInfo. The caller should free it with
502 * gst_discoverer_stream_info_list_free().
505 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
507 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
511 * gst_discoverer_info_get_video_streams:
512 * @info: a #GstDiscovererInfo
514 * Finds all the #GstDiscovererVideoInfo contained in @info
516 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
517 * matching #GstDiscovererStreamInfo. The caller should free it with
518 * gst_discoverer_stream_info_list_free().
521 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
523 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
527 * gst_discoverer_info_get_subtitle_streams:
528 * @info: a #GstDiscovererInfo
530 * Finds all the #GstDiscovererSubtitleInfo 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().
537 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
539 return gst_discoverer_info_get_streams (info,
540 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
544 * gst_discoverer_info_get_container_streams:
545 * @info: a #GstDiscovererInfo
547 * Finds all the #GstDiscovererContainerInfo contained in @info
549 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
550 * matching #GstDiscovererStreamInfo. The caller should free it with
551 * gst_discoverer_stream_info_list_free().
554 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
556 return gst_discoverer_info_get_streams (info,
557 GST_TYPE_DISCOVERER_CONTAINER_INFO);
561 * gst_discoverer_stream_info_get_stream_type_nick:
562 * @info: a #GstDiscovererStreamInfo
564 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
568 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
570 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
572 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
574 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
575 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
577 return "video(image)";
581 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
589 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
590 type parent##_get_##fieldname(const parenttype info) { \
591 g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
592 return (info)->fieldname; \
596 * gst_discoverer_stream_info_get_previous:
597 * @info: a #GstDiscovererStreamInfo
599 * Returns: (transfer full): the previous #GstDiscovererStreamInfo in a chain.
600 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
603 GstDiscovererStreamInfo *
604 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
606 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
609 return gst_discoverer_stream_info_ref (info->previous);
614 * gst_discoverer_stream_info_get_next:
615 * @info: a #GstDiscovererStreamInfo
617 * Returns: (transfer full): the next #GstDiscovererStreamInfo in a chain. %NULL
619 * Unref with #gst_discoverer_stream_info_unref after usage.
621 GstDiscovererStreamInfo *
622 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
624 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
627 return gst_discoverer_stream_info_ref (info->next);
633 * gst_discoverer_stream_info_get_caps:
634 * @info: a #GstDiscovererStreamInfo
636 * Returns: (transfer full): the #GstCaps of the stream. Unref with
637 * #gst_caps_unref after usage.
640 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
642 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
645 return gst_caps_ref (info->caps);
650 * gst_discoverer_stream_info_get_tags:
651 * @info: a #GstDiscovererStreamInfo
653 * Returns: (transfer none): the tags contained in this stream. If you wish to
654 * use the tags after the life-time of @info you will need to copy them.
657 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
659 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
665 * gst_discoverer_stream_info_get_toc:
666 * @info: a #GstDiscovererStreamInfo
668 * Returns: (transfer none): the TOC contained in this stream. If you wish to
669 * use the TOC after the life-time of @info you will need to copy it.
672 gst_discoverer_stream_info_get_toc (GstDiscovererStreamInfo * info)
674 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
680 * gst_discoverer_stream_info_get_stream_id:
681 * @info: a #GstDiscovererStreamInfo
683 * Returns: (transfer none): the stream ID of this stream. If you wish to
684 * use the stream ID after the life-time of @info you will need to copy it.
687 gst_discoverer_stream_info_get_stream_id (GstDiscovererStreamInfo * info)
689 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
691 return info->stream_id;
694 #ifndef GST_REMOVE_DEPRECATED
696 * gst_discoverer_stream_info_get_misc:
697 * @info: a #GstDiscovererStreamInfo
699 * Deprecated: This functions is deprecated since version 1.4, use
700 * #gst_discoverer_info_get_missing_elements_installer_details
702 * Returns: (transfer none): additional information regarding the stream (for
703 * example codec version, profile, etc..). If you wish to use the #GstStructure
704 * after the life-time of @info you will need to copy it.
707 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
709 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
715 /* GstDiscovererContainerInfo */
718 * gst_discoverer_container_info_get_streams:
719 * @info: a #GstDiscovererStreamInfo
721 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
722 * #GstDiscovererStreamInfo this container stream offers.
723 * Free with gst_discoverer_stream_info_list_free() after usage.
727 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
729 GList *res = NULL, *tmp;
731 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
733 for (tmp = info->streams; tmp; tmp = tmp->next)
736 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
741 /* GstDiscovererAudioInfo */
743 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
744 GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
745 GST_TYPE_DISCOVERER_AUDIO_INFO, \
746 fieldname, type, failval)
749 * gst_discoverer_audio_info_get_channels:
750 * @info: a #GstDiscovererAudioInfo
752 * Returns: the number of channels in the stream.
755 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
758 * gst_discoverer_audio_info_get_channel_mask:
759 * @info: a #GstDiscovererAudioInfo
761 * Returns: the channel-mask of the stream, refer to
762 * gst_audio_channel_positions_from_mask() for more
768 AUDIO_INFO_ACCESSOR_CODE (channel_mask, guint64, G_MAXUINT64);
771 * gst_discoverer_audio_info_get_sample_rate:
772 * @info: a #GstDiscovererAudioInfo
774 * Returns: the sample rate of the stream in Hertz.
777 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
780 * gst_discoverer_audio_info_get_depth:
781 * @info: a #GstDiscovererAudioInfo
783 * Returns: the number of bits used per sample in each channel.
786 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
789 * gst_discoverer_audio_info_get_bitrate:
790 * @info: a #GstDiscovererAudioInfo
792 * Returns: the average or nominal bitrate of the stream in bits/second.
795 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
798 * gst_discoverer_audio_info_get_max_bitrate:
799 * @info: a #GstDiscovererAudioInfo
801 * Returns: the maximum bitrate of the stream in bits/second.
804 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
807 * gst_discoverer_audio_info_get_language:
808 * @info: a #GstDiscovererAudioInfo
810 * Returns: the language of the stream, or NULL if unknown.
813 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
815 /* GstDiscovererVideoInfo */
817 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
818 GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
819 GST_TYPE_DISCOVERER_VIDEO_INFO, \
820 fieldname, type, failval)
823 * gst_discoverer_video_info_get_width:
824 * @info: a #GstDiscovererVideoInfo
826 * Returns: the width of the video stream in pixels.
829 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
832 * gst_discoverer_video_info_get_height:
833 * @info: a #GstDiscovererVideoInfo
835 * Returns: the height of the video stream in pixels.
838 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
841 * gst_discoverer_video_info_get_depth:
842 * @info: a #GstDiscovererVideoInfo
844 * Returns: the depth in bits of the video stream.
847 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
850 * gst_discoverer_video_info_get_framerate_num:
851 * @info: a #GstDiscovererVideoInfo
853 * 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).
865 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
868 * gst_discoverer_video_info_get_par_num:
869 * @info: a #GstDiscovererVideoInfo
871 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
874 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
877 * gst_discoverer_video_info_get_par_denom:
878 * @info: a #GstDiscovererVideoInfo
880 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
883 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
886 * gst_discoverer_video_info_is_interlaced:
887 * @info: a #GstDiscovererVideoInfo
889 * Returns: %TRUE if the stream is interlaced, else %FALSE.
892 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
894 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
896 return info->interlaced;
900 * gst_discoverer_video_info_get_bitrate:
901 * @info: a #GstDiscovererVideoInfo
903 * Returns: the average or nominal bitrate of the video stream in bits/second.
906 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
909 * gst_discoverer_video_info_get_max_bitrate:
910 * @info: a #GstDiscovererVideoInfo
912 * Returns: the maximum bitrate of the video stream in bits/second.
915 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
918 * gst_discoverer_video_info_is_image:
919 * @info: a #GstDiscovererVideoInfo
921 * Returns: %TRUE if the video stream corresponds to an image (i.e. only contains
925 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
927 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
929 return info->is_image;
932 /* GstDiscovererSubtitleInfo */
934 #define SUBTITLE_INFO_ACCESSOR_CODE(fieldname, type, failval) \
935 GENERIC_ACCESSOR_CODE(gst_discoverer_subtitle_info, GstDiscovererSubtitleInfo*, \
936 GST_TYPE_DISCOVERER_SUBTITLE_INFO, \
937 fieldname, type, failval)
940 * gst_discoverer_subtitle_info_get_language:
941 * @info: a #GstDiscovererSubtitleInfo
943 * Returns: the language of the stream, or NULL if unknown.
946 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
948 /* GstDiscovererInfo */
950 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval) \
951 GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*, \
952 GST_TYPE_DISCOVERER_INFO, \
953 fieldname, type, failval)
956 * gst_discoverer_info_get_uri:
957 * @info: a #GstDiscovererInfo
959 * Returns: (transfer none): the URI to which this information corresponds to.
960 * Copy it if you wish to use it after the life-time of @info.
963 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
966 * gst_discoverer_info_get_result:
967 * @info: a #GstDiscovererInfo
969 * Returns: the result of the discovery as a #GstDiscovererResult.
972 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
975 * gst_discoverer_info_get_stream_info:
976 * @info: a #GstDiscovererInfo
978 * Returns: (transfer full): the structure (or topology) of the URI as a
979 * #GstDiscovererStreamInfo.
980 * This structure can be traversed to see the original hierarchy. Unref with
981 * gst_discoverer_stream_info_unref() after usage.
984 GstDiscovererStreamInfo *
985 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
987 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
989 if (info->stream_info)
990 return gst_discoverer_stream_info_ref (info->stream_info);
995 * gst_discoverer_info_get_stream_list:
996 * @info: a #GstDiscovererInfo
998 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
999 * all streams contained in the #info. Free after usage
1000 * with gst_discoverer_stream_info_list_free().
1003 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
1005 GList *res = NULL, *tmp;
1007 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1009 for (tmp = info->stream_list; tmp; tmp = tmp->next)
1012 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
1018 * gst_discoverer_info_get_duration:
1019 * @info: a #GstDiscovererInfo
1021 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
1024 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1027 * gst_discoverer_info_get_seekable:
1028 * @info: a #GstDiscovererInfo
1030 * Returns: the whether the URI is seekable.
1033 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1036 * gst_discoverer_info_get_live:
1037 * @info: a #GstDiscovererInfo
1039 * Returns: whether the URI is live.
1044 DISCOVERER_INFO_ACCESSOR_CODE (live, gboolean, FALSE);
1046 #ifndef GST_REMOVE_DEPRECATED
1048 * gst_discoverer_info_get_misc:
1049 * @info: a #GstDiscovererInfo
1051 * Deprecated: This functions is deprecated since version 1.4, use
1052 * #gst_discoverer_info_get_missing_elements_installer_details
1054 * Returns: (transfer none): Miscellaneous information stored as a #GstStructure
1055 * (for example: information about missing plugins). If you wish to use the
1056 * #GstStructure after the life-time of @info, you will need to copy it.
1059 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1063 * gst_discoverer_info_get_tags:
1064 * @info: a #GstDiscovererInfo
1066 * Returns: (transfer none): all tags contained in the URI. If you wish to use
1067 * the tags after the life-time of @info, you will need to copy them.
1070 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1073 * gst_discoverer_info_get_toc:
1074 * @info: a #GstDiscovererInfo
1076 * Returns: (transfer none): TOC contained in the URI. If you wish to use
1077 * the TOC after the life-time of @info, you will need to copy it.
1080 DISCOVERER_INFO_ACCESSOR_CODE (toc, const GstToc *, NULL);
1083 * gst_discoverer_info_ref:
1084 * @info: a #GstDiscovererInfo
1086 * Increments the reference count of @info.
1088 * Returns: the same #GstDiscovererInfo object
1092 * gst_discoverer_info_unref:
1093 * @info: a #GstDiscovererInfo
1095 * Decrements the reference count of @info.
1099 * gst_discoverer_stream_info_ref:
1100 * @info: a #GstDiscovererStreamInfo
1102 * Increments the reference count of @info.
1104 * Returns: the same #GstDiscovererStreamInfo object
1108 * gst_discoverer_stream_info_unref:
1109 * @info: a #GstDiscovererStreamInfo
1111 * Decrements the reference count of @info.
1116 * gst_discoverer_info_get_missing_elements_installer_details:
1117 * @info: a #GstDiscovererStreamInfo to retrieve installer detail
1118 * for the missing element
1120 * Get the installer details for missing elements
1122 * Returns: (transfer none) (array zero-terminated=1): An array of strings
1123 * containing information about how to install the various missing elements
1124 * for @info to be usable. If you wish to use the strings after the life-time
1125 * of @info, you will need to copy them.
1130 gst_discoverer_info_get_missing_elements_installer_details (const
1131 GstDiscovererInfo * info)
1134 if (info->result != GST_DISCOVERER_MISSING_PLUGINS) {
1135 GST_WARNING_OBJECT (info, "Trying to get missing element installed details "
1136 "but result is not 'MISSING_PLUGINS'");
1141 if (info->missing_elements_details->pdata[info->missing_elements_details->
1143 GST_DEBUG ("Adding NULL pointer to the end of missing_elements_details");
1144 g_ptr_array_add (info->missing_elements_details, NULL);
1147 return (const gchar **) info->missing_elements_details->pdata;