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