3 * Copyright (C) 2014-2015 Sebastian Dröge <sebastian@centricular.com>
4 * Copyright (C) 2015 Brijesh Singh <brijesh.ksingh@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 * @short_description: Player
29 * Starting from GStreamer 1.20, application developers are strongly advised to migrate to #GstPlay.
30 * #GstPlayer will be deprecated in 1.20 and most likely removed by 1.24.
38 * - Subtitle font, connection speed
40 * - Buffering control (-> progressive downloading)
41 * - Playlist/queue object
42 * - Custom video sink (e.g. embed in GL scene)
50 #include "gstplayer.h"
51 #include "gstplayer-signal-dispatcher-private.h"
52 #include "gstplayer-video-renderer-private.h"
53 #include "gstplayer-media-info-private.h"
54 #include "gstplayer-wrapped-video-renderer-private.h"
57 #include <gst/play/play.h>
58 #include <gst/video/video.h>
59 #include <gst/video/colorbalance.h>
60 #include <gst/tag/tag.h>
61 #include <gst/pbutils/descriptions.h>
65 GST_DEBUG_CATEGORY_STATIC (gst_player_debug);
66 #define GST_CAT_DEFAULT gst_player_debug
68 #define DEFAULT_URI NULL
69 #define DEFAULT_POSITION GST_CLOCK_TIME_NONE
70 #define DEFAULT_DURATION GST_CLOCK_TIME_NONE
71 #define DEFAULT_VOLUME 1.0
72 #define DEFAULT_MUTE FALSE
73 #define DEFAULT_RATE 1.0
74 #define DEFAULT_POSITION_UPDATE_INTERVAL_MS 100
75 #define DEFAULT_AUDIO_VIDEO_OFFSET 0
76 #define DEFAULT_SUBTITLE_VIDEO_OFFSET 0
79 * gst_player_error_quark:
82 gst_player_error_quark (void)
84 return g_quark_from_static_string ("gst-player-error-quark");
87 static GQuark QUARK_CONFIG;
89 /* Keep ConfigQuarkId and _config_quark_strings ordered and synced */
92 CONFIG_QUARK_USER_AGENT = 0,
93 CONFIG_QUARK_POSITION_INTERVAL_UPDATE,
94 CONFIG_QUARK_ACCURATE_SEEK,
99 static const gchar *_config_quark_strings[] = {
101 "position-interval-update",
105 static GQuark _config_quark_table[CONFIG_QUARK_MAX];
107 #define CONFIG_QUARK(q) _config_quark_table[CONFIG_QUARK_##q]
113 PROP_SIGNAL_DISPATCHER,
119 PROP_CURRENT_AUDIO_TRACK,
120 PROP_CURRENT_VIDEO_TRACK,
121 PROP_CURRENT_SUBTITLE_TRACK,
126 PROP_VIDEO_MULTIVIEW_MODE,
127 PROP_VIDEO_MULTIVIEW_FLAGS,
128 PROP_AUDIO_VIDEO_OFFSET,
129 PROP_SUBTITLE_VIDEO_OFFSET,
136 SIGNAL_POSITION_UPDATED,
137 SIGNAL_DURATION_CHANGED,
138 SIGNAL_STATE_CHANGED,
140 SIGNAL_END_OF_STREAM,
143 SIGNAL_VIDEO_DIMENSIONS_CHANGED,
144 SIGNAL_MEDIA_INFO_UPDATED,
145 SIGNAL_VOLUME_CHANGED,
156 GstPlaySignalAdapter *signal_adapter;
159 GstPlayerSignalDispatcher *signal_dispatcher;
162 struct _GstPlayerClass
164 GstObjectClass parent_class;
167 #define parent_class gst_player_parent_class
168 G_DEFINE_TYPE (GstPlayer, gst_player, GST_TYPE_OBJECT);
170 static guint signals[SIGNAL_LAST] = { 0, };
171 static GParamSpec *param_specs[PROP_LAST] = { NULL, };
173 static void gst_player_finalize (GObject * object);
174 static void gst_player_set_property (GObject * object, guint prop_id,
175 const GValue * value, GParamSpec * pspec);
176 static void gst_player_get_property (GObject * object, guint prop_id,
177 GValue * value, GParamSpec * pspec);
180 gst_player_init (G_GNUC_UNUSED GstPlayer * self)
186 config_quark_initialize (void)
190 QUARK_CONFIG = g_quark_from_static_string ("player-config");
192 if (G_N_ELEMENTS (_config_quark_strings) != CONFIG_QUARK_MAX)
193 g_warning ("the quark table is not consistent! %d != %d",
194 (int) G_N_ELEMENTS (_config_quark_strings), CONFIG_QUARK_MAX);
196 for (i = 0; i < CONFIG_QUARK_MAX; i++) {
197 _config_quark_table[i] =
198 g_quark_from_static_string (_config_quark_strings[i]);
203 gst_player_class_init (GstPlayerClass * klass)
205 GObjectClass *gobject_class = (GObjectClass *) klass;
207 gobject_class->set_property = gst_player_set_property;
208 gobject_class->get_property = gst_player_get_property;
209 gobject_class->finalize = gst_player_finalize;
211 param_specs[PROP_VIDEO_RENDERER] =
212 g_param_spec_object ("video-renderer",
213 "Video Renderer", "Video renderer to use for rendering videos",
214 GST_TYPE_PLAYER_VIDEO_RENDERER,
215 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
217 param_specs[PROP_SIGNAL_DISPATCHER] =
218 g_param_spec_object ("signal-dispatcher",
219 "Signal Dispatcher", "Dispatcher for the signals to e.g. event loops",
220 GST_TYPE_PLAYER_SIGNAL_DISPATCHER,
221 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
223 param_specs[PROP_URI] = g_param_spec_string ("uri", "URI", "Current URI",
224 DEFAULT_URI, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
226 param_specs[PROP_SUBURI] = g_param_spec_string ("suburi", "Subtitle URI",
227 "Current Subtitle URI", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
229 param_specs[PROP_POSITION] =
230 g_param_spec_uint64 ("position", "Position", "Current Position",
231 0, G_MAXUINT64, DEFAULT_POSITION,
232 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
234 param_specs[PROP_MEDIA_INFO] =
235 g_param_spec_object ("media-info", "Media Info",
236 "Current media information", GST_TYPE_PLAYER_MEDIA_INFO,
237 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
239 param_specs[PROP_CURRENT_AUDIO_TRACK] =
240 g_param_spec_object ("current-audio-track", "Current Audio Track",
241 "Current audio track information", GST_TYPE_PLAYER_AUDIO_INFO,
242 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
244 param_specs[PROP_CURRENT_VIDEO_TRACK] =
245 g_param_spec_object ("current-video-track", "Current Video Track",
246 "Current video track information", GST_TYPE_PLAYER_VIDEO_INFO,
247 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
249 param_specs[PROP_CURRENT_SUBTITLE_TRACK] =
250 g_param_spec_object ("current-subtitle-track", "Current Subtitle Track",
251 "Current audio subtitle information", GST_TYPE_PLAYER_SUBTITLE_INFO,
252 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
254 param_specs[PROP_DURATION] =
255 g_param_spec_uint64 ("duration", "Duration", "Duration",
256 0, G_MAXUINT64, DEFAULT_DURATION,
257 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
259 param_specs[PROP_VOLUME] =
260 g_param_spec_double ("volume", "Volume", "Volume",
261 0, 10.0, DEFAULT_VOLUME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
263 param_specs[PROP_MUTE] =
264 g_param_spec_boolean ("mute", "Mute", "Mute",
265 DEFAULT_MUTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
267 param_specs[PROP_PIPELINE] =
268 g_param_spec_object ("pipeline", "Pipeline",
269 "GStreamer pipeline that is used",
270 GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
272 param_specs[PROP_RATE] =
273 g_param_spec_double ("rate", "rate", "Playback rate",
274 -64.0, 64.0, DEFAULT_RATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
276 param_specs[PROP_VIDEO_MULTIVIEW_MODE] =
277 g_param_spec_enum ("video-multiview-mode",
278 "Multiview Mode Override",
279 "Re-interpret a video stream as one of several frame-packed stereoscopic modes.",
280 GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING,
281 GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE,
282 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
284 param_specs[PROP_VIDEO_MULTIVIEW_FLAGS] =
285 g_param_spec_flags ("video-multiview-flags",
286 "Multiview Flags Override",
287 "Override details of the multiview frame layout",
288 GST_TYPE_VIDEO_MULTIVIEW_FLAGS, GST_VIDEO_MULTIVIEW_FLAGS_NONE,
289 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
291 param_specs[PROP_AUDIO_VIDEO_OFFSET] =
292 g_param_spec_int64 ("audio-video-offset", "Audio Video Offset",
293 "The synchronisation offset between audio and video in nanoseconds",
294 G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
296 param_specs[PROP_SUBTITLE_VIDEO_OFFSET] =
297 g_param_spec_int64 ("subtitle-video-offset", "Text Video Offset",
298 "The synchronisation offset between text and video in nanoseconds",
299 G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
301 g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
303 signals[SIGNAL_URI_LOADED] =
304 g_signal_new ("uri-loaded", G_TYPE_FROM_CLASS (klass),
305 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
306 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
308 signals[SIGNAL_POSITION_UPDATED] =
309 g_signal_new ("position-updated", G_TYPE_FROM_CLASS (klass),
310 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
311 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_CLOCK_TIME);
313 signals[SIGNAL_DURATION_CHANGED] =
314 g_signal_new ("duration-changed", G_TYPE_FROM_CLASS (klass),
315 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
316 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_CLOCK_TIME);
318 signals[SIGNAL_STATE_CHANGED] =
319 g_signal_new ("state-changed", G_TYPE_FROM_CLASS (klass),
320 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
321 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_PLAYER_STATE);
323 signals[SIGNAL_BUFFERING] =
324 g_signal_new ("buffering", G_TYPE_FROM_CLASS (klass),
325 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
326 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT);
328 signals[SIGNAL_END_OF_STREAM] =
329 g_signal_new ("end-of-stream", G_TYPE_FROM_CLASS (klass),
330 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
331 NULL, NULL, G_TYPE_NONE, 0, G_TYPE_INVALID);
333 signals[SIGNAL_ERROR] =
334 g_signal_new ("error", G_TYPE_FROM_CLASS (klass),
335 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
336 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ERROR);
338 signals[SIGNAL_VIDEO_DIMENSIONS_CHANGED] =
339 g_signal_new ("video-dimensions-changed", G_TYPE_FROM_CLASS (klass),
340 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
341 NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
343 signals[SIGNAL_MEDIA_INFO_UPDATED] =
344 g_signal_new ("media-info-updated", G_TYPE_FROM_CLASS (klass),
345 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
346 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_PLAYER_MEDIA_INFO);
348 signals[SIGNAL_VOLUME_CHANGED] =
349 g_signal_new ("volume-changed", G_TYPE_FROM_CLASS (klass),
350 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
351 NULL, NULL, G_TYPE_NONE, 0, G_TYPE_INVALID);
353 signals[SIGNAL_MUTE_CHANGED] =
354 g_signal_new ("mute-changed", G_TYPE_FROM_CLASS (klass),
355 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
356 NULL, NULL, G_TYPE_NONE, 0, G_TYPE_INVALID);
358 signals[SIGNAL_WARNING] =
359 g_signal_new ("warning", G_TYPE_FROM_CLASS (klass),
360 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
361 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ERROR);
363 signals[SIGNAL_SEEK_DONE] =
364 g_signal_new ("seek-done", G_TYPE_FROM_CLASS (klass),
365 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
366 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_CLOCK_TIME);
368 config_quark_initialize ();
372 gst_player_finalize (GObject * object)
374 GstPlayer *self = GST_PLAYER (object);
376 GST_TRACE_OBJECT (self, "Finalizing");
378 if (self->signal_dispatcher)
379 g_object_unref (self->signal_dispatcher);
380 if (self->signal_adapter)
381 g_object_unref (self->signal_adapter);
383 gst_object_unref (self->play);
385 G_OBJECT_CLASS (parent_class)->finalize (object);
389 gst_player_set_property (GObject * object, guint prop_id,
390 const GValue * value, GParamSpec * pspec)
392 GstPlayer *self = GST_PLAYER (object);
395 case PROP_SIGNAL_DISPATCHER:
396 self->signal_dispatcher = g_value_dup_object (value);
399 g_object_set_property (G_OBJECT (self->play),
400 g_param_spec_get_name (pspec), value);
406 gst_player_get_property (GObject * object, guint prop_id,
407 GValue * value, GParamSpec * pspec)
409 GstPlayer *self = GST_PLAYER (object);
412 case PROP_MEDIA_INFO:
413 g_value_take_object (value, gst_player_get_media_info (self));
415 case PROP_CURRENT_AUDIO_TRACK:
416 g_value_take_object (value, gst_player_get_current_audio_track (self));
418 case PROP_CURRENT_VIDEO_TRACK:
419 g_value_take_object (value, gst_player_get_current_video_track (self));
421 case PROP_CURRENT_SUBTITLE_TRACK:
422 g_value_take_object (value, gst_player_get_current_subtitle_track (self));
425 g_object_get_property (G_OBJECT (self->play),
426 g_param_spec_get_name (pspec), value);
432 gst_player_init_once (G_GNUC_UNUSED gpointer user_data)
434 gst_init (NULL, NULL);
436 GST_DEBUG_CATEGORY_INIT (gst_player_debug, "gst-player", 0, "GstPlayer");
437 gst_player_error_quark ();
443 uri_loaded_cb (GstPlaySignalAdapter * adapter, const gchar * uri,
446 g_signal_emit (self, signals[SIGNAL_URI_LOADED], 0, uri);
450 position_updated_cb (GstPlaySignalAdapter * adapter, GstClockTime position,
453 g_signal_emit (self, signals[SIGNAL_POSITION_UPDATED], 0, position);
457 duration_changed_cb (GstPlaySignalAdapter * adapter, GstClockTime duraton,
460 g_signal_emit (self, signals[SIGNAL_DURATION_CHANGED], 0, duraton);
464 state_changed_cb (GstPlaySignalAdapter * adapter, GstPlayState state,
467 GstPlayerState s = GST_PLAYER_STATE_BUFFERING;
469 case GST_PLAY_STATE_BUFFERING:
470 s = GST_PLAYER_STATE_BUFFERING;
472 case GST_PLAY_STATE_PAUSED:
473 s = GST_PLAYER_STATE_PAUSED;
475 case GST_PLAY_STATE_PLAYING:
476 s = GST_PLAYER_STATE_PLAYING;
478 case GST_PLAY_STATE_STOPPED:
479 s = GST_PLAYER_STATE_STOPPED;
482 g_signal_emit (self, signals[SIGNAL_STATE_CHANGED], 0, s);
486 buffering_cb (GstPlaySignalAdapter * adapter, gint buffering_percent,
489 g_signal_emit (self, signals[SIGNAL_BUFFERING], 0, buffering_percent);
493 end_of_stream_cb (GstPlaySignalAdapter * adapter, GstPlayer * self)
495 g_signal_emit (self, signals[SIGNAL_END_OF_STREAM], 0, NULL);
499 error_cb (GstPlaySignalAdapter * adapter, GError * error,
500 GstStructure * details, GstPlayer * self)
502 g_signal_emit (self, signals[SIGNAL_ERROR], 0, error);
506 dimensions_changed_cb (GstPlaySignalAdapter * adapter, guint width,
507 guint height, GstPlayer * self)
509 g_signal_emit (self, signals[SIGNAL_VIDEO_DIMENSIONS_CHANGED], 0, width,
514 media_info_cb (GstPlaySignalAdapter * adapter, GstPlayMediaInfo * info,
517 GstPlayerMediaInfo *i = gst_player_media_info_wrapped (info);
518 g_signal_emit (self, signals[SIGNAL_MEDIA_INFO_UPDATED], 0, i);
523 volume_cb (GstPlaySignalAdapter * adapter, gdouble volume, GstPlayer * self)
525 g_signal_emit (self, signals[SIGNAL_VOLUME_CHANGED], 0, NULL);
530 mute_cb (GstPlaySignalAdapter * adapter, gboolean muted, GstPlayer * self)
532 g_signal_emit (self, signals[SIGNAL_MUTE_CHANGED], 0, NULL);
536 warning_cb (GstPlaySignalAdapter * adapter, GError * warning,
537 GstStructure * details, GstPlayer * self)
539 g_signal_emit (self, signals[SIGNAL_WARNING], 0, warning);
543 seek_done_cb (GstPlaySignalAdapter * adapter, GstClockTime time,
546 g_signal_emit (self, signals[SIGNAL_SEEK_DONE], 0, time);
551 * @video_renderer: (transfer full) (allow-none): GstPlayerVideoRenderer to use
552 * @signal_dispatcher: (transfer full) (allow-none): GstPlayerSignalDispatcher to use
554 * Creates a new #GstPlayer instance that uses @signal_dispatcher to dispatch
555 * signals to some event loop system, or emits signals directly if NULL is
556 * passed. See gst_player_g_main_context_signal_dispatcher_new().
558 * Video is going to be rendered by @video_renderer, or if %NULL is provided
559 * no special video set up will be done and some default handling will be
562 * Returns: (transfer full): a new #GstPlayer instance
565 gst_player_new (GstPlayerVideoRenderer * video_renderer,
566 GstPlayerSignalDispatcher * signal_dispatcher)
568 static GOnce once = G_ONCE_INIT;
571 g_once (&once, gst_player_init_once, NULL);
574 g_object_new (GST_TYPE_PLAYER, "signal-dispatcher", signal_dispatcher,
577 self->play = gst_play_new (NULL);
579 if (video_renderer != NULL) {
580 GstPlayerVideoRenderer *renderer;
581 renderer = gst_player_wrapped_video_renderer_new (video_renderer, self);
582 g_object_set (self->play, "video-renderer",
583 GST_PLAY_VIDEO_RENDERER (renderer), NULL);
584 g_object_unref (renderer);
587 if (signal_dispatcher != NULL) {
588 GMainContext *context = NULL;
590 g_object_get (signal_dispatcher, "application-context", &context, NULL);
591 self->signal_adapter =
592 gst_play_signal_adapter_new_with_main_context (self->play, context);
593 g_main_context_unref (context);
595 self->signal_adapter = gst_play_signal_adapter_new (self->play);
598 gst_object_ref_sink (self);
600 g_signal_connect (self->signal_adapter, "uri-loaded",
601 G_CALLBACK (uri_loaded_cb), self);
602 g_signal_connect (self->signal_adapter, "position-updated",
603 G_CALLBACK (position_updated_cb), self);
604 g_signal_connect (self->signal_adapter, "duration-changed",
605 G_CALLBACK (duration_changed_cb), self);
606 g_signal_connect (self->signal_adapter, "state-changed",
607 G_CALLBACK (state_changed_cb), self);
608 g_signal_connect (self->signal_adapter, "buffering",
609 G_CALLBACK (buffering_cb), self);
610 g_signal_connect (self->signal_adapter, "end-of-stream",
611 G_CALLBACK (end_of_stream_cb), self);
612 g_signal_connect (self->signal_adapter, "error", G_CALLBACK (error_cb), self);
613 g_signal_connect (self->signal_adapter, "video-dimensions-changed",
614 G_CALLBACK (dimensions_changed_cb), self);
615 g_signal_connect (self->signal_adapter, "media-info-updated",
616 G_CALLBACK (media_info_cb), self);
617 g_signal_connect (self->signal_adapter, "volume-changed",
618 G_CALLBACK (volume_cb), self);
619 g_signal_connect (self->signal_adapter, "mute-changed", G_CALLBACK (mute_cb),
621 g_signal_connect (self->signal_adapter, "warning", G_CALLBACK (warning_cb),
623 g_signal_connect (self->signal_adapter, "seek-done",
624 G_CALLBACK (seek_done_cb), self);
627 g_object_unref (video_renderer);
628 if (signal_dispatcher)
629 g_object_unref (signal_dispatcher);
636 * @player: #GstPlayer instance
638 * Request to play the loaded stream.
641 gst_player_play (GstPlayer * self)
643 g_return_if_fail (GST_IS_PLAYER (self));
645 gst_play_play (self->play);
650 * @player: #GstPlayer instance
652 * Pauses the current stream.
655 gst_player_pause (GstPlayer * self)
657 g_return_if_fail (GST_IS_PLAYER (self));
659 gst_play_pause (self->play);
664 * @player: #GstPlayer instance
666 * Stops playing the current stream and resets to the first position
670 gst_player_stop (GstPlayer * self)
672 g_return_if_fail (GST_IS_PLAYER (self));
674 gst_play_stop (self->play);
678 * gst_player_set_rate:
679 * @player: #GstPlayer instance
680 * @rate: playback rate
682 * Playback at specified rate
685 gst_player_set_rate (GstPlayer * self, gdouble rate)
687 g_return_if_fail (GST_IS_PLAYER (self));
688 g_return_if_fail (rate != 0.0);
690 g_object_set (self, "rate", rate, NULL);
694 * gst_player_get_rate:
695 * @player: #GstPlayer instance
697 * Returns: current playback rate
700 gst_player_get_rate (GstPlayer * self)
704 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_RATE);
706 g_object_get (self, "rate", &val, NULL);
713 * @player: #GstPlayer instance
714 * @position: position to seek in nanoseconds
716 * Seeks the currently-playing stream to the absolute @position time
720 gst_player_seek (GstPlayer * self, GstClockTime position)
722 g_return_if_fail (GST_IS_PLAYER (self));
723 g_return_if_fail (GST_CLOCK_TIME_IS_VALID (position));
725 gst_play_seek (self->play, position);
729 * gst_player_get_uri:
730 * @player: #GstPlayer instance
732 * Gets the URI of the currently-playing stream.
734 * Returns: (transfer full) (nullable): a string containing the URI of the
735 * currently-playing stream. g_free() after usage.
738 gst_player_get_uri (GstPlayer * self)
742 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_URI);
744 g_object_get (self, "uri", &val, NULL);
750 * gst_player_set_uri:
751 * @player: #GstPlayer instance
752 * @uri: (nullable): next URI to play.
754 * Sets the next URI to play.
757 gst_player_set_uri (GstPlayer * self, const gchar * val)
759 g_return_if_fail (GST_IS_PLAYER (self));
761 g_object_set (self, "uri", val, NULL);
765 * gst_player_set_subtitle_uri:
766 * @player: #GstPlayer instance
767 * @uri: (nullable): subtitle URI
769 * Sets the external subtitle URI. This should be combined with a call to
770 * gst_player_set_subtitle_track_enabled(@player, TRUE) so the subtitles are actually
774 gst_player_set_subtitle_uri (GstPlayer * self, const gchar * suburi)
776 g_return_if_fail (GST_IS_PLAYER (self));
778 g_object_set (self, "suburi", suburi, NULL);
782 * gst_player_get_subtitle_uri:
783 * @player: #GstPlayer instance
785 * current subtitle URI
787 * Returns: (transfer full) (nullable): URI of the current external subtitle.
788 * g_free() after usage.
791 gst_player_get_subtitle_uri (GstPlayer * self)
795 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
797 g_object_get (self, "suburi", &val, NULL);
803 * gst_player_get_position:
804 * @player: #GstPlayer instance
806 * Returns: the absolute position time, in nanoseconds, of the
807 * currently-playing stream.
810 gst_player_get_position (GstPlayer * self)
814 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_POSITION);
816 g_object_get (self, "position", &val, NULL);
822 * gst_player_get_duration:
823 * @player: #GstPlayer instance
825 * Retrieves the duration of the media stream that self represents.
827 * Returns: the duration of the currently-playing media stream, in
831 gst_player_get_duration (GstPlayer * self)
835 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_DURATION);
837 g_object_get (self, "duration", &val, NULL);
843 * gst_player_get_volume:
844 * @player: #GstPlayer instance
846 * Returns the current volume level, as a percentage between 0 and 1.
848 * Returns: the volume as percentage between 0 and 1.
851 gst_player_get_volume (GstPlayer * self)
855 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_VOLUME);
857 g_object_get (self, "volume", &val, NULL);
863 * gst_player_set_volume:
864 * @player: #GstPlayer instance
865 * @val: the new volume level, as a percentage between 0 and 1
867 * Sets the volume level of the stream as a percentage between 0 and 1.
869 * This volume is a linear factor. For showing the volume in a GUI it
870 * might make sense to first convert from a different format. Volume sliders
871 * should usually use a cubic volume. See gst_stream_volume_convert_volume().
874 gst_player_set_volume (GstPlayer * self, gdouble val)
876 g_return_if_fail (GST_IS_PLAYER (self));
878 g_object_set (self, "volume", val, NULL);
882 * gst_player_get_mute:
883 * @player: #GstPlayer instance
885 * Returns: %TRUE if the currently-playing stream is muted.
888 gst_player_get_mute (GstPlayer * self)
892 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_MUTE);
894 g_object_get (self, "mute", &val, NULL);
900 * gst_player_set_mute:
901 * @player: #GstPlayer instance
902 * @val: Mute state the should be set
904 * %TRUE if the currently-playing stream should be muted.
907 gst_player_set_mute (GstPlayer * self, gboolean val)
909 g_return_if_fail (GST_IS_PLAYER (self));
911 g_object_set (self, "mute", val, NULL);
915 * gst_player_get_pipeline:
916 * @player: #GstPlayer instance
918 * Returns: (transfer full): The internal playbin instance.
920 * The caller should free it with g_object_unref()
923 gst_player_get_pipeline (GstPlayer * self)
927 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
929 g_object_get (self, "pipeline", &val, NULL);
935 * gst_player_get_media_info:
936 * @player: #GstPlayer instance
938 * A Function to get the current media info #GstPlayerMediaInfo instance.
940 * Returns: (transfer full) (nullable): media info instance.
942 * The caller should free it with g_object_unref()
945 gst_player_get_media_info (GstPlayer * self)
947 GstPlayMediaInfo *info;
948 GstPlayerMediaInfo *ret;
950 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
952 info = gst_play_get_media_info (self->play);
956 ret = gst_player_media_info_wrapped (info);
957 g_object_unref (info);
962 * gst_player_get_current_audio_track:
963 * @player: #GstPlayer instance
965 * A Function to get current audio #GstPlayerAudioInfo instance.
967 * Returns: (transfer full) (nullable): current audio track.
969 * The caller should free it with g_object_unref()
972 gst_player_get_current_audio_track (GstPlayer * self)
974 GstPlayAudioInfo *info;
975 GstPlayerAudioInfo *ret = NULL;
977 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
979 info = gst_play_get_current_audio_track (self->play);
981 ret = gst_player_audio_info_wrapped (info);
982 g_object_unref (info);
988 * gst_player_get_current_video_track:
989 * @player: #GstPlayer instance
991 * A Function to get current video #GstPlayerVideoInfo instance.
993 * Returns: (transfer full) (nullable): current video track.
995 * The caller should free it with g_object_unref()
998 gst_player_get_current_video_track (GstPlayer * self)
1000 GstPlayVideoInfo *info;
1001 GstPlayerVideoInfo *ret = NULL;
1003 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1005 info = gst_play_get_current_video_track (self->play);
1007 ret = gst_player_video_info_wrapped (info);
1008 g_object_unref (info);
1014 * gst_player_get_current_subtitle_track:
1015 * @player: #GstPlayer instance
1017 * A Function to get current subtitle #GstPlayerSubtitleInfo instance.
1019 * Returns: (transfer full) (nullable): current subtitle track.
1021 * The caller should free it with g_object_unref()
1023 GstPlayerSubtitleInfo *
1024 gst_player_get_current_subtitle_track (GstPlayer * self)
1026 GstPlaySubtitleInfo *info;
1027 GstPlayerSubtitleInfo *ret = NULL;
1029 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1031 info = gst_play_get_current_subtitle_track (self->play);
1033 ret = gst_player_subtitle_info_wrapped (info);
1034 g_object_unref (info);
1040 * gst_player_set_audio_track:
1041 * @player: #GstPlayer instance
1042 * @stream_index: stream index
1044 * Returns: %TRUE or %FALSE
1046 * Sets the audio track @stream_idex.
1049 gst_player_set_audio_track (GstPlayer * self, gint stream_index)
1051 g_return_val_if_fail (GST_IS_PLAYER (self), 0);
1053 return gst_play_set_audio_track (self->play, stream_index);
1057 * gst_player_set_video_track:
1058 * @player: #GstPlayer instance
1059 * @stream_index: stream index
1061 * Returns: %TRUE or %FALSE
1063 * Sets the video track @stream_index.
1066 gst_player_set_video_track (GstPlayer * self, gint stream_index)
1068 g_return_val_if_fail (GST_IS_PLAYER (self), 0);
1070 return gst_play_set_video_track (self->play, stream_index);
1074 * gst_player_set_subtitle_track:
1075 * @player: #GstPlayer instance
1076 * @stream_index: stream index
1078 * Returns: %TRUE or %FALSE
1080 * Sets the subtitle stack @stream_index.
1083 gst_player_set_subtitle_track (GstPlayer * self, gint stream_index)
1085 g_return_val_if_fail (GST_IS_PLAYER (self), 0);
1087 return gst_play_set_subtitle_track (self->play, stream_index);
1091 * gst_player_set_audio_track_enabled:
1092 * @player: #GstPlayer instance
1093 * @enabled: TRUE or FALSE
1095 * Enable or disable the current audio track.
1098 gst_player_set_audio_track_enabled (GstPlayer * self, gboolean enabled)
1100 g_return_if_fail (GST_IS_PLAYER (self));
1102 gst_play_set_audio_track_enabled (self->play, enabled);
1106 * gst_player_set_video_track_enabled:
1107 * @player: #GstPlayer instance
1108 * @enabled: TRUE or FALSE
1110 * Enable or disable the current video track.
1113 gst_player_set_video_track_enabled (GstPlayer * self, gboolean enabled)
1115 g_return_if_fail (GST_IS_PLAYER (self));
1117 gst_play_set_video_track_enabled (self->play, enabled);
1121 * gst_player_set_subtitle_track_enabled:
1122 * @player: #GstPlayer instance
1123 * @enabled: TRUE or FALSE
1125 * Enable or disable the current subtitle track.
1128 gst_player_set_subtitle_track_enabled (GstPlayer * self, gboolean enabled)
1130 g_return_if_fail (GST_IS_PLAYER (self));
1132 gst_play_set_subtitle_track_enabled (self->play, enabled);
1136 * gst_player_set_visualization:
1137 * @player: #GstPlayer instance
1138 * @name: (nullable): visualization element obtained from
1139 * #gst_player_visualizations_get()
1141 * Returns: %TRUE if the visualizations was set correctly. Otherwise,
1145 gst_player_set_visualization (GstPlayer * self, const gchar * name)
1147 g_return_val_if_fail (GST_IS_PLAYER (self), FALSE);
1149 return gst_play_set_visualization (self->play, name);
1153 * gst_player_get_current_visualization:
1154 * @player: #GstPlayer instance
1156 * Returns: (transfer full) (nullable): Name of the currently enabled
1158 * g_free() after usage.
1161 gst_player_get_current_visualization (GstPlayer * self)
1163 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1165 return gst_play_get_current_visualization (self->play);
1169 * gst_player_set_visualization_enabled:
1170 * @player: #GstPlayer instance
1171 * @enabled: TRUE or FALSE
1173 * Enable or disable the visualization.
1176 gst_player_set_visualization_enabled (GstPlayer * self, gboolean enabled)
1178 g_return_if_fail (GST_IS_PLAYER (self));
1180 gst_play_set_visualization_enabled (self->play, enabled);
1185 const gchar *label; /* channel label name */
1186 const gchar *name; /* get_name () */
1189 static const struct CBChannelMap cb_channel_map[] = {
1190 /* GST_PLAYER_COLOR_BALANCE_BRIGHTNESS */ {"BRIGHTNESS", "brightness"},
1191 /* GST_PLAYER_COLOR_BALANCE_CONTRAST */ {"CONTRAST", "contrast"},
1192 /* GST_PLAYER_COLOR_BALANCE_SATURATION */ {"SATURATION", "saturation"},
1193 /* GST_PLAYER_COLOR_BALANCE_HUE */ {"HUE", "hue"},
1197 * gst_player_has_color_balance:
1198 * @player:#GstPlayer instance
1200 * Checks whether the @player has color balance support available.
1202 * Returns: %TRUE if @player has color balance support. Otherwise,
1206 gst_player_has_color_balance (GstPlayer * self)
1208 g_return_val_if_fail (GST_IS_PLAYER (self), FALSE);
1210 return gst_play_has_color_balance (self->play);
1214 * gst_player_set_color_balance:
1215 * @player: #GstPlayer instance
1216 * @type: #GstPlayerColorBalanceType
1217 * @value: The new value for the @type, ranged [0,1]
1219 * Sets the current value of the indicated channel @type to the passed
1223 gst_player_set_color_balance (GstPlayer * self, GstPlayerColorBalanceType type,
1226 g_return_if_fail (GST_IS_PLAYER (self));
1227 g_return_if_fail (value >= 0.0 && value <= 1.0);
1229 gst_play_set_color_balance (self->play, (GstPlayColorBalanceType) type,
1234 * gst_player_get_color_balance:
1235 * @player: #GstPlayer instance
1236 * @type: #GstPlayerColorBalanceType
1238 * Retrieve the current value of the indicated @type.
1240 * Returns: The current value of @type, between [0,1]. In case of
1241 * error -1 is returned.
1244 gst_player_get_color_balance (GstPlayer * self, GstPlayerColorBalanceType type)
1246 g_return_val_if_fail (GST_IS_PLAYER (self), -1);
1248 return gst_play_get_color_balance (self->play,
1249 (GstPlayColorBalanceType) type);
1253 * gst_player_get_multiview_mode:
1254 * @player: #GstPlayer instance
1256 * Retrieve the current value of the indicated @type.
1258 * Returns: The current value of @type, Default: -1 "none"
1262 GstVideoMultiviewFramePacking
1263 gst_player_get_multiview_mode (GstPlayer * self)
1265 GstVideoMultiviewFramePacking val = GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE;
1267 g_return_val_if_fail (GST_IS_PLAYER (self),
1268 GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE);
1270 g_object_get (self, "video-multiview-mode", &val, NULL);
1276 * gst_player_set_multiview_mode:
1277 * @player: #GstPlayer instance
1278 * @mode: The new value for the @type
1280 * Sets the current value of the indicated mode @type to the passed
1286 gst_player_set_multiview_mode (GstPlayer * self,
1287 GstVideoMultiviewFramePacking mode)
1289 g_return_if_fail (GST_IS_PLAYER (self));
1291 g_object_set (self, "video-multiview-mode", mode, NULL);
1295 * gst_player_get_multiview_flags:
1296 * @player: #GstPlayer instance
1298 * Retrieve the current value of the indicated @type.
1300 * Returns: The current value of @type, Default: 0x00000000 "none
1304 GstVideoMultiviewFlags
1305 gst_player_get_multiview_flags (GstPlayer * self)
1307 GstVideoMultiviewFlags val = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
1309 g_return_val_if_fail (GST_IS_PLAYER (self), val);
1311 g_object_get (self, "video-multiview-flags", &val, NULL);
1317 * gst_player_set_multiview_flags:
1318 * @player: #GstPlayer instance
1319 * @flags: The new value for the @type
1321 * Sets the current value of the indicated mode @type to the passed
1327 gst_player_set_multiview_flags (GstPlayer * self, GstVideoMultiviewFlags flags)
1329 g_return_if_fail (GST_IS_PLAYER (self));
1331 g_object_set (self, "video-multiview-flags", flags, NULL);
1335 * gst_player_get_audio_video_offset:
1336 * @player: #GstPlayer instance
1338 * Retrieve the current value of audio-video-offset property
1340 * Returns: The current value of audio-video-offset in nanoseconds
1345 gst_player_get_audio_video_offset (GstPlayer * self)
1349 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_AUDIO_VIDEO_OFFSET);
1351 g_object_get (self, "audio-video-offset", &val, NULL);
1357 * gst_player_set_audio_video_offset:
1358 * @player: #GstPlayer instance
1359 * @offset: #gint64 in nanoseconds
1361 * Sets audio-video-offset property by value of @offset
1366 gst_player_set_audio_video_offset (GstPlayer * self, gint64 offset)
1368 g_return_if_fail (GST_IS_PLAYER (self));
1370 g_object_set (self, "audio-video-offset", offset, NULL);
1374 * gst_player_get_subtitle_video_offset:
1375 * @player: #GstPlayer instance
1377 * Retrieve the current value of subtitle-video-offset property
1379 * Returns: The current value of subtitle-video-offset in nanoseconds
1384 gst_player_get_subtitle_video_offset (GstPlayer * self)
1388 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_SUBTITLE_VIDEO_OFFSET);
1390 g_object_get (self, "subtitle-video-offset", &val, NULL);
1396 * gst_player_set_subtitle_video_offset:
1397 * @player: #GstPlayer instance
1398 * @offset: #gint64 in nanoseconds
1400 * Sets subtitle-video-offset property by value of @offset
1405 gst_player_set_subtitle_video_offset (GstPlayer * self, gint64 offset)
1407 g_return_if_fail (GST_IS_PLAYER (self));
1409 g_object_set (self, "subtitle-video-offset", offset, NULL);
1413 #define C_ENUM(v) ((gint) v)
1414 #define C_FLAGS(v) ((guint) v)
1417 gst_player_color_balance_type_get_type (void)
1419 static gsize id = 0;
1420 static const GEnumValue values[] = {
1421 {C_ENUM (GST_PLAYER_COLOR_BALANCE_HUE), "GST_PLAYER_COLOR_BALANCE_HUE",
1423 {C_ENUM (GST_PLAYER_COLOR_BALANCE_BRIGHTNESS),
1424 "GST_PLAYER_COLOR_BALANCE_BRIGHTNESS", "brightness"},
1425 {C_ENUM (GST_PLAYER_COLOR_BALANCE_SATURATION),
1426 "GST_PLAYER_COLOR_BALANCE_SATURATION", "saturation"},
1427 {C_ENUM (GST_PLAYER_COLOR_BALANCE_CONTRAST),
1428 "GST_PLAYER_COLOR_BALANCE_CONTRAST", "contrast"},
1432 if (g_once_init_enter (&id)) {
1433 GType tmp = g_enum_register_static ("GstPlayerColorBalanceType", values);
1434 g_once_init_leave (&id, tmp);
1441 * gst_player_color_balance_type_get_name:
1442 * @type: a #GstPlayerColorBalanceType
1444 * Gets a string representing the given color balance type.
1446 * Returns: (transfer none): a string with the name of the color
1450 gst_player_color_balance_type_get_name (GstPlayerColorBalanceType type)
1452 g_return_val_if_fail (type >= GST_PLAYER_COLOR_BALANCE_BRIGHTNESS &&
1453 type <= GST_PLAYER_COLOR_BALANCE_HUE, NULL);
1455 return cb_channel_map[type].name;
1459 gst_player_state_get_type (void)
1461 static gsize id = 0;
1462 static const GEnumValue values[] = {
1463 {C_ENUM (GST_PLAYER_STATE_STOPPED), "GST_PLAYER_STATE_STOPPED", "stopped"},
1464 {C_ENUM (GST_PLAYER_STATE_BUFFERING), "GST_PLAYER_STATE_BUFFERING",
1466 {C_ENUM (GST_PLAYER_STATE_PAUSED), "GST_PLAYER_STATE_PAUSED", "paused"},
1467 {C_ENUM (GST_PLAYER_STATE_PLAYING), "GST_PLAYER_STATE_PLAYING", "playing"},
1471 if (g_once_init_enter (&id)) {
1472 GType tmp = g_enum_register_static ("GstPlayerState", values);
1473 g_once_init_leave (&id, tmp);
1480 * gst_player_state_get_name:
1481 * @state: a #GstPlayerState
1483 * Gets a string representing the given state.
1485 * Returns: (transfer none): a string with the name of the state.
1488 gst_player_state_get_name (GstPlayerState state)
1491 case GST_PLAYER_STATE_STOPPED:
1493 case GST_PLAYER_STATE_BUFFERING:
1495 case GST_PLAYER_STATE_PAUSED:
1497 case GST_PLAYER_STATE_PLAYING:
1501 g_assert_not_reached ();
1506 gst_player_error_get_type (void)
1508 static gsize id = 0;
1509 static const GEnumValue values[] = {
1510 {C_ENUM (GST_PLAYER_ERROR_FAILED), "GST_PLAYER_ERROR_FAILED", "failed"},
1514 if (g_once_init_enter (&id)) {
1515 GType tmp = g_enum_register_static ("GstPlayerError", values);
1516 g_once_init_leave (&id, tmp);
1523 * gst_player_error_get_name:
1524 * @error: a #GstPlayerError
1526 * Gets a string representing the given error.
1528 * Returns: (transfer none): a string with the given error.
1531 gst_player_error_get_name (GstPlayerError error)
1534 case GST_PLAYER_ERROR_FAILED:
1538 g_assert_not_reached ();
1543 * gst_player_set_config:
1544 * @player: #GstPlayer instance
1545 * @config: (transfer full): a #GstStructure
1547 * Set the configuration of the player. If the player is already configured, and
1548 * the configuration haven't change, this function will return %TRUE. If the
1549 * player is not in the GST_PLAYER_STATE_STOPPED, this method will return %FALSE
1550 * and active configuration will remain.
1552 * @config is a #GstStructure that contains the configuration parameters for
1555 * This function takes ownership of @config.
1557 * Returns: %TRUE when the configuration could be set.
1561 gst_player_set_config (GstPlayer * self, GstStructure * config)
1563 g_return_val_if_fail (GST_IS_PLAYER (self), FALSE);
1564 g_return_val_if_fail (config != NULL, FALSE);
1566 return gst_play_set_config (self->play, config);
1570 * gst_player_get_config:
1571 * @player: #GstPlayer instance
1573 * Get a copy of the current configuration of the player. This configuration
1574 * can either be modified and used for the gst_player_set_config() call
1575 * or it must be freed after usage.
1577 * Returns: (transfer full): a copy of the current configuration of @player. Use
1578 * gst_structure_free() after usage or gst_player_set_config().
1583 gst_player_get_config (GstPlayer * self)
1585 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1587 return gst_play_get_config (self->play);
1591 * gst_player_config_set_user_agent:
1592 * @config: a #GstPlayer configuration
1593 * @agent: (nullable): the string to use as user agent
1595 * Set the user agent to pass to the server if @player needs to connect
1596 * to a server during playback. This is typically used when playing HTTP
1602 gst_player_config_set_user_agent (GstStructure * config, const gchar * agent)
1604 g_return_if_fail (config != NULL);
1605 g_return_if_fail (agent != NULL);
1607 gst_structure_id_set (config,
1608 CONFIG_QUARK (USER_AGENT), G_TYPE_STRING, agent, NULL);
1612 * gst_player_config_get_user_agent:
1613 * @config: a #GstPlayer configuration
1615 * Return the user agent which has been configured using
1616 * gst_player_config_set_user_agent() if any.
1618 * Returns: (transfer full) (nullable): the configured agent, or %NULL
1623 gst_player_config_get_user_agent (const GstStructure * config)
1625 gchar *agent = NULL;
1627 g_return_val_if_fail (config != NULL, NULL);
1629 gst_structure_id_get (config,
1630 CONFIG_QUARK (USER_AGENT), G_TYPE_STRING, &agent, NULL);
1636 * gst_player_config_set_position_update_interval:
1637 * @config: a #GstPlayer configuration
1638 * @interval: interval in ms
1640 * set interval in milliseconds between two position-updated signals.
1641 * pass 0 to stop updating the position.
1646 gst_player_config_set_position_update_interval (GstStructure * config,
1649 g_return_if_fail (config != NULL);
1650 g_return_if_fail (interval <= 10000);
1652 gst_structure_id_set (config,
1653 CONFIG_QUARK (POSITION_INTERVAL_UPDATE), G_TYPE_UINT, interval, NULL);
1657 * gst_player_config_get_position_update_interval:
1658 * @config: a #GstPlayer configuration
1660 * Returns: current position update interval in milliseconds
1665 gst_player_config_get_position_update_interval (const GstStructure * config)
1667 guint interval = DEFAULT_POSITION_UPDATE_INTERVAL_MS;
1669 g_return_val_if_fail (config != NULL, DEFAULT_POSITION_UPDATE_INTERVAL_MS);
1671 gst_structure_id_get (config,
1672 CONFIG_QUARK (POSITION_INTERVAL_UPDATE), G_TYPE_UINT, &interval, NULL);
1678 * gst_player_config_set_seek_accurate:
1679 * @config: a #GstPlayer configuration
1680 * @accurate: accurate seek or not
1682 * Enable or disable accurate seeking. When enabled, elements will try harder
1683 * to seek as accurately as possible to the requested seek position. Generally
1684 * it will be slower especially for formats that don't have any indexes or
1685 * timestamp markers in the stream.
1687 * If accurate seeking is disabled, elements will seek as close as the request
1688 * position without slowing down seeking too much.
1690 * Accurate seeking is disabled by default.
1695 gst_player_config_set_seek_accurate (GstStructure * config, gboolean accurate)
1697 g_return_if_fail (config != NULL);
1699 gst_structure_id_set (config,
1700 CONFIG_QUARK (ACCURATE_SEEK), G_TYPE_BOOLEAN, accurate, NULL);
1704 * gst_player_config_get_seek_accurate:
1705 * @config: a #GstPlayer configuration
1707 * Returns: %TRUE if accurate seeking is enabled
1712 gst_player_config_get_seek_accurate (const GstStructure * config)
1714 gboolean accurate = FALSE;
1716 g_return_val_if_fail (config != NULL, FALSE);
1718 gst_structure_id_get (config,
1719 CONFIG_QUARK (ACCURATE_SEEK), G_TYPE_BOOLEAN, &accurate, NULL);
1725 * gst_player_get_video_snapshot:
1726 * @player: #GstPlayer instance
1727 * @format: output format of the video snapshot
1728 * @config: (allow-none): Additional configuration
1730 * Get a snapshot of the currently selected video stream, if any. The format can be
1731 * selected with @format and optional configuration is possible with @config
1732 * Currently supported settings are:
1733 * - width, height of type G_TYPE_INT
1734 * - pixel-aspect-ratio of type GST_TYPE_FRACTION
1735 * Except for GST_PLAYER_THUMBNAIL_RAW_NATIVE format, if no config is set, pixel-aspect-ratio would be 1/1
1737 * Returns: (transfer full) (nullable): Current video snapshot sample or %NULL on failure
1742 gst_player_get_video_snapshot (GstPlayer * self,
1743 GstPlayerSnapshotFormat format, const GstStructure * config)
1745 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1747 return gst_play_get_video_snapshot (self->play,
1748 (GstPlaySnapshotFormat) format, config);