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 info->stream_number = -1;
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);
78 G_OBJECT_CLASS (gst_discoverer_stream_info_parent_class)->finalize (object);
82 gst_discoverer_stream_info_class_init (GObjectClass * klass)
84 klass->finalize = gst_discoverer_stream_info_finalize;
87 static GstDiscovererStreamInfo *
88 gst_discoverer_stream_info_new (void)
90 return (GstDiscovererStreamInfo *)
91 g_object_new (GST_TYPE_DISCOVERER_STREAM_INFO, NULL);
94 static GstDiscovererStreamInfo *
95 gst_discoverer_info_copy_int (GstDiscovererStreamInfo * info,
96 GHashTable * stream_map)
98 GstDiscovererStreamInfo *ret;
101 g_return_val_if_fail (info != NULL, NULL);
103 ltyp = G_TYPE_FROM_INSTANCE (info);
105 if (ltyp == GST_TYPE_DISCOVERER_CONTAINER_INFO) {
106 ret = (GstDiscovererStreamInfo *)
107 gst_stream_container_info_copy_int (
108 (GstDiscovererContainerInfo *) info, stream_map);
109 } else if (ltyp == GST_TYPE_DISCOVERER_AUDIO_INFO) {
110 ret = (GstDiscovererStreamInfo *)
111 gst_discoverer_audio_info_copy_int ((GstDiscovererAudioInfo *) info);
113 } else if (ltyp == GST_TYPE_DISCOVERER_VIDEO_INFO) {
114 ret = (GstDiscovererStreamInfo *)
115 gst_discoverer_video_info_copy_int ((GstDiscovererVideoInfo *) info);
117 } else if (ltyp == GST_TYPE_DISCOVERER_SUBTITLE_INFO) {
118 ret = (GstDiscovererStreamInfo *)
119 gst_discoverer_subtitle_info_copy_int ((GstDiscovererSubtitleInfo *)
123 ret = gst_discoverer_stream_info_new ();
126 ret->next = gst_discoverer_info_copy_int (info->next, stream_map);
127 ret->next->previous = ret;
131 ret->caps = gst_caps_copy (info->caps);
134 ret->tags = gst_tag_list_copy (info->tags);
137 ret->toc = gst_toc_ref (info->toc);
140 ret->stream_id = g_strdup (info->stream_id);
143 ret->misc = gst_structure_copy (info->misc);
146 g_hash_table_insert (stream_map, info, ret);
148 ret->stream_number = info->stream_number;
153 /* Container information */
154 G_DEFINE_TYPE (GstDiscovererContainerInfo, gst_discoverer_container_info,
155 GST_TYPE_DISCOVERER_STREAM_INFO);
158 gst_discoverer_container_info_init (GstDiscovererContainerInfo * info)
160 /* Nothing to initialize */
163 static GstDiscovererContainerInfo *
164 gst_discoverer_container_info_new (void)
166 return (GstDiscovererContainerInfo *)
167 g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
171 gst_discoverer_container_info_finalize (GObject * object)
173 GstDiscovererContainerInfo *info = (GstDiscovererContainerInfo *) object;
176 for (tmp = ((GstDiscovererContainerInfo *) info)->streams; tmp;
178 g_object_unref ((GObject *) tmp->data);
180 gst_discoverer_stream_info_list_free (info->streams);
183 gst_tag_list_unref (info->tags);
185 G_OBJECT_CLASS (gst_discoverer_container_info_parent_class)->finalize
190 gst_discoverer_container_info_class_init (GObjectClass * klass)
192 klass->finalize = gst_discoverer_container_info_finalize;
195 static GstDiscovererContainerInfo *
196 gst_stream_container_info_copy_int (GstDiscovererContainerInfo * ptr,
197 GHashTable * stream_map)
199 GstDiscovererContainerInfo *ret;
202 g_return_val_if_fail (ptr != NULL, NULL);
204 ret = gst_discoverer_container_info_new ();
206 for (tmp = ((GstDiscovererContainerInfo *) ptr)->streams; tmp;
208 GstDiscovererStreamInfo *subtop = gst_discoverer_info_copy_int (tmp->data,
210 ret->streams = g_list_append (ret->streams, subtop);
212 g_hash_table_insert (stream_map, tmp->data, subtop);
216 ret->tags = gst_tag_list_copy (ptr->tags);
221 /* Audio information */
222 G_DEFINE_TYPE (GstDiscovererAudioInfo, gst_discoverer_audio_info,
223 GST_TYPE_DISCOVERER_STREAM_INFO);
226 gst_discoverer_audio_info_finalize (GObject * object)
228 GstDiscovererAudioInfo *info = (GstDiscovererAudioInfo *) object;
230 g_free (info->language);
232 G_OBJECT_CLASS (gst_discoverer_audio_info_parent_class)->finalize (object);
236 gst_discoverer_audio_info_class_init (GObjectClass * klass)
238 klass->finalize = gst_discoverer_audio_info_finalize;
242 gst_discoverer_audio_info_init (GstDiscovererAudioInfo * info)
244 info->language = NULL;
247 static GstDiscovererAudioInfo *
248 gst_discoverer_audio_info_new (void)
250 return (GstDiscovererAudioInfo *)
251 g_object_new (GST_TYPE_DISCOVERER_AUDIO_INFO, NULL);
254 static GstDiscovererAudioInfo *
255 gst_discoverer_audio_info_copy_int (GstDiscovererAudioInfo * ptr)
257 GstDiscovererAudioInfo *ret;
259 ret = gst_discoverer_audio_info_new ();
261 ret->channels = ptr->channels;
262 ret->channel_mask = ptr->channel_mask;
263 ret->sample_rate = ptr->sample_rate;
264 ret->depth = ptr->depth;
265 ret->bitrate = ptr->bitrate;
266 ret->max_bitrate = ptr->max_bitrate;
267 ret->language = g_strdup (ptr->language);
272 /* Subtitle information */
273 G_DEFINE_TYPE (GstDiscovererSubtitleInfo, gst_discoverer_subtitle_info,
274 GST_TYPE_DISCOVERER_STREAM_INFO);
277 gst_discoverer_subtitle_info_init (GstDiscovererSubtitleInfo * info)
279 info->language = NULL;
283 gst_discoverer_subtitle_info_finalize (GObject * object)
285 GstDiscovererSubtitleInfo *info = (GstDiscovererSubtitleInfo *) object;
287 g_free (info->language);
289 G_OBJECT_CLASS (gst_discoverer_subtitle_info_parent_class)->finalize (object);
293 gst_discoverer_subtitle_info_class_init (GObjectClass * klass)
295 klass->finalize = gst_discoverer_subtitle_info_finalize;
298 static GstDiscovererSubtitleInfo *
299 gst_discoverer_subtitle_info_new (void)
301 return (GstDiscovererSubtitleInfo *)
302 g_object_new (GST_TYPE_DISCOVERER_SUBTITLE_INFO, NULL);
305 static GstDiscovererSubtitleInfo *
306 gst_discoverer_subtitle_info_copy_int (GstDiscovererSubtitleInfo * ptr)
308 GstDiscovererSubtitleInfo *ret;
310 ret = gst_discoverer_subtitle_info_new ();
312 ret->language = g_strdup (ptr->language);
317 /* Video information */
318 G_DEFINE_TYPE (GstDiscovererVideoInfo, gst_discoverer_video_info,
319 GST_TYPE_DISCOVERER_STREAM_INFO);
322 gst_discoverer_video_info_class_init (GObjectClass * klass)
324 /* Nothing to initialize */
328 gst_discoverer_video_info_init (GstDiscovererVideoInfo * info)
330 /* Nothing to initialize */
333 static GstDiscovererVideoInfo *
334 gst_discoverer_video_info_new (void)
336 return (GstDiscovererVideoInfo *)
337 g_object_new (GST_TYPE_DISCOVERER_VIDEO_INFO, NULL);
340 static GstDiscovererVideoInfo *
341 gst_discoverer_video_info_copy_int (GstDiscovererVideoInfo * ptr)
343 GstDiscovererVideoInfo *ret;
345 ret = gst_discoverer_video_info_new ();
347 ret->width = ptr->width;
348 ret->height = ptr->height;
349 ret->depth = ptr->depth;
350 ret->framerate_num = ptr->framerate_num;
351 ret->framerate_denom = ptr->framerate_denom;
352 ret->par_num = ptr->par_num;
353 ret->par_denom = ptr->par_denom;
354 ret->interlaced = ptr->interlaced;
355 ret->bitrate = ptr->bitrate;
356 ret->max_bitrate = ptr->max_bitrate;
357 ret->is_image = ptr->is_image;
362 /* Global stream information */
363 G_DEFINE_TYPE (GstDiscovererInfo, gst_discoverer_info, G_TYPE_OBJECT);
366 gst_discoverer_info_init (GstDiscovererInfo * info)
368 info->missing_elements_details = g_ptr_array_new_with_free_func (g_free);
372 gst_discoverer_info_finalize (GObject * object)
374 GstDiscovererInfo *info = (GstDiscovererInfo *) object;
377 if (info->stream_info)
378 g_object_unref ((GObject *) info->stream_info);
381 gst_structure_free (info->misc);
383 g_list_free (info->stream_list);
386 gst_tag_list_unref (info->tags);
389 gst_toc_unref (info->toc);
391 g_free (info->cachefile);
393 g_ptr_array_unref (info->missing_elements_details);
395 G_OBJECT_CLASS (gst_discoverer_info_parent_class)->finalize (object);
398 static GstDiscovererInfo *
399 gst_discoverer_info_new (void)
401 return (GstDiscovererInfo *) g_object_new (GST_TYPE_DISCOVERER_INFO, NULL);
405 * gst_discoverer_info_copy:
406 * @ptr: (transfer none): a #GstDiscovererInfo
408 * Returns: (transfer full): A copy of the #GstDiscovererInfo
411 gst_discoverer_info_copy (GstDiscovererInfo * ptr)
413 GstDiscovererInfo *ret;
414 GHashTable *stream_map;
417 g_return_val_if_fail (ptr != NULL, NULL);
419 stream_map = g_hash_table_new (g_direct_hash, NULL);
421 ret = gst_discoverer_info_new ();
423 ret->uri = g_strdup (ptr->uri);
424 if (ptr->stream_info) {
425 ret->stream_info = gst_discoverer_info_copy_int (ptr->stream_info,
428 ret->duration = ptr->duration;
429 ret->result = ptr->result;
430 ret->seekable = ptr->seekable;
431 ret->live = ptr->live;
433 ret->misc = gst_structure_copy (ptr->misc);
435 /* We need to set up the new list of streams to correspond to old one. The
436 * list just contains a set of pointers to streams in the stream_info tree,
437 * so we keep a map of old stream info objects to the corresponding new
438 * ones and use that to figure out correspondence in stream_list. */
439 for (tmp = ptr->stream_list; tmp; tmp = tmp->next) {
440 GstDiscovererStreamInfo *old_stream = (GstDiscovererStreamInfo *) tmp->data;
441 GstDiscovererStreamInfo *new_stream = g_hash_table_lookup (stream_map,
443 g_assert (new_stream != NULL);
444 ret->stream_list = g_list_append (ret->stream_list, new_stream);
448 ret->tags = gst_tag_list_copy (ptr->tags);
451 ret->toc = gst_toc_ref (ptr->toc);
453 g_hash_table_destroy (stream_map);
458 gst_discoverer_info_class_init (GObjectClass * klass)
460 klass->finalize = gst_discoverer_info_finalize;
464 * gst_discoverer_stream_info_list_free:
465 * @infos: (element-type GstPbutils.DiscovererStreamInfo): a #GList of #GstDiscovererStreamInfo
467 * Decrements the reference count of all contained #GstDiscovererStreamInfo
468 * and fress the #GList.
471 gst_discoverer_stream_info_list_free (GList * infos)
475 for (tmp = infos; tmp; tmp = tmp->next)
476 gst_discoverer_stream_info_unref ((GstDiscovererStreamInfo *) tmp->data);
481 * gst_discoverer_info_get_streams:
482 * @info: a #GstDiscovererInfo
483 * @streamtype: a #GType derived from #GstDiscovererStreamInfo
485 * Finds the #GstDiscovererStreamInfo contained in @info that match the
488 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
489 * matching #GstDiscovererStreamInfo. The caller should free it with
490 * gst_discoverer_stream_info_list_free().
493 gst_discoverer_info_get_streams (GstDiscovererInfo * info, GType streamtype)
495 GList *tmp, *res = NULL;
497 for (tmp = info->stream_list; tmp; tmp = tmp->next) {
498 GstDiscovererStreamInfo *stmp = (GstDiscovererStreamInfo *) tmp->data;
500 if (G_TYPE_CHECK_INSTANCE_TYPE (stmp, streamtype))
501 res = g_list_append (res, gst_discoverer_stream_info_ref (stmp));
508 * gst_discoverer_info_get_audio_streams:
509 * @info: a #GstDiscovererInfo
511 * Finds all the #GstDiscovererAudioInfo 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().
518 gst_discoverer_info_get_audio_streams (GstDiscovererInfo * info)
520 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_AUDIO_INFO);
524 * gst_discoverer_info_get_video_streams:
525 * @info: a #GstDiscovererInfo
527 * Finds all the #GstDiscovererVideoInfo contained in @info
529 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
530 * matching #GstDiscovererStreamInfo. The caller should free it with
531 * gst_discoverer_stream_info_list_free().
534 gst_discoverer_info_get_video_streams (GstDiscovererInfo * info)
536 return gst_discoverer_info_get_streams (info, GST_TYPE_DISCOVERER_VIDEO_INFO);
540 * gst_discoverer_info_get_subtitle_streams:
541 * @info: a #GstDiscovererInfo
543 * Finds all the #GstDiscovererSubtitleInfo contained in @info
545 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
546 * matching #GstDiscovererStreamInfo. The caller should free it with
547 * gst_discoverer_stream_info_list_free().
550 gst_discoverer_info_get_subtitle_streams (GstDiscovererInfo * info)
552 return gst_discoverer_info_get_streams (info,
553 GST_TYPE_DISCOVERER_SUBTITLE_INFO);
557 * gst_discoverer_info_get_container_streams:
558 * @info: a #GstDiscovererInfo
560 * Finds all the #GstDiscovererContainerInfo contained in @info
562 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): A #GList of
563 * matching #GstDiscovererStreamInfo. The caller should free it with
564 * gst_discoverer_stream_info_list_free().
567 gst_discoverer_info_get_container_streams (GstDiscovererInfo * info)
569 return gst_discoverer_info_get_streams (info,
570 GST_TYPE_DISCOVERER_CONTAINER_INFO);
574 * gst_discoverer_stream_info_get_stream_type_nick:
575 * @info: a #GstDiscovererStreamInfo
577 * Returns: a human readable name for the stream type of the given @info (ex : "audio",
581 gst_discoverer_stream_info_get_stream_type_nick (GstDiscovererStreamInfo * info)
583 if (GST_IS_DISCOVERER_CONTAINER_INFO (info))
585 if (GST_IS_DISCOVERER_AUDIO_INFO (info))
587 if (GST_IS_DISCOVERER_VIDEO_INFO (info)) {
588 if (gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo *)
590 return "video(image)";
594 if (GST_IS_DISCOVERER_SUBTITLE_INFO (info))
602 #define GENERIC_ACCESSOR_CODE(parent, parenttype, parentgtype, fieldname, type, failval) \
603 type parent##_get_##fieldname(const parenttype info) { \
604 g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE((info), parentgtype), failval); \
605 return (info)->fieldname; \
609 * gst_discoverer_stream_info_get_previous:
610 * @info: a #GstDiscovererStreamInfo
612 * Returns: (transfer full) (nullable): the previous #GstDiscovererStreamInfo in a chain.
613 * %NULL for starting points. Unref with #gst_discoverer_stream_info_unref
616 GstDiscovererStreamInfo *
617 gst_discoverer_stream_info_get_previous (GstDiscovererStreamInfo * info)
619 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
622 return gst_discoverer_stream_info_ref (info->previous);
627 * gst_discoverer_stream_info_get_next:
628 * @info: a #GstDiscovererStreamInfo
630 * Returns: (transfer full) (nullable): the next #GstDiscovererStreamInfo in a chain. %NULL
632 * Unref with #gst_discoverer_stream_info_unref after usage.
634 GstDiscovererStreamInfo *
635 gst_discoverer_stream_info_get_next (GstDiscovererStreamInfo * info)
637 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
640 return gst_discoverer_stream_info_ref (info->next);
646 * gst_discoverer_stream_info_get_caps:
647 * @info: a #GstDiscovererStreamInfo
649 * Returns: (transfer full) (nullable): the #GstCaps of the stream. Unref with
650 * #gst_caps_unref after usage.
653 gst_discoverer_stream_info_get_caps (GstDiscovererStreamInfo * info)
655 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
658 return gst_caps_ref (info->caps);
663 * gst_discoverer_stream_info_get_tags:
664 * @info: a #GstDiscovererStreamInfo
666 * Returns: (transfer none) (nullable): the tags contained in this stream. If you wish to
667 * use the tags after the life-time of @info you will need to copy them.
670 gst_discoverer_stream_info_get_tags (GstDiscovererStreamInfo * info)
672 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
678 * gst_discoverer_stream_info_get_toc:
679 * @info: a #GstDiscovererStreamInfo
681 * Returns: (transfer none) (nullable): the TOC contained in this stream. If you wish to
682 * use the TOC after the life-time of @info you will need to copy it.
685 gst_discoverer_stream_info_get_toc (GstDiscovererStreamInfo * info)
687 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
693 * gst_discoverer_stream_info_get_stream_id:
694 * @info: a #GstDiscovererStreamInfo
696 * Returns: (transfer none): the stream ID of this stream. If you wish to
697 * use the stream ID after the life-time of @info you will need to copy it.
700 gst_discoverer_stream_info_get_stream_id (GstDiscovererStreamInfo * info)
702 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
704 return info->stream_id;
707 #ifndef GST_REMOVE_DEPRECATED
709 * gst_discoverer_stream_info_get_misc:
710 * @info: a #GstDiscovererStreamInfo
712 * Deprecated: This functions is deprecated since version 1.4, use
713 * #gst_discoverer_info_get_missing_elements_installer_details
715 * Returns: (transfer none) (nullable): additional information regarding the stream (for
716 * example codec version, profile, etc..). If you wish to use the #GstStructure
717 * after the life-time of @info you will need to copy it.
720 gst_discoverer_stream_info_get_misc (GstDiscovererStreamInfo * info)
722 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), NULL);
729 * gst_discoverer_stream_info_get_stream_number:
730 * @info: a #GstDiscovererStreamInfo
732 * Returns: the stream number, -1 if no index could be determined. This property
733 * acts as a unique identifier as a 'int' for the stream.
738 gst_discoverer_stream_info_get_stream_number (GstDiscovererStreamInfo * info)
740 g_return_val_if_fail (GST_IS_DISCOVERER_STREAM_INFO (info), -1);
742 return info->stream_number;
745 /* GstDiscovererContainerInfo */
748 * gst_discoverer_container_info_get_streams:
749 * @info: a #GstDiscovererStreamInfo
751 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
752 * #GstDiscovererStreamInfo this container stream offers.
753 * Free with gst_discoverer_stream_info_list_free() after usage.
757 gst_discoverer_container_info_get_streams (GstDiscovererContainerInfo * info)
759 GList *res = NULL, *tmp;
761 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
763 for (tmp = info->streams; tmp; tmp = tmp->next)
766 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
772 * gst_discoverer_container_info_get_tags:
773 * @info: a #GstDiscovererStreamInfo
775 * Returns: (transfer none) (nullable): tags specific to the given container. If you wish to use
776 * the tags after the life-time of @info, you will need to copy them.
781 gst_discoverer_container_info_get_tags (const GstDiscovererContainerInfo * info)
783 g_return_val_if_fail (GST_IS_DISCOVERER_CONTAINER_INFO (info), NULL);
788 /* GstDiscovererAudioInfo */
790 #define AUDIO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
791 GENERIC_ACCESSOR_CODE(gst_discoverer_audio_info, GstDiscovererAudioInfo*, \
792 GST_TYPE_DISCOVERER_AUDIO_INFO, \
793 fieldname, type, failval)
796 * gst_discoverer_audio_info_get_channels:
797 * @info: a #GstDiscovererAudioInfo
799 * Returns: the number of channels in the stream.
802 AUDIO_INFO_ACCESSOR_CODE (channels, guint, 0);
805 * gst_discoverer_audio_info_get_channel_mask:
806 * @info: a #GstDiscovererAudioInfo
808 * Returns: the channel-mask of the stream, refer to
809 * gst_audio_channel_positions_from_mask() for more
815 AUDIO_INFO_ACCESSOR_CODE (channel_mask, guint64, G_MAXUINT64);
818 * gst_discoverer_audio_info_get_sample_rate:
819 * @info: a #GstDiscovererAudioInfo
821 * Returns: the sample rate of the stream in Hertz.
824 AUDIO_INFO_ACCESSOR_CODE (sample_rate, guint, 0);
827 * gst_discoverer_audio_info_get_depth:
828 * @info: a #GstDiscovererAudioInfo
830 * Returns: the number of bits used per sample in each channel.
833 AUDIO_INFO_ACCESSOR_CODE (depth, guint, 0);
836 * gst_discoverer_audio_info_get_bitrate:
837 * @info: a #GstDiscovererAudioInfo
839 * Returns: the average or nominal bitrate of the stream in bits/second.
842 AUDIO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
845 * gst_discoverer_audio_info_get_max_bitrate:
846 * @info: a #GstDiscovererAudioInfo
848 * Returns: the maximum bitrate of the stream in bits/second.
851 AUDIO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
854 * gst_discoverer_audio_info_get_language:
855 * @info: a #GstDiscovererAudioInfo
857 * Returns: (nullable): the language of the stream, or NULL if unknown.
860 AUDIO_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
862 /* GstDiscovererVideoInfo */
864 #define VIDEO_INFO_ACCESSOR_CODE(fieldname, type, failval) \
865 GENERIC_ACCESSOR_CODE(gst_discoverer_video_info, GstDiscovererVideoInfo*, \
866 GST_TYPE_DISCOVERER_VIDEO_INFO, \
867 fieldname, type, failval)
870 * gst_discoverer_video_info_get_width:
871 * @info: a #GstDiscovererVideoInfo
873 * Returns: the width of the video stream in pixels.
876 VIDEO_INFO_ACCESSOR_CODE (width, guint, 0);
879 * gst_discoverer_video_info_get_height:
880 * @info: a #GstDiscovererVideoInfo
882 * Returns: the height of the video stream in pixels.
885 VIDEO_INFO_ACCESSOR_CODE (height, guint, 0);
888 * gst_discoverer_video_info_get_depth:
889 * @info: a #GstDiscovererVideoInfo
891 * Returns: the depth in bits of the video stream.
894 VIDEO_INFO_ACCESSOR_CODE (depth, guint, 0);
897 * gst_discoverer_video_info_get_framerate_num:
898 * @info: a #GstDiscovererVideoInfo
900 * Returns: the framerate of the video stream (numerator).
903 VIDEO_INFO_ACCESSOR_CODE (framerate_num, guint, 0);
906 * gst_discoverer_video_info_get_framerate_denom:
907 * @info: a #GstDiscovererVideoInfo
909 * Returns: the framerate of the video stream (denominator).
912 VIDEO_INFO_ACCESSOR_CODE (framerate_denom, guint, 0);
915 * gst_discoverer_video_info_get_par_num:
916 * @info: a #GstDiscovererVideoInfo
918 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (numerator).
921 VIDEO_INFO_ACCESSOR_CODE (par_num, guint, 0);
924 * gst_discoverer_video_info_get_par_denom:
925 * @info: a #GstDiscovererVideoInfo
927 * Returns: the Pixel Aspect Ratio (PAR) of the video stream (denominator).
930 VIDEO_INFO_ACCESSOR_CODE (par_denom, guint, 0);
933 * gst_discoverer_video_info_is_interlaced:
934 * @info: a #GstDiscovererVideoInfo
936 * Returns: %TRUE if the stream is interlaced, else %FALSE.
939 gst_discoverer_video_info_is_interlaced (const GstDiscovererVideoInfo * info)
941 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
943 return info->interlaced;
947 * gst_discoverer_video_info_get_bitrate:
948 * @info: a #GstDiscovererVideoInfo
950 * Returns: the average or nominal bitrate of the video stream in bits/second.
953 VIDEO_INFO_ACCESSOR_CODE (bitrate, guint, 0);
956 * gst_discoverer_video_info_get_max_bitrate:
957 * @info: a #GstDiscovererVideoInfo
959 * Returns: the maximum bitrate of the video stream in bits/second.
962 VIDEO_INFO_ACCESSOR_CODE (max_bitrate, guint, 0);
965 * gst_discoverer_video_info_is_image:
966 * @info: a #GstDiscovererVideoInfo
968 * Returns: %TRUE if the video stream corresponds to an image (i.e. only contains
972 gst_discoverer_video_info_is_image (const GstDiscovererVideoInfo * info)
974 g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (info), FALSE);
976 return info->is_image;
979 /* GstDiscovererSubtitleInfo */
981 #define SUBTITLE_INFO_ACCESSOR_CODE(fieldname, type, failval) \
982 GENERIC_ACCESSOR_CODE(gst_discoverer_subtitle_info, GstDiscovererSubtitleInfo*, \
983 GST_TYPE_DISCOVERER_SUBTITLE_INFO, \
984 fieldname, type, failval)
987 * gst_discoverer_subtitle_info_get_language:
988 * @info: a #GstDiscovererSubtitleInfo
990 * Returns: (nullable): the language of the stream, or NULL if unknown.
993 SUBTITLE_INFO_ACCESSOR_CODE (language, const gchar *, NULL);
995 /* GstDiscovererInfo */
997 #define DISCOVERER_INFO_ACCESSOR_CODE(fieldname, type, failval) \
998 GENERIC_ACCESSOR_CODE(gst_discoverer_info, GstDiscovererInfo*, \
999 GST_TYPE_DISCOVERER_INFO, \
1000 fieldname, type, failval)
1003 * gst_discoverer_info_get_uri:
1004 * @info: a #GstDiscovererInfo
1006 * Returns: (transfer none): the URI to which this information corresponds to.
1007 * Copy it if you wish to use it after the life-time of @info.
1010 DISCOVERER_INFO_ACCESSOR_CODE (uri, const gchar *, NULL);
1013 * gst_discoverer_info_get_result:
1014 * @info: a #GstDiscovererInfo
1016 * Returns: the result of the discovery as a #GstDiscovererResult.
1019 DISCOVERER_INFO_ACCESSOR_CODE (result, GstDiscovererResult, GST_DISCOVERER_OK);
1022 * gst_discoverer_info_get_stream_info:
1023 * @info: a #GstDiscovererInfo
1025 * Returns: (transfer full) (nullable): the structure (or topology) of the URI as a
1026 * #GstDiscovererStreamInfo.
1027 * This structure can be traversed to see the original hierarchy. Unref with
1028 * gst_discoverer_stream_info_unref() after usage.
1031 GstDiscovererStreamInfo *
1032 gst_discoverer_info_get_stream_info (GstDiscovererInfo * info)
1034 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1036 if (info->stream_info)
1037 return gst_discoverer_stream_info_ref (info->stream_info);
1042 * gst_discoverer_info_get_stream_list:
1043 * @info: a #GstDiscovererInfo
1045 * Returns: (transfer full) (element-type GstPbutils.DiscovererStreamInfo): the list of
1046 * all streams contained in the #info. Free after usage
1047 * with gst_discoverer_stream_info_list_free().
1050 gst_discoverer_info_get_stream_list (GstDiscovererInfo * info)
1052 GList *res = NULL, *tmp;
1054 g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
1056 for (tmp = info->stream_list; tmp; tmp = tmp->next)
1059 gst_discoverer_stream_info_ref ((GstDiscovererStreamInfo *) tmp->data));
1065 * gst_discoverer_info_get_duration:
1066 * @info: a #GstDiscovererInfo
1068 * Returns: the duration of the URI in #GstClockTime (nanoseconds).
1071 DISCOVERER_INFO_ACCESSOR_CODE (duration, GstClockTime, GST_CLOCK_TIME_NONE);
1074 * gst_discoverer_info_get_seekable:
1075 * @info: a #GstDiscovererInfo
1077 * Returns: the whether the URI is seekable.
1080 DISCOVERER_INFO_ACCESSOR_CODE (seekable, gboolean, FALSE);
1083 * gst_discoverer_info_get_live:
1084 * @info: a #GstDiscovererInfo
1086 * Returns: whether the URI is live.
1091 DISCOVERER_INFO_ACCESSOR_CODE (live, gboolean, FALSE);
1093 #ifndef GST_REMOVE_DEPRECATED
1095 * gst_discoverer_info_get_misc:
1096 * @info: a #GstDiscovererInfo
1098 * Deprecated: This functions is deprecated since version 1.4, use
1099 * #gst_discoverer_info_get_missing_elements_installer_details
1101 * Returns: (transfer none) (nullable): Miscellaneous information stored as a #GstStructure
1102 * (for example: information about missing plugins). If you wish to use the
1103 * #GstStructure after the life-time of @info, you will need to copy it.
1106 DISCOVERER_INFO_ACCESSOR_CODE (misc, const GstStructure *, NULL);
1109 * gst_discoverer_info_get_tags:
1110 * @info: a #GstDiscovererInfo
1112 * Returns: (transfer none) (nullable): all tags contained in the URI. If you wish to use
1113 * the tags after the life-time of @info, you will need to copy them.
1115 * Deprecated: 1.20: Use gst_discoverer_{container,stream}_info_get_tags() instead.
1118 DISCOVERER_INFO_ACCESSOR_CODE (tags, const GstTagList *, NULL);
1122 * gst_discoverer_info_get_toc:
1123 * @info: a #GstDiscovererInfo
1125 * Returns: (transfer none) (nullable): TOC contained in the URI. If you wish to use
1126 * the TOC after the life-time of @info, you will need to copy it.
1129 DISCOVERER_INFO_ACCESSOR_CODE (toc, const GstToc *, NULL);
1132 * gst_discoverer_info_ref:
1133 * @info: a #GstDiscovererInfo
1135 * Increments the reference count of @info.
1137 * Returns: the same #GstDiscovererInfo object
1141 * gst_discoverer_info_unref:
1142 * @info: a #GstDiscovererInfo
1144 * Decrements the reference count of @info.
1148 * gst_discoverer_stream_info_ref:
1149 * @info: a #GstDiscovererStreamInfo
1151 * Increments the reference count of @info.
1153 * Returns: the same #GstDiscovererStreamInfo object
1157 * gst_discoverer_stream_info_unref:
1158 * @info: a #GstDiscovererStreamInfo
1160 * Decrements the reference count of @info.
1165 * gst_discoverer_info_get_missing_elements_installer_details:
1166 * @info: a #GstDiscovererStreamInfo to retrieve installer detail
1167 * for the missing element
1169 * Get the installer details for missing elements
1171 * Returns: (transfer none) (array zero-terminated=1): An array of strings
1172 * containing information about how to install the various missing elements
1173 * for @info to be usable. If you wish to use the strings after the life-time
1174 * of @info, you will need to copy them.
1179 gst_discoverer_info_get_missing_elements_installer_details (const
1180 GstDiscovererInfo * info)
1183 if (info->result != GST_DISCOVERER_MISSING_PLUGINS) {
1184 GST_WARNING_OBJECT (info, "Trying to get missing element installed details "
1185 "but result is not 'MISSING_PLUGINS'");
1190 if (info->missing_elements_details->pdata[info->missing_elements_details->
1192 GST_DEBUG ("Adding NULL pointer to the end of missing_elements_details");
1193 g_ptr_array_add (info->missing_elements_details, NULL);
1196 return (const gchar **) info->missing_elements_details->pdata;