• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  *
3  * Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
4  *
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.
9  *
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.
14  *
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.
19  */
20 
21 /**
22  * SECTION:gstplayer-mediainfo
23  * @title: GstPlayerMediaInfo
24  * @short_description: Player Media Information
25  *
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 
32 #include "gstplayer-media-info.h"
33 #include "gstplayer-media-info-private.h"
34 
35 /* Per-stream information */
36 G_DEFINE_ABSTRACT_TYPE (GstPlayerStreamInfo, gst_player_stream_info,
37     G_TYPE_OBJECT);
38 
39 static void
gst_player_stream_info_init(GstPlayerStreamInfo * sinfo)40 gst_player_stream_info_init (GstPlayerStreamInfo * sinfo)
41 {
42   sinfo->stream_index = -1;
43 }
44 
45 static void
gst_player_stream_info_finalize(GObject * object)46 gst_player_stream_info_finalize (GObject * object)
47 {
48   GstPlayerStreamInfo *sinfo = GST_PLAYER_STREAM_INFO (object);
49 
50   g_clear_object (&sinfo->info);
51 
52   G_OBJECT_CLASS (gst_player_stream_info_parent_class)->finalize (object);
53 }
54 
55 static void
gst_player_stream_info_class_init(GstPlayerStreamInfoClass * klass)56 gst_player_stream_info_class_init (GstPlayerStreamInfoClass * klass)
57 {
58   GObjectClass *gobject_class = (GObjectClass *) klass;
59 
60   gobject_class->finalize = gst_player_stream_info_finalize;
61 }
62 
63 /**
64  * gst_player_stream_info_get_index:
65  * @info: a #GstPlayerStreamInfo
66  *
67  * Function to get stream index from #GstPlayerStreamInfo instance or -1 if
68  * unknown.
69  *
70  * Returns: the stream index of this stream.
71  */
72 gint
gst_player_stream_info_get_index(const GstPlayerStreamInfo * info)73 gst_player_stream_info_get_index (const GstPlayerStreamInfo * info)
74 {
75   g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), -1);
76 
77   return info->stream_index;
78 }
79 
80 /**
81  * gst_player_stream_info_get_stream_type:
82  * @info: a #GstPlayerStreamInfo
83  *
84  * Function to return human readable name for the stream type
85  * of the given @info (ex: "audio", "video", "subtitle")
86  *
87  * Returns: a human readable name
88  */
89 const gchar *
gst_player_stream_info_get_stream_type(const GstPlayerStreamInfo * info)90 gst_player_stream_info_get_stream_type (const GstPlayerStreamInfo * info)
91 {
92   g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
93 
94   return gst_play_stream_info_get_stream_type (info->info);
95 }
96 
97 /**
98  * gst_player_stream_info_get_tags:
99  * @info: a #GstPlayerStreamInfo
100  *
101  * Returns: (transfer none) (nullable): the tags contained in this stream.
102  */
103 GstTagList *
gst_player_stream_info_get_tags(const GstPlayerStreamInfo * info)104 gst_player_stream_info_get_tags (const GstPlayerStreamInfo * info)
105 {
106   g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
107 
108   return gst_play_stream_info_get_tags (info->info);
109 }
110 
111 /**
112  * gst_player_stream_info_get_codec:
113  * @info: a #GstPlayerStreamInfo
114  *
115  * A string describing codec used in #GstPlayerStreamInfo.
116  *
117  * Returns: (nullable): codec string or %NULL on unknown.
118  */
119 const gchar *
gst_player_stream_info_get_codec(const GstPlayerStreamInfo * info)120 gst_player_stream_info_get_codec (const GstPlayerStreamInfo * info)
121 {
122   g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
123 
124   return gst_play_stream_info_get_codec (info->info);
125 }
126 
127 /**
128  * gst_player_stream_info_get_caps:
129  * @info: a #GstPlayerStreamInfo
130  *
131  * Returns: (transfer none) (nullable): the #GstCaps of the stream.
132  */
133 GstCaps *
gst_player_stream_info_get_caps(const GstPlayerStreamInfo * info)134 gst_player_stream_info_get_caps (const GstPlayerStreamInfo * info)
135 {
136   g_return_val_if_fail (GST_IS_PLAYER_STREAM_INFO (info), NULL);
137 
138   return gst_play_stream_info_get_caps (info->info);
139 }
140 
141 /* Video information */
142 G_DEFINE_TYPE (GstPlayerVideoInfo, gst_player_video_info,
143     GST_TYPE_PLAYER_STREAM_INFO);
144 
145 static void
gst_player_video_info_init(G_GNUC_UNUSED GstPlayerVideoInfo * info)146 gst_player_video_info_init (G_GNUC_UNUSED GstPlayerVideoInfo * info)
147 {
148 
149 }
150 
151 static void
gst_player_video_info_class_init(G_GNUC_UNUSED GstPlayerVideoInfoClass * klass)152 gst_player_video_info_class_init (G_GNUC_UNUSED GstPlayerVideoInfoClass * klass)
153 {
154   /* nothing to do here */
155 }
156 
157 /**
158  * gst_player_video_info_get_width:
159  * @info: a #GstPlayerVideoInfo
160  *
161  * Returns: the width of video in #GstPlayerVideoInfo or -1 if unknown.
162  */
163 gint
gst_player_video_info_get_width(const GstPlayerVideoInfo * info)164 gst_player_video_info_get_width (const GstPlayerVideoInfo * info)
165 {
166   g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
167 
168   return gst_play_video_info_get_width (info->info);
169 }
170 
171 /**
172  * gst_player_video_info_get_height:
173  * @info: a #GstPlayerVideoInfo
174  *
175  * Returns: the height of video in #GstPlayerVideoInfo or -1 if unknown.
176  */
177 gint
gst_player_video_info_get_height(const GstPlayerVideoInfo * info)178 gst_player_video_info_get_height (const GstPlayerVideoInfo * info)
179 {
180   g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
181 
182   return gst_play_video_info_get_height (info->info);
183 }
184 
185 /**
186  * gst_player_video_info_get_framerate:
187  * @info: a #GstPlayerVideoInfo
188  * @fps_n: (out): Numerator of frame rate
189  * @fps_d: (out): Denominator of frame rate
190  *
191  */
192 void
gst_player_video_info_get_framerate(const GstPlayerVideoInfo * info,gint * fps_n,gint * fps_d)193 gst_player_video_info_get_framerate (const GstPlayerVideoInfo * info,
194     gint * fps_n, gint * fps_d)
195 {
196   g_return_if_fail (GST_IS_PLAYER_VIDEO_INFO (info));
197 
198   gst_play_video_info_get_framerate (info->info, fps_n, fps_d);
199 }
200 
201 /**
202  * gst_player_video_info_get_pixel_aspect_ratio:
203  * @info: a #GstPlayerVideoInfo
204  * @par_n: (out): numerator
205  * @par_d: (out): denominator
206  *
207  * Returns the pixel aspect ratio in @par_n and @par_d
208  *
209  */
210 void
gst_player_video_info_get_pixel_aspect_ratio(const GstPlayerVideoInfo * info,guint * par_n,guint * par_d)211 gst_player_video_info_get_pixel_aspect_ratio (const GstPlayerVideoInfo * info,
212     guint * par_n, guint * par_d)
213 {
214   g_return_if_fail (GST_IS_PLAYER_VIDEO_INFO (info));
215 
216   gst_play_video_info_get_pixel_aspect_ratio (info->info, par_n, par_d);
217 }
218 
219 /**
220  * gst_player_video_info_get_bitrate:
221  * @info: a #GstPlayerVideoInfo
222  *
223  * Returns: the current bitrate of video in #GstPlayerVideoInfo or -1 if
224  * unknown.
225  */
226 gint
gst_player_video_info_get_bitrate(const GstPlayerVideoInfo * info)227 gst_player_video_info_get_bitrate (const GstPlayerVideoInfo * info)
228 {
229   g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
230 
231   return gst_play_video_info_get_bitrate (info->info);
232 }
233 
234 /**
235  * gst_player_video_info_get_max_bitrate:
236  * @info: a #GstPlayerVideoInfo
237  *
238  * Returns: the maximum bitrate of video in #GstPlayerVideoInfo or -1 if
239  * unknown.
240  */
241 gint
gst_player_video_info_get_max_bitrate(const GstPlayerVideoInfo * info)242 gst_player_video_info_get_max_bitrate (const GstPlayerVideoInfo * info)
243 {
244   g_return_val_if_fail (GST_IS_PLAYER_VIDEO_INFO (info), -1);
245 
246   return gst_play_video_info_get_max_bitrate (info->info);
247 }
248 
249 /* Audio information */
250 G_DEFINE_TYPE (GstPlayerAudioInfo, gst_player_audio_info,
251     GST_TYPE_PLAYER_STREAM_INFO);
252 
253 static void
gst_player_audio_info_init(G_GNUC_UNUSED GstPlayerAudioInfo * info)254 gst_player_audio_info_init (G_GNUC_UNUSED GstPlayerAudioInfo * info)
255 {
256 
257 }
258 
259 static void
gst_player_audio_info_finalize(GObject * object)260 gst_player_audio_info_finalize (GObject * object)
261 {
262   GstPlayerAudioInfo *info = GST_PLAYER_AUDIO_INFO (object);
263 
264   g_clear_object (&info->info);
265 
266   G_OBJECT_CLASS (gst_player_audio_info_parent_class)->finalize (object);
267 }
268 
269 static void
gst_player_audio_info_class_init(GstPlayerAudioInfoClass * klass)270 gst_player_audio_info_class_init (GstPlayerAudioInfoClass * klass)
271 {
272   GObjectClass *gobject_class = (GObjectClass *) klass;
273 
274   gobject_class->finalize = gst_player_audio_info_finalize;
275 }
276 
277 /**
278  * gst_player_audio_info_get_language:
279  * @info: a #GstPlayerAudioInfo
280  *
281  * Returns: (nullable): the language of the stream, or NULL if unknown.
282  */
283 const gchar *
gst_player_audio_info_get_language(const GstPlayerAudioInfo * info)284 gst_player_audio_info_get_language (const GstPlayerAudioInfo * info)
285 {
286   g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), NULL);
287 
288   return gst_play_audio_info_get_language (info->info);
289 }
290 
291 /**
292  * gst_player_audio_info_get_channels:
293  * @info: a #GstPlayerAudioInfo
294  *
295  * Returns: the number of audio channels in #GstPlayerAudioInfo or 0 if
296  * unknown.
297  */
298 gint
gst_player_audio_info_get_channels(const GstPlayerAudioInfo * info)299 gst_player_audio_info_get_channels (const GstPlayerAudioInfo * info)
300 {
301   g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), 0);
302 
303   return gst_play_audio_info_get_channels (info->info);
304 }
305 
306 /**
307  * gst_player_audio_info_get_sample_rate:
308  * @info: a #GstPlayerAudioInfo
309  *
310  * Returns: the audio sample rate in #GstPlayerAudioInfo or 0 if unknown.
311  */
312 gint
gst_player_audio_info_get_sample_rate(const GstPlayerAudioInfo * info)313 gst_player_audio_info_get_sample_rate (const GstPlayerAudioInfo * info)
314 {
315   g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), 0);
316 
317   return gst_play_audio_info_get_sample_rate (info->info);
318 }
319 
320 /**
321  * gst_player_audio_info_get_bitrate:
322  * @info: a #GstPlayerAudioInfo
323  *
324  * Returns: the audio bitrate in #GstPlayerAudioInfo or -1 if unknown.
325  */
326 gint
gst_player_audio_info_get_bitrate(const GstPlayerAudioInfo * info)327 gst_player_audio_info_get_bitrate (const GstPlayerAudioInfo * info)
328 {
329   g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), -1);
330 
331   return gst_play_audio_info_get_bitrate (info->info);
332 }
333 
334 /**
335  * gst_player_audio_info_get_max_bitrate:
336  * @info: a #GstPlayerAudioInfo
337  *
338  * Returns: the audio maximum bitrate in #GstPlayerAudioInfo or -1 if unknown.
339  */
340 gint
gst_player_audio_info_get_max_bitrate(const GstPlayerAudioInfo * info)341 gst_player_audio_info_get_max_bitrate (const GstPlayerAudioInfo * info)
342 {
343   g_return_val_if_fail (GST_IS_PLAYER_AUDIO_INFO (info), -1);
344 
345   return gst_play_audio_info_get_max_bitrate (info->info);
346 }
347 
348 /* Subtitle information */
349 G_DEFINE_TYPE (GstPlayerSubtitleInfo, gst_player_subtitle_info,
350     GST_TYPE_PLAYER_STREAM_INFO);
351 
352 static void
gst_player_subtitle_info_init(G_GNUC_UNUSED GstPlayerSubtitleInfo * info)353 gst_player_subtitle_info_init (G_GNUC_UNUSED GstPlayerSubtitleInfo * info)
354 {
355   /* nothing to do */
356 }
357 
358 static void
gst_player_subtitle_info_finalize(GObject * object)359 gst_player_subtitle_info_finalize (GObject * object)
360 {
361   GstPlayerSubtitleInfo *info = GST_PLAYER_SUBTITLE_INFO (object);
362 
363   g_clear_object (&info->info);
364 
365   G_OBJECT_CLASS (gst_player_subtitle_info_parent_class)->finalize (object);
366 }
367 
368 static void
gst_player_subtitle_info_class_init(GstPlayerSubtitleInfoClass * klass)369 gst_player_subtitle_info_class_init (GstPlayerSubtitleInfoClass * klass)
370 {
371   GObjectClass *gobject_class = (GObjectClass *) klass;
372 
373   gobject_class->finalize = gst_player_subtitle_info_finalize;
374 }
375 
376 /**
377  * gst_player_subtitle_info_get_language:
378  * @info: a #GstPlayerSubtitleInfo
379  *
380  * Returns: (nullable): the language of the stream, or %NULL if unknown.
381  */
382 const gchar *
gst_player_subtitle_info_get_language(const GstPlayerSubtitleInfo * info)383 gst_player_subtitle_info_get_language (const GstPlayerSubtitleInfo * info)
384 {
385   g_return_val_if_fail (GST_IS_PLAYER_SUBTITLE_INFO (info), NULL);
386 
387   return gst_play_subtitle_info_get_language (info->info);
388 }
389 
390 /* Global media information */
391 G_DEFINE_TYPE (GstPlayerMediaInfo, gst_player_media_info, G_TYPE_OBJECT);
392 
393 static void
gst_player_media_info_init(G_GNUC_UNUSED GstPlayerMediaInfo * info)394 gst_player_media_info_init (G_GNUC_UNUSED GstPlayerMediaInfo * info)
395 {
396 
397 }
398 
399 static void
gst_player_media_info_finalize(GObject * object)400 gst_player_media_info_finalize (GObject * object)
401 {
402   GstPlayerMediaInfo *info = GST_PLAYER_MEDIA_INFO (object);
403 
404   if (info->audio_stream_list)
405     g_list_free (info->audio_stream_list);
406 
407   if (info->video_stream_list)
408     g_list_free (info->video_stream_list);
409 
410   if (info->subtitle_stream_list)
411     g_list_free (info->subtitle_stream_list);
412 
413   if (info->stream_list)
414     g_list_free_full (info->stream_list, g_object_unref);
415   g_clear_object (&info->info);
416 
417   G_OBJECT_CLASS (gst_player_media_info_parent_class)->finalize (object);
418 }
419 
420 static void
gst_player_media_info_class_init(GstPlayerMediaInfoClass * klass)421 gst_player_media_info_class_init (GstPlayerMediaInfoClass * klass)
422 {
423   GObjectClass *oclass = (GObjectClass *) klass;
424 
425   oclass->finalize = gst_player_media_info_finalize;
426 }
427 
428 static GstPlayerVideoInfo *
gst_player_video_info_new(void)429 gst_player_video_info_new (void)
430 {
431   return g_object_new (GST_TYPE_PLAYER_VIDEO_INFO, NULL);
432 }
433 
434 static GstPlayerAudioInfo *
gst_player_audio_info_new(void)435 gst_player_audio_info_new (void)
436 {
437   return g_object_new (GST_TYPE_PLAYER_AUDIO_INFO, NULL);
438 }
439 
440 static GstPlayerSubtitleInfo *
gst_player_subtitle_info_new(void)441 gst_player_subtitle_info_new (void)
442 {
443   return g_object_new (GST_TYPE_PLAYER_SUBTITLE_INFO, NULL);
444 }
445 
446 static GstPlayerStreamInfo *
gst_player_video_info_copy(GstPlayerVideoInfo * ref)447 gst_player_video_info_copy (GstPlayerVideoInfo * ref)
448 {
449   GstPlayerVideoInfo *ret;
450 
451   ret = gst_player_video_info_new ();
452   ret->info = g_object_ref (ref->info);
453 
454   return (GstPlayerStreamInfo *) ret;
455 }
456 
457 static GstPlayerStreamInfo *
gst_player_audio_info_copy(GstPlayerAudioInfo * ref)458 gst_player_audio_info_copy (GstPlayerAudioInfo * ref)
459 {
460   GstPlayerAudioInfo *ret;
461 
462   ret = gst_player_audio_info_new ();
463   ret->info = g_object_ref (ref->info);
464 
465   return (GstPlayerStreamInfo *) ret;
466 }
467 
468 static GstPlayerStreamInfo *
gst_player_subtitle_info_copy(GstPlayerSubtitleInfo * ref)469 gst_player_subtitle_info_copy (GstPlayerSubtitleInfo * ref)
470 {
471   GstPlayerSubtitleInfo *ret;
472 
473   ret = gst_player_subtitle_info_new ();
474   ret->info = g_object_ref (ref->info);
475 
476   return (GstPlayerStreamInfo *) ret;
477 }
478 
479 GstPlayerStreamInfo *
gst_player_stream_info_copy(GstPlayerStreamInfo * ref)480 gst_player_stream_info_copy (GstPlayerStreamInfo * ref)
481 {
482   GstPlayerStreamInfo *info = NULL;
483 
484   if (!ref)
485     return NULL;
486 
487   if (GST_IS_PLAYER_VIDEO_INFO (ref))
488     info = gst_player_video_info_copy ((GstPlayerVideoInfo *) ref);
489   else if (GST_IS_PLAYER_AUDIO_INFO (ref))
490     info = gst_player_audio_info_copy ((GstPlayerAudioInfo *) ref);
491   else
492     info = gst_player_subtitle_info_copy ((GstPlayerSubtitleInfo *) ref);
493 
494   info->stream_index = ref->stream_index;
495 
496   return info;
497 }
498 
499 GstPlayerMediaInfo *
gst_player_media_info_copy(GstPlayerMediaInfo * ref)500 gst_player_media_info_copy (GstPlayerMediaInfo * ref)
501 {
502   GList *l;
503   GstPlayerMediaInfo *info;
504 
505   if (!ref)
506     return NULL;
507 
508   info = gst_player_media_info_new ();
509 
510   for (l = gst_player_media_info_get_stream_list (ref); l != NULL; l = l->next) {
511     GstPlayerStreamInfo *s;
512 
513     s = gst_player_stream_info_copy ((GstPlayerStreamInfo *) l->data);
514     info->stream_list = g_list_append (info->stream_list, s);
515 
516     if (GST_IS_PLAYER_AUDIO_INFO (s))
517       info->audio_stream_list = g_list_append (info->audio_stream_list, s);
518     else if (GST_IS_PLAYER_VIDEO_INFO (s))
519       info->video_stream_list = g_list_append (info->video_stream_list, s);
520     else
521       info->subtitle_stream_list =
522           g_list_append (info->subtitle_stream_list, s);
523   }
524 
525   info->info = g_object_ref (ref->info);
526 
527   return info;
528 }
529 
530 GstPlayerStreamInfo *
gst_player_stream_info_new(gint stream_index,GType type)531 gst_player_stream_info_new (gint stream_index, GType type)
532 {
533   GstPlayerStreamInfo *info = NULL;
534 
535   if (type == GST_TYPE_PLAYER_AUDIO_INFO)
536     info = (GstPlayerStreamInfo *) gst_player_audio_info_new ();
537   else if (type == GST_TYPE_PLAYER_VIDEO_INFO)
538     info = (GstPlayerStreamInfo *) gst_player_video_info_new ();
539   else
540     info = (GstPlayerStreamInfo *) gst_player_subtitle_info_new ();
541 
542   info->stream_index = stream_index;
543 
544   return info;
545 }
546 
547 GstPlayerStreamInfo *
gst_player_stream_info_wrapped(GstPlayStreamInfo * info)548 gst_player_stream_info_wrapped (GstPlayStreamInfo * info)
549 {
550   GstPlayerStreamInfo *ret;
551   GType type;
552 
553   if (GST_IS_PLAY_AUDIO_INFO (info)) {
554     type = GST_TYPE_PLAYER_AUDIO_INFO;
555   } else if (GST_IS_PLAY_VIDEO_INFO (info)) {
556     type = GST_TYPE_PLAYER_VIDEO_INFO;
557   } else {
558     type = GST_TYPE_PLAYER_SUBTITLE_INFO;
559   }
560 
561   ret =
562       gst_player_stream_info_new (gst_play_stream_info_get_index (info), type);
563   ret->info = g_object_ref (info);
564   return ret;
565 }
566 
567 GstPlayerMediaInfo *
gst_player_media_info_new(void)568 gst_player_media_info_new (void)
569 {
570   return g_object_new (GST_TYPE_PLAYER_MEDIA_INFO, NULL);
571 }
572 
573 GstPlayerMediaInfo *
gst_player_media_info_wrapped(GstPlayMediaInfo * info)574 gst_player_media_info_wrapped (GstPlayMediaInfo * info)
575 {
576   GstPlayerMediaInfo *ret;
577   GList *l;
578 
579   ret = gst_player_media_info_new ();
580   ret->info = g_object_ref (info);
581 
582   for (l = gst_play_media_info_get_stream_list (info); l != NULL; l = l->next) {
583     GstPlayerStreamInfo *s;
584 
585     s = gst_player_stream_info_wrapped ((GstPlayStreamInfo *) l->data);
586     ret->stream_list = g_list_append (ret->stream_list, s);
587 
588     if (GST_IS_PLAYER_AUDIO_INFO (s)) {
589       GstPlayerAudioInfo *i = GST_PLAYER_AUDIO_INFO (s);
590       i->info = g_object_ref (GST_PLAY_AUDIO_INFO (l->data));
591       ret->audio_stream_list = g_list_append (ret->audio_stream_list, i);
592     } else if (GST_IS_PLAYER_VIDEO_INFO (s)) {
593       GstPlayerVideoInfo *i = GST_PLAYER_VIDEO_INFO (s);
594       i->info = g_object_ref (GST_PLAY_VIDEO_INFO (l->data));
595       ret->video_stream_list = g_list_append (ret->video_stream_list, i);
596     } else {
597       GstPlayerSubtitleInfo *i = GST_PLAYER_SUBTITLE_INFO (s);
598       i->info = g_object_ref (GST_PLAY_SUBTITLE_INFO (l->data));
599       ret->subtitle_stream_list = g_list_append (ret->subtitle_stream_list, i);
600     }
601   }
602 
603   return ret;
604 }
605 
606 GstPlayerAudioInfo *
gst_player_audio_info_wrapped(GstPlayAudioInfo * info)607 gst_player_audio_info_wrapped (GstPlayAudioInfo * info)
608 {
609   GstPlayerStreamInfo *s;
610   GstPlayerAudioInfo *i;
611 
612   s = gst_player_stream_info_wrapped ((GstPlayStreamInfo *) info);
613   i = GST_PLAYER_AUDIO_INFO (s);
614   i->info = g_object_ref (info);
615   return i;
616 }
617 
618 GstPlayerVideoInfo *
gst_player_video_info_wrapped(GstPlayVideoInfo * info)619 gst_player_video_info_wrapped (GstPlayVideoInfo * info)
620 {
621   GstPlayerStreamInfo *s;
622   GstPlayerVideoInfo *i;
623 
624   s = gst_player_stream_info_wrapped ((GstPlayStreamInfo *) info);
625   i = GST_PLAYER_VIDEO_INFO (s);
626   i->info = g_object_ref (info);
627   return i;
628 }
629 
630 GstPlayerSubtitleInfo *
gst_player_subtitle_info_wrapped(GstPlaySubtitleInfo * info)631 gst_player_subtitle_info_wrapped (GstPlaySubtitleInfo * info)
632 {
633   GstPlayerStreamInfo *s;
634   GstPlayerSubtitleInfo *i;
635 
636   s = gst_player_stream_info_wrapped ((GstPlayStreamInfo *) info);
637   i = GST_PLAYER_SUBTITLE_INFO (s);
638   i->info = g_object_ref (info);
639   return i;
640 }
641 
642 /**
643  * gst_player_media_info_get_uri:
644  * @info: a #GstPlayerMediaInfo
645  *
646  * Returns: the URI associated with #GstPlayerMediaInfo.
647  */
648 const gchar *
gst_player_media_info_get_uri(const GstPlayerMediaInfo * info)649 gst_player_media_info_get_uri (const GstPlayerMediaInfo * info)
650 {
651   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
652 
653   return gst_play_media_info_get_uri (info->info);
654 }
655 
656 /**
657  * gst_player_media_info_is_seekable:
658  * @info: a #GstPlayerMediaInfo
659  *
660  * Returns: %TRUE if the media is seekable.
661  */
662 gboolean
gst_player_media_info_is_seekable(const GstPlayerMediaInfo * info)663 gst_player_media_info_is_seekable (const GstPlayerMediaInfo * info)
664 {
665   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), FALSE);
666 
667   return gst_play_media_info_is_seekable (info->info);
668 }
669 
670 /**
671  * gst_player_media_info_is_live:
672  * @info: a #GstPlayerMediaInfo
673  *
674  * Returns: %TRUE if the media is live.
675  */
676 gboolean
gst_player_media_info_is_live(const GstPlayerMediaInfo * info)677 gst_player_media_info_is_live (const GstPlayerMediaInfo * info)
678 {
679   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), FALSE);
680 
681   return gst_play_media_info_is_live (info->info);
682 }
683 
684 /**
685  * gst_player_media_info_get_stream_list:
686  * @info: a #GstPlayerMediaInfo
687  *
688  * Returns: (transfer none) (element-type GstPlayerStreamInfo): A #GList of
689  * matching #GstPlayerStreamInfo.
690  */
691 GList *
gst_player_media_info_get_stream_list(const GstPlayerMediaInfo * info)692 gst_player_media_info_get_stream_list (const GstPlayerMediaInfo * info)
693 {
694   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
695 
696   return info->stream_list;
697 }
698 
699 /**
700  * gst_player_media_info_get_video_streams:
701  * @info: a #GstPlayerMediaInfo
702  *
703  * Returns: (transfer none) (element-type GstPlayerVideoInfo): A #GList of
704  * matching #GstPlayerVideoInfo.
705  */
706 GList *
gst_player_media_info_get_video_streams(const GstPlayerMediaInfo * info)707 gst_player_media_info_get_video_streams (const GstPlayerMediaInfo * info)
708 {
709   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
710 
711   return info->video_stream_list;
712 }
713 
714 /**
715  * gst_player_media_info_get_subtitle_streams:
716  * @info: a #GstPlayerMediaInfo
717  *
718  * Returns: (transfer none) (element-type GstPlayerSubtitleInfo): A #GList of
719  * matching #GstPlayerSubtitleInfo.
720  */
721 GList *
gst_player_media_info_get_subtitle_streams(const GstPlayerMediaInfo * info)722 gst_player_media_info_get_subtitle_streams (const GstPlayerMediaInfo * info)
723 {
724   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
725 
726   return info->subtitle_stream_list;
727 }
728 
729 /**
730  * gst_player_media_info_get_audio_streams:
731  * @info: a #GstPlayerMediaInfo
732  *
733  * Returns: (transfer none) (element-type GstPlayerAudioInfo): A #GList of
734  * matching #GstPlayerAudioInfo.
735  */
736 GList *
gst_player_media_info_get_audio_streams(const GstPlayerMediaInfo * info)737 gst_player_media_info_get_audio_streams (const GstPlayerMediaInfo * info)
738 {
739   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
740 
741   return info->audio_stream_list;
742 }
743 
744 /**
745  * gst_player_media_info_get_duration:
746  * @info: a #GstPlayerMediaInfo
747  *
748  * Returns: duration of the media or %GST_CLOCK_TIME_NONE if unknown.
749  */
750 GstClockTime
gst_player_media_info_get_duration(const GstPlayerMediaInfo * info)751 gst_player_media_info_get_duration (const GstPlayerMediaInfo * info)
752 {
753   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), -1);
754 
755   return gst_play_media_info_get_duration (info->info);
756 }
757 
758 /**
759  * gst_player_media_info_get_tags:
760  * @info: a #GstPlayerMediaInfo
761  *
762  * Returns: (transfer none) (nullable): the tags contained in media info.
763  */
764 GstTagList *
gst_player_media_info_get_tags(const GstPlayerMediaInfo * info)765 gst_player_media_info_get_tags (const GstPlayerMediaInfo * info)
766 {
767   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
768 
769   return gst_play_media_info_get_tags (info->info);
770 }
771 
772 /**
773  * gst_player_media_info_get_title:
774  * @info: a #GstPlayerMediaInfo
775  *
776  * Returns: (nullable): the media title or %NULL if unknown.
777  */
778 const gchar *
gst_player_media_info_get_title(const GstPlayerMediaInfo * info)779 gst_player_media_info_get_title (const GstPlayerMediaInfo * info)
780 {
781   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
782 
783   return gst_play_media_info_get_title (info->info);
784 }
785 
786 /**
787  * gst_player_media_info_get_container_format:
788  * @info: a #GstPlayerMediaInfo
789  *
790  * Returns: (nullable): the container format or %NULL if unknown.
791  */
792 const gchar *
gst_player_media_info_get_container_format(const GstPlayerMediaInfo * info)793 gst_player_media_info_get_container_format (const GstPlayerMediaInfo * info)
794 {
795   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
796 
797   return gst_play_media_info_get_container_format (info->info);
798 }
799 
800 /**
801  * gst_player_media_info_get_image_sample:
802  * @info: a #GstPlayerMediaInfo
803  *
804  * Function to get the image (or preview-image) stored in taglist.
805  * Application can use `gst_sample_*_()` API's to get caps, buffer etc.
806  *
807  * Returns: (transfer none) (nullable): GstSample or %NULL.
808  */
809 GstSample *
gst_player_media_info_get_image_sample(const GstPlayerMediaInfo * info)810 gst_player_media_info_get_image_sample (const GstPlayerMediaInfo * info)
811 {
812   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), NULL);
813 
814   return gst_play_media_info_get_image_sample (info->info);
815 }
816 
817 /**
818  * gst_player_media_info_get_number_of_streams:
819  * @info: a #GstPlayerMediaInfo
820  *
821  * Returns: number of total streams or 0 if unknown.
822  *
823  * Since: 1.12
824  */
825 guint
gst_player_media_info_get_number_of_streams(const GstPlayerMediaInfo * info)826 gst_player_media_info_get_number_of_streams (const GstPlayerMediaInfo * info)
827 {
828   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), 0);
829 
830   return g_list_length (info->stream_list);
831 }
832 
833 /**
834  * gst_player_media_info_get_number_of_video_streams:
835  * @info: a #GstPlayerMediaInfo
836  *
837  * Returns: number of video streams or 0 if unknown.
838  *
839  * Since: 1.12
840  */
841 guint
gst_player_media_info_get_number_of_video_streams(const GstPlayerMediaInfo * info)842 gst_player_media_info_get_number_of_video_streams (const GstPlayerMediaInfo *
843     info)
844 {
845   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), 0);
846 
847   return g_list_length (info->video_stream_list);
848 }
849 
850 /**
851  * gst_player_media_info_get_number_of_audio_streams:
852  * @info: a #GstPlayerMediaInfo
853  *
854  * Returns: number of audio streams or 0 if unknown.
855  *
856  * Since: 1.12
857  */
858 guint
gst_player_media_info_get_number_of_audio_streams(const GstPlayerMediaInfo * info)859 gst_player_media_info_get_number_of_audio_streams (const GstPlayerMediaInfo *
860     info)
861 {
862   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), 0);
863 
864   return g_list_length (info->audio_stream_list);
865 }
866 
867 /**
868  * gst_player_media_info_get_number_of_subtitle_streams:
869  * @info: a #GstPlayerMediaInfo
870  *
871  * Returns: number of subtitle streams or 0 if unknown.
872  *
873  * Since: 1.12
874  */
gst_player_media_info_get_number_of_subtitle_streams(const GstPlayerMediaInfo * info)875 guint gst_player_media_info_get_number_of_subtitle_streams
876     (const GstPlayerMediaInfo * info)
877 {
878   g_return_val_if_fail (GST_IS_PLAYER_MEDIA_INFO (info), 0);
879 
880   return g_list_length (info->subtitle_stream_list);
881 }
882 
883 /**
884  * gst_player_get_video_streams:
885  * @info: a #GstPlayerMediaInfo
886  *
887  * Returns: (transfer none) (element-type GstPlayerVideoInfo): A #GList of
888  * matching #GstPlayerVideoInfo.
889  */
890 #ifndef GST_REMOVE_DEPRECATED
891 GList *
gst_player_get_video_streams(const GstPlayerMediaInfo * info)892 gst_player_get_video_streams (const GstPlayerMediaInfo * info)
893 {
894   return gst_player_media_info_get_video_streams (info);
895 }
896 #endif
897 
898 /**
899  * gst_player_get_audio_streams:
900  * @info: a #GstPlayerMediaInfo
901  *
902  * Returns: (transfer none) (element-type GstPlayerAudioInfo): A #GList of
903  * matching #GstPlayerAudioInfo.
904  */
905 #ifndef GST_REMOVE_DEPRECATED
906 GList *
gst_player_get_audio_streams(const GstPlayerMediaInfo * info)907 gst_player_get_audio_streams (const GstPlayerMediaInfo * info)
908 {
909   return gst_player_media_info_get_audio_streams (info);
910 }
911 #endif
912 
913 /**
914  * gst_player_get_subtitle_streams:
915  * @info: a #GstPlayerMediaInfo
916  *
917  * Returns: (transfer none) (element-type GstPlayerSubtitleInfo): A #GList of
918  * matching #GstPlayerSubtitleInfo.
919  */
920 #ifndef GST_REMOVE_DEPRECATED
921 GList *
gst_player_get_subtitle_streams(const GstPlayerMediaInfo * info)922 gst_player_get_subtitle_streams (const GstPlayerMediaInfo * info)
923 {
924   return gst_player_media_info_get_subtitle_streams (info);
925 }
926 #endif
927