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