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;
160 GstPlayerVideoRenderer *video_renderer;
163 struct _GstPlayerClass
165 GstObjectClass parent_class;
168 #define parent_class gst_player_parent_class
169 G_DEFINE_TYPE (GstPlayer, gst_player, GST_TYPE_OBJECT);
171 static guint signals[SIGNAL_LAST] = { 0, };
172 static GParamSpec *param_specs[PROP_LAST] = { NULL, };
174 static void gst_player_finalize (GObject * object);
175 static void gst_player_set_property (GObject * object, guint prop_id,
176 const GValue * value, GParamSpec * pspec);
177 static void gst_player_get_property (GObject * object, guint prop_id,
178 GValue * value, GParamSpec * pspec);
179 static void gst_player_constructed (GObject * object);
182 gst_player_init (GstPlayer * self)
184 self->play = gst_play_new (NULL);
188 config_quark_initialize (void)
192 QUARK_CONFIG = g_quark_from_static_string ("player-config");
194 if (G_N_ELEMENTS (_config_quark_strings) != CONFIG_QUARK_MAX)
195 g_warning ("the quark table is not consistent! %d != %d",
196 (int) G_N_ELEMENTS (_config_quark_strings), CONFIG_QUARK_MAX);
198 for (i = 0; i < CONFIG_QUARK_MAX; i++) {
199 _config_quark_table[i] =
200 g_quark_from_static_string (_config_quark_strings[i]);
205 gst_player_class_init (GstPlayerClass * klass)
207 GObjectClass *gobject_class = (GObjectClass *) klass;
209 gobject_class->set_property = gst_player_set_property;
210 gobject_class->get_property = gst_player_get_property;
211 gobject_class->finalize = gst_player_finalize;
212 gobject_class->constructed = gst_player_constructed;
214 param_specs[PROP_VIDEO_RENDERER] =
215 g_param_spec_object ("video-renderer",
216 "Video Renderer", "Video renderer to use for rendering videos",
217 GST_TYPE_PLAYER_VIDEO_RENDERER,
218 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
220 param_specs[PROP_SIGNAL_DISPATCHER] =
221 g_param_spec_object ("signal-dispatcher",
222 "Signal Dispatcher", "Dispatcher for the signals to e.g. event loops",
223 GST_TYPE_PLAYER_SIGNAL_DISPATCHER,
224 G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
226 param_specs[PROP_URI] = g_param_spec_string ("uri", "URI", "Current URI",
227 DEFAULT_URI, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
229 param_specs[PROP_SUBURI] = g_param_spec_string ("suburi", "Subtitle URI",
230 "Current Subtitle URI", NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
232 param_specs[PROP_POSITION] =
233 g_param_spec_uint64 ("position", "Position", "Current Position",
234 0, G_MAXUINT64, DEFAULT_POSITION,
235 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
237 param_specs[PROP_MEDIA_INFO] =
238 g_param_spec_object ("media-info", "Media Info",
239 "Current media information", GST_TYPE_PLAYER_MEDIA_INFO,
240 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
242 param_specs[PROP_CURRENT_AUDIO_TRACK] =
243 g_param_spec_object ("current-audio-track", "Current Audio Track",
244 "Current audio track information", GST_TYPE_PLAYER_AUDIO_INFO,
245 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
247 param_specs[PROP_CURRENT_VIDEO_TRACK] =
248 g_param_spec_object ("current-video-track", "Current Video Track",
249 "Current video track information", GST_TYPE_PLAYER_VIDEO_INFO,
250 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
252 param_specs[PROP_CURRENT_SUBTITLE_TRACK] =
253 g_param_spec_object ("current-subtitle-track", "Current Subtitle Track",
254 "Current audio subtitle information", GST_TYPE_PLAYER_SUBTITLE_INFO,
255 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
257 param_specs[PROP_DURATION] =
258 g_param_spec_uint64 ("duration", "Duration", "Duration",
259 0, G_MAXUINT64, DEFAULT_DURATION,
260 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
262 param_specs[PROP_VOLUME] =
263 g_param_spec_double ("volume", "Volume", "Volume",
264 0, 10.0, DEFAULT_VOLUME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
266 param_specs[PROP_MUTE] =
267 g_param_spec_boolean ("mute", "Mute", "Mute",
268 DEFAULT_MUTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
270 param_specs[PROP_PIPELINE] =
271 g_param_spec_object ("pipeline", "Pipeline",
272 "GStreamer pipeline that is used",
273 GST_TYPE_ELEMENT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
275 param_specs[PROP_RATE] =
276 g_param_spec_double ("rate", "rate", "Playback rate",
277 -64.0, 64.0, DEFAULT_RATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
279 param_specs[PROP_VIDEO_MULTIVIEW_MODE] =
280 g_param_spec_enum ("video-multiview-mode",
281 "Multiview Mode Override",
282 "Re-interpret a video stream as one of several frame-packed stereoscopic modes.",
283 GST_TYPE_VIDEO_MULTIVIEW_FRAME_PACKING,
284 GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE,
285 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
287 param_specs[PROP_VIDEO_MULTIVIEW_FLAGS] =
288 g_param_spec_flags ("video-multiview-flags",
289 "Multiview Flags Override",
290 "Override details of the multiview frame layout",
291 GST_TYPE_VIDEO_MULTIVIEW_FLAGS, GST_VIDEO_MULTIVIEW_FLAGS_NONE,
292 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
294 param_specs[PROP_AUDIO_VIDEO_OFFSET] =
295 g_param_spec_int64 ("audio-video-offset", "Audio Video Offset",
296 "The synchronisation offset between audio and video in nanoseconds",
297 G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
299 param_specs[PROP_SUBTITLE_VIDEO_OFFSET] =
300 g_param_spec_int64 ("subtitle-video-offset", "Text Video Offset",
301 "The synchronisation offset between text and video in nanoseconds",
302 G_MININT64, G_MAXINT64, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
304 g_object_class_install_properties (gobject_class, PROP_LAST, param_specs);
306 signals[SIGNAL_URI_LOADED] =
307 g_signal_new ("uri-loaded", G_TYPE_FROM_CLASS (klass),
308 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
309 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING);
311 signals[SIGNAL_POSITION_UPDATED] =
312 g_signal_new ("position-updated", G_TYPE_FROM_CLASS (klass),
313 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
314 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_CLOCK_TIME);
316 signals[SIGNAL_DURATION_CHANGED] =
317 g_signal_new ("duration-changed", G_TYPE_FROM_CLASS (klass),
318 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
319 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_CLOCK_TIME);
321 signals[SIGNAL_STATE_CHANGED] =
322 g_signal_new ("state-changed", G_TYPE_FROM_CLASS (klass),
323 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
324 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_PLAYER_STATE);
326 signals[SIGNAL_BUFFERING] =
327 g_signal_new ("buffering", G_TYPE_FROM_CLASS (klass),
328 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
329 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_INT);
331 signals[SIGNAL_END_OF_STREAM] =
332 g_signal_new ("end-of-stream", G_TYPE_FROM_CLASS (klass),
333 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
334 NULL, NULL, G_TYPE_NONE, 0, G_TYPE_INVALID);
336 signals[SIGNAL_ERROR] =
337 g_signal_new ("error", G_TYPE_FROM_CLASS (klass),
338 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
339 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ERROR);
341 signals[SIGNAL_VIDEO_DIMENSIONS_CHANGED] =
342 g_signal_new ("video-dimensions-changed", G_TYPE_FROM_CLASS (klass),
343 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
344 NULL, NULL, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
346 signals[SIGNAL_MEDIA_INFO_UPDATED] =
347 g_signal_new ("media-info-updated", G_TYPE_FROM_CLASS (klass),
348 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
349 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_PLAYER_MEDIA_INFO);
351 signals[SIGNAL_VOLUME_CHANGED] =
352 g_signal_new ("volume-changed", G_TYPE_FROM_CLASS (klass),
353 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
354 NULL, NULL, G_TYPE_NONE, 0, G_TYPE_INVALID);
356 signals[SIGNAL_MUTE_CHANGED] =
357 g_signal_new ("mute-changed", G_TYPE_FROM_CLASS (klass),
358 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
359 NULL, NULL, G_TYPE_NONE, 0, G_TYPE_INVALID);
361 signals[SIGNAL_WARNING] =
362 g_signal_new ("warning", G_TYPE_FROM_CLASS (klass),
363 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
364 NULL, NULL, G_TYPE_NONE, 1, G_TYPE_ERROR);
366 signals[SIGNAL_SEEK_DONE] =
367 g_signal_new ("seek-done", G_TYPE_FROM_CLASS (klass),
368 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, NULL,
369 NULL, NULL, G_TYPE_NONE, 1, GST_TYPE_CLOCK_TIME);
371 config_quark_initialize ();
375 gst_player_finalize (GObject * object)
377 GstPlayer *self = GST_PLAYER (object);
379 GST_TRACE_OBJECT (self, "Finalizing");
381 if (self->signal_dispatcher)
382 g_object_unref (self->signal_dispatcher);
383 if (self->video_renderer)
384 g_object_unref (self->video_renderer);
385 if (self->signal_adapter)
386 g_object_unref (self->signal_adapter);
388 gst_object_unref (self->play);
390 G_OBJECT_CLASS (parent_class)->finalize (object);
394 gst_player_set_property (GObject * object, guint prop_id,
395 const GValue * value, GParamSpec * pspec)
397 GstPlayer *self = GST_PLAYER (object);
400 case PROP_SIGNAL_DISPATCHER:
401 self->signal_dispatcher = g_value_dup_object (value);
403 case PROP_VIDEO_RENDERER:
404 self->video_renderer = g_value_dup_object (value);
407 g_object_set_property (G_OBJECT (self->play),
408 g_param_spec_get_name (pspec), value);
414 gst_player_get_property (GObject * object, guint prop_id,
415 GValue * value, GParamSpec * pspec)
417 GstPlayer *self = GST_PLAYER (object);
420 case PROP_VIDEO_RENDERER:
421 g_value_set_object (value, self->video_renderer);
423 case PROP_MEDIA_INFO:
424 g_value_take_object (value, gst_player_get_media_info (self));
426 case PROP_CURRENT_AUDIO_TRACK:
427 g_value_take_object (value, gst_player_get_current_audio_track (self));
429 case PROP_CURRENT_VIDEO_TRACK:
430 g_value_take_object (value, gst_player_get_current_video_track (self));
432 case PROP_CURRENT_SUBTITLE_TRACK:
433 g_value_take_object (value, gst_player_get_current_subtitle_track (self));
436 g_object_get_property (G_OBJECT (self->play),
437 g_param_spec_get_name (pspec), value);
443 gst_player_init_once (G_GNUC_UNUSED gpointer user_data)
445 gst_init (NULL, NULL);
447 GST_DEBUG_CATEGORY_INIT (gst_player_debug, "gst-player", 0, "GstPlayer");
448 gst_player_error_quark ();
454 uri_loaded_cb (GstPlaySignalAdapter * adapter, const gchar * uri,
457 g_signal_emit (self, signals[SIGNAL_URI_LOADED], 0, uri);
461 position_updated_cb (GstPlaySignalAdapter * adapter, GstClockTime position,
464 g_signal_emit (self, signals[SIGNAL_POSITION_UPDATED], 0, position);
468 duration_changed_cb (GstPlaySignalAdapter * adapter, GstClockTime duraton,
471 g_signal_emit (self, signals[SIGNAL_DURATION_CHANGED], 0, duraton);
475 state_changed_cb (GstPlaySignalAdapter * adapter, GstPlayState state,
478 GstPlayerState s = GST_PLAYER_STATE_BUFFERING;
480 case GST_PLAY_STATE_BUFFERING:
481 s = GST_PLAYER_STATE_BUFFERING;
483 case GST_PLAY_STATE_PAUSED:
484 s = GST_PLAYER_STATE_PAUSED;
486 case GST_PLAY_STATE_PLAYING:
487 s = GST_PLAYER_STATE_PLAYING;
489 case GST_PLAY_STATE_STOPPED:
490 s = GST_PLAYER_STATE_STOPPED;
493 g_signal_emit (self, signals[SIGNAL_STATE_CHANGED], 0, s);
497 buffering_cb (GstPlaySignalAdapter * adapter, gint buffering_percent,
500 g_signal_emit (self, signals[SIGNAL_BUFFERING], 0, buffering_percent);
504 end_of_stream_cb (GstPlaySignalAdapter * adapter, GstPlayer * self)
506 g_signal_emit (self, signals[SIGNAL_END_OF_STREAM], 0, NULL);
510 error_cb (GstPlaySignalAdapter * adapter, GError * error,
511 GstStructure * details, GstPlayer * self)
513 g_signal_emit (self, signals[SIGNAL_ERROR], 0, error);
517 dimensions_changed_cb (GstPlaySignalAdapter * adapter, guint width,
518 guint height, GstPlayer * self)
520 g_signal_emit (self, signals[SIGNAL_VIDEO_DIMENSIONS_CHANGED], 0, width,
525 media_info_cb (GstPlaySignalAdapter * adapter, GstPlayMediaInfo * info,
528 GstPlayerMediaInfo *i = gst_player_media_info_wrapped (info);
529 g_signal_emit (self, signals[SIGNAL_MEDIA_INFO_UPDATED], 0, i);
534 volume_cb (GstPlaySignalAdapter * adapter, gdouble volume, GstPlayer * self)
536 g_signal_emit (self, signals[SIGNAL_VOLUME_CHANGED], 0, NULL);
541 mute_cb (GstPlaySignalAdapter * adapter, gboolean muted, GstPlayer * self)
543 g_signal_emit (self, signals[SIGNAL_MUTE_CHANGED], 0, NULL);
547 warning_cb (GstPlaySignalAdapter * adapter, GError * warning,
548 GstStructure * details, GstPlayer * self)
550 g_signal_emit (self, signals[SIGNAL_WARNING], 0, warning);
554 seek_done_cb (GstPlaySignalAdapter * adapter, GstClockTime time,
557 g_signal_emit (self, signals[SIGNAL_SEEK_DONE], 0, time);
561 gst_player_constructed (GObject * object)
563 GstPlayer *self = GST_PLAYER (object);
564 GstPlayerVideoRenderer *renderer = NULL;
566 G_OBJECT_CLASS (parent_class)->constructed (object);
568 if (self->video_renderer != NULL) {
570 gst_player_wrapped_video_renderer_new (self->video_renderer, self);
571 g_object_set (self->play, "video-renderer",
572 GST_PLAY_VIDEO_RENDERER (renderer), NULL);
573 g_object_unref (renderer);
576 if (self->signal_dispatcher != NULL) {
577 GMainContext *context = NULL;
579 g_object_get (self->signal_dispatcher, "application-context", &context,
581 self->signal_adapter =
582 gst_play_signal_adapter_new_with_main_context (self->play, context);
583 g_main_context_unref (context);
585 self->signal_adapter = gst_play_signal_adapter_new_sync_emit (self->play);
588 g_signal_connect (self->signal_adapter, "uri-loaded",
589 G_CALLBACK (uri_loaded_cb), self);
590 g_signal_connect (self->signal_adapter, "position-updated",
591 G_CALLBACK (position_updated_cb), self);
592 g_signal_connect (self->signal_adapter, "duration-changed",
593 G_CALLBACK (duration_changed_cb), self);
594 g_signal_connect (self->signal_adapter, "state-changed",
595 G_CALLBACK (state_changed_cb), self);
596 g_signal_connect (self->signal_adapter, "buffering",
597 G_CALLBACK (buffering_cb), self);
598 g_signal_connect (self->signal_adapter, "end-of-stream",
599 G_CALLBACK (end_of_stream_cb), self);
600 g_signal_connect (self->signal_adapter, "error", G_CALLBACK (error_cb), self);
601 g_signal_connect (self->signal_adapter, "video-dimensions-changed",
602 G_CALLBACK (dimensions_changed_cb), self);
603 g_signal_connect (self->signal_adapter, "media-info-updated",
604 G_CALLBACK (media_info_cb), self);
605 g_signal_connect (self->signal_adapter, "volume-changed",
606 G_CALLBACK (volume_cb), self);
607 g_signal_connect (self->signal_adapter, "mute-changed", G_CALLBACK (mute_cb),
609 g_signal_connect (self->signal_adapter, "warning", G_CALLBACK (warning_cb),
611 g_signal_connect (self->signal_adapter, "seek-done",
612 G_CALLBACK (seek_done_cb), self);
617 * @video_renderer: (transfer full) (allow-none): GstPlayerVideoRenderer to use
618 * @signal_dispatcher: (transfer full) (allow-none): GstPlayerSignalDispatcher to use
620 * Creates a new #GstPlayer instance that uses @signal_dispatcher to dispatch
621 * signals to some event loop system, or emits signals directly if NULL is
622 * passed. See gst_player_g_main_context_signal_dispatcher_new().
624 * Video is going to be rendered by @video_renderer, or if %NULL is provided
625 * no special video set up will be done and some default handling will be
628 * Returns: (transfer full): a new #GstPlayer instance
631 gst_player_new (GstPlayerVideoRenderer * video_renderer,
632 GstPlayerSignalDispatcher * signal_dispatcher)
634 static GOnce once = G_ONCE_INIT;
637 g_once (&once, gst_player_init_once, NULL);
640 g_object_new (GST_TYPE_PLAYER, "signal-dispatcher", signal_dispatcher,
641 "video-renderer", video_renderer, NULL);
643 gst_object_ref_sink (self);
646 g_object_unref (video_renderer);
647 if (signal_dispatcher)
648 g_object_unref (signal_dispatcher);
655 * @player: #GstPlayer instance
657 * Request to play the loaded stream.
660 gst_player_play (GstPlayer * self)
662 g_return_if_fail (GST_IS_PLAYER (self));
664 gst_play_play (self->play);
669 * @player: #GstPlayer instance
671 * Pauses the current stream.
674 gst_player_pause (GstPlayer * self)
676 g_return_if_fail (GST_IS_PLAYER (self));
678 gst_play_pause (self->play);
683 * @player: #GstPlayer instance
685 * Stops playing the current stream and resets to the first position
689 gst_player_stop (GstPlayer * self)
691 g_return_if_fail (GST_IS_PLAYER (self));
693 gst_play_stop (self->play);
697 * gst_player_set_rate:
698 * @player: #GstPlayer instance
699 * @rate: playback rate
701 * Playback at specified rate
704 gst_player_set_rate (GstPlayer * self, gdouble rate)
706 g_return_if_fail (GST_IS_PLAYER (self));
707 g_return_if_fail (rate != 0.0);
709 g_object_set (self, "rate", rate, NULL);
713 * gst_player_get_rate:
714 * @player: #GstPlayer instance
716 * Returns: current playback rate
719 gst_player_get_rate (GstPlayer * self)
723 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_RATE);
725 g_object_get (self, "rate", &val, NULL);
732 * @player: #GstPlayer instance
733 * @position: position to seek in nanoseconds
735 * Seeks the currently-playing stream to the absolute @position time
739 gst_player_seek (GstPlayer * self, GstClockTime position)
741 g_return_if_fail (GST_IS_PLAYER (self));
742 g_return_if_fail (GST_CLOCK_TIME_IS_VALID (position));
744 gst_play_seek (self->play, position);
748 * gst_player_get_uri:
749 * @player: #GstPlayer instance
751 * Gets the URI of the currently-playing stream.
753 * Returns: (transfer full) (nullable): a string containing the URI of the
754 * currently-playing stream. g_free() after usage.
757 gst_player_get_uri (GstPlayer * self)
761 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_URI);
763 g_object_get (self, "uri", &val, NULL);
769 * gst_player_set_uri:
770 * @player: #GstPlayer instance
771 * @uri: (nullable): next URI to play.
773 * Sets the next URI to play.
776 gst_player_set_uri (GstPlayer * self, const gchar * val)
778 g_return_if_fail (GST_IS_PLAYER (self));
780 g_object_set (self, "uri", val, NULL);
784 * gst_player_set_subtitle_uri:
785 * @player: #GstPlayer instance
786 * @uri: (nullable): subtitle URI
788 * Sets the external subtitle URI. This should be combined with a call to
789 * gst_player_set_subtitle_track_enabled(@player, TRUE) so the subtitles are actually
793 gst_player_set_subtitle_uri (GstPlayer * self, const gchar * suburi)
795 g_return_if_fail (GST_IS_PLAYER (self));
797 g_object_set (self, "suburi", suburi, NULL);
801 * gst_player_get_subtitle_uri:
802 * @player: #GstPlayer instance
804 * current subtitle URI
806 * Returns: (transfer full) (nullable): URI of the current external subtitle.
807 * g_free() after usage.
810 gst_player_get_subtitle_uri (GstPlayer * self)
814 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
816 g_object_get (self, "suburi", &val, NULL);
822 * gst_player_get_position:
823 * @player: #GstPlayer instance
825 * Returns: the absolute position time, in nanoseconds, of the
826 * currently-playing stream.
829 gst_player_get_position (GstPlayer * self)
833 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_POSITION);
835 g_object_get (self, "position", &val, NULL);
841 * gst_player_get_duration:
842 * @player: #GstPlayer instance
844 * Retrieves the duration of the media stream that self represents.
846 * Returns: the duration of the currently-playing media stream, in
850 gst_player_get_duration (GstPlayer * self)
854 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_DURATION);
856 g_object_get (self, "duration", &val, NULL);
862 * gst_player_get_volume:
863 * @player: #GstPlayer instance
865 * Returns the current volume level, as a percentage between 0 and 1.
867 * Returns: the volume as percentage between 0 and 1.
870 gst_player_get_volume (GstPlayer * self)
874 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_VOLUME);
876 g_object_get (self, "volume", &val, NULL);
882 * gst_player_set_volume:
883 * @player: #GstPlayer instance
884 * @val: the new volume level, as a percentage between 0 and 1
886 * Sets the volume level of the stream as a percentage between 0 and 1.
888 * This volume is a linear factor. For showing the volume in a GUI it
889 * might make sense to first convert from a different format. Volume sliders
890 * should usually use a cubic volume. See gst_stream_volume_convert_volume().
893 gst_player_set_volume (GstPlayer * self, gdouble val)
895 g_return_if_fail (GST_IS_PLAYER (self));
897 g_object_set (self, "volume", val, NULL);
901 * gst_player_get_mute:
902 * @player: #GstPlayer instance
904 * Returns: %TRUE if the currently-playing stream is muted.
907 gst_player_get_mute (GstPlayer * self)
911 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_MUTE);
913 g_object_get (self, "mute", &val, NULL);
919 * gst_player_set_mute:
920 * @player: #GstPlayer instance
921 * @val: Mute state the should be set
923 * %TRUE if the currently-playing stream should be muted.
926 gst_player_set_mute (GstPlayer * self, gboolean val)
928 g_return_if_fail (GST_IS_PLAYER (self));
930 g_object_set (self, "mute", val, NULL);
934 * gst_player_get_pipeline:
935 * @player: #GstPlayer instance
937 * Returns: (transfer full): The internal playbin instance.
939 * The caller should free it with g_object_unref()
942 gst_player_get_pipeline (GstPlayer * self)
946 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
948 g_object_get (self, "pipeline", &val, NULL);
954 * gst_player_get_media_info:
955 * @player: #GstPlayer instance
957 * A Function to get the current media info #GstPlayerMediaInfo instance.
959 * Returns: (transfer full) (nullable): media info instance.
961 * The caller should free it with g_object_unref()
964 gst_player_get_media_info (GstPlayer * self)
966 GstPlayMediaInfo *info;
967 GstPlayerMediaInfo *ret;
969 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
971 info = gst_play_get_media_info (self->play);
975 ret = gst_player_media_info_wrapped (info);
976 g_object_unref (info);
981 * gst_player_get_current_audio_track:
982 * @player: #GstPlayer instance
984 * A Function to get current audio #GstPlayerAudioInfo instance.
986 * Returns: (transfer full) (nullable): current audio track.
988 * The caller should free it with g_object_unref()
991 gst_player_get_current_audio_track (GstPlayer * self)
993 GstPlayAudioInfo *info;
994 GstPlayerAudioInfo *ret = NULL;
996 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
998 info = gst_play_get_current_audio_track (self->play);
1000 ret = gst_player_audio_info_wrapped (info);
1001 g_object_unref (info);
1007 * gst_player_get_current_video_track:
1008 * @player: #GstPlayer instance
1010 * A Function to get current video #GstPlayerVideoInfo instance.
1012 * Returns: (transfer full) (nullable): current video track.
1014 * The caller should free it with g_object_unref()
1016 GstPlayerVideoInfo *
1017 gst_player_get_current_video_track (GstPlayer * self)
1019 GstPlayVideoInfo *info;
1020 GstPlayerVideoInfo *ret = NULL;
1022 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1024 info = gst_play_get_current_video_track (self->play);
1026 ret = gst_player_video_info_wrapped (info);
1027 g_object_unref (info);
1033 * gst_player_get_current_subtitle_track:
1034 * @player: #GstPlayer instance
1036 * A Function to get current subtitle #GstPlayerSubtitleInfo instance.
1038 * Returns: (transfer full) (nullable): current subtitle track.
1040 * The caller should free it with g_object_unref()
1042 GstPlayerSubtitleInfo *
1043 gst_player_get_current_subtitle_track (GstPlayer * self)
1045 GstPlaySubtitleInfo *info;
1046 GstPlayerSubtitleInfo *ret = NULL;
1048 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1050 info = gst_play_get_current_subtitle_track (self->play);
1052 ret = gst_player_subtitle_info_wrapped (info);
1053 g_object_unref (info);
1059 * gst_player_set_audio_track:
1060 * @player: #GstPlayer instance
1061 * @stream_index: stream index
1063 * Returns: %TRUE or %FALSE
1065 * Sets the audio track @stream_idex.
1068 gst_player_set_audio_track (GstPlayer * self, gint stream_index)
1070 g_return_val_if_fail (GST_IS_PLAYER (self), 0);
1072 return gst_play_set_audio_track (self->play, stream_index);
1076 * gst_player_set_video_track:
1077 * @player: #GstPlayer instance
1078 * @stream_index: stream index
1080 * Returns: %TRUE or %FALSE
1082 * Sets the video track @stream_index.
1085 gst_player_set_video_track (GstPlayer * self, gint stream_index)
1087 g_return_val_if_fail (GST_IS_PLAYER (self), 0);
1089 return gst_play_set_video_track (self->play, stream_index);
1093 * gst_player_set_subtitle_track:
1094 * @player: #GstPlayer instance
1095 * @stream_index: stream index
1097 * Returns: %TRUE or %FALSE
1099 * Sets the subtitle stack @stream_index.
1102 gst_player_set_subtitle_track (GstPlayer * self, gint stream_index)
1104 g_return_val_if_fail (GST_IS_PLAYER (self), 0);
1106 return gst_play_set_subtitle_track (self->play, stream_index);
1110 * gst_player_set_audio_track_enabled:
1111 * @player: #GstPlayer instance
1112 * @enabled: TRUE or FALSE
1114 * Enable or disable the current audio track.
1117 gst_player_set_audio_track_enabled (GstPlayer * self, gboolean enabled)
1119 g_return_if_fail (GST_IS_PLAYER (self));
1121 gst_play_set_audio_track_enabled (self->play, enabled);
1125 * gst_player_set_video_track_enabled:
1126 * @player: #GstPlayer instance
1127 * @enabled: TRUE or FALSE
1129 * Enable or disable the current video track.
1132 gst_player_set_video_track_enabled (GstPlayer * self, gboolean enabled)
1134 g_return_if_fail (GST_IS_PLAYER (self));
1136 gst_play_set_video_track_enabled (self->play, enabled);
1140 * gst_player_set_subtitle_track_enabled:
1141 * @player: #GstPlayer instance
1142 * @enabled: TRUE or FALSE
1144 * Enable or disable the current subtitle track.
1147 gst_player_set_subtitle_track_enabled (GstPlayer * self, gboolean enabled)
1149 g_return_if_fail (GST_IS_PLAYER (self));
1151 gst_play_set_subtitle_track_enabled (self->play, enabled);
1155 * gst_player_set_visualization:
1156 * @player: #GstPlayer instance
1157 * @name: (nullable): visualization element obtained from
1158 * #gst_player_visualizations_get()
1160 * Returns: %TRUE if the visualizations was set correctly. Otherwise,
1164 gst_player_set_visualization (GstPlayer * self, const gchar * name)
1166 g_return_val_if_fail (GST_IS_PLAYER (self), FALSE);
1168 return gst_play_set_visualization (self->play, name);
1172 * gst_player_get_current_visualization:
1173 * @player: #GstPlayer instance
1175 * Returns: (transfer full) (nullable): Name of the currently enabled
1177 * g_free() after usage.
1180 gst_player_get_current_visualization (GstPlayer * self)
1182 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1184 return gst_play_get_current_visualization (self->play);
1188 * gst_player_set_visualization_enabled:
1189 * @player: #GstPlayer instance
1190 * @enabled: TRUE or FALSE
1192 * Enable or disable the visualization.
1195 gst_player_set_visualization_enabled (GstPlayer * self, gboolean enabled)
1197 g_return_if_fail (GST_IS_PLAYER (self));
1199 gst_play_set_visualization_enabled (self->play, enabled);
1204 const gchar *label; /* channel label name */
1205 const gchar *name; /* get_name () */
1208 static const struct CBChannelMap cb_channel_map[] = {
1209 /* GST_PLAYER_COLOR_BALANCE_BRIGHTNESS */ {"BRIGHTNESS", "brightness"},
1210 /* GST_PLAYER_COLOR_BALANCE_CONTRAST */ {"CONTRAST", "contrast"},
1211 /* GST_PLAYER_COLOR_BALANCE_SATURATION */ {"SATURATION", "saturation"},
1212 /* GST_PLAYER_COLOR_BALANCE_HUE */ {"HUE", "hue"},
1216 * gst_player_has_color_balance:
1217 * @player:#GstPlayer instance
1219 * Checks whether the @player has color balance support available.
1221 * Returns: %TRUE if @player has color balance support. Otherwise,
1225 gst_player_has_color_balance (GstPlayer * self)
1227 g_return_val_if_fail (GST_IS_PLAYER (self), FALSE);
1229 return gst_play_has_color_balance (self->play);
1233 * gst_player_set_color_balance:
1234 * @player: #GstPlayer instance
1235 * @type: #GstPlayerColorBalanceType
1236 * @value: The new value for the @type, ranged [0,1]
1238 * Sets the current value of the indicated channel @type to the passed
1242 gst_player_set_color_balance (GstPlayer * self, GstPlayerColorBalanceType type,
1245 g_return_if_fail (GST_IS_PLAYER (self));
1246 g_return_if_fail (value >= 0.0 && value <= 1.0);
1248 gst_play_set_color_balance (self->play, (GstPlayColorBalanceType) type,
1253 * gst_player_get_color_balance:
1254 * @player: #GstPlayer instance
1255 * @type: #GstPlayerColorBalanceType
1257 * Retrieve the current value of the indicated @type.
1259 * Returns: The current value of @type, between [0,1]. In case of
1260 * error -1 is returned.
1263 gst_player_get_color_balance (GstPlayer * self, GstPlayerColorBalanceType type)
1265 g_return_val_if_fail (GST_IS_PLAYER (self), -1);
1267 return gst_play_get_color_balance (self->play,
1268 (GstPlayColorBalanceType) type);
1272 * gst_player_get_multiview_mode:
1273 * @player: #GstPlayer instance
1275 * Retrieve the current value of the indicated @type.
1277 * Returns: The current value of @type, Default: -1 "none"
1281 GstVideoMultiviewFramePacking
1282 gst_player_get_multiview_mode (GstPlayer * self)
1284 GstVideoMultiviewFramePacking val = GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE;
1286 g_return_val_if_fail (GST_IS_PLAYER (self),
1287 GST_VIDEO_MULTIVIEW_FRAME_PACKING_NONE);
1289 g_object_get (self, "video-multiview-mode", &val, NULL);
1295 * gst_player_set_multiview_mode:
1296 * @player: #GstPlayer instance
1297 * @mode: The new value for the @type
1299 * Sets the current value of the indicated mode @type to the passed
1305 gst_player_set_multiview_mode (GstPlayer * self,
1306 GstVideoMultiviewFramePacking mode)
1308 g_return_if_fail (GST_IS_PLAYER (self));
1310 g_object_set (self, "video-multiview-mode", mode, NULL);
1314 * gst_player_get_multiview_flags:
1315 * @player: #GstPlayer instance
1317 * Retrieve the current value of the indicated @type.
1319 * Returns: The current value of @type, Default: 0x00000000 "none
1323 GstVideoMultiviewFlags
1324 gst_player_get_multiview_flags (GstPlayer * self)
1326 GstVideoMultiviewFlags val = GST_VIDEO_MULTIVIEW_FLAGS_NONE;
1328 g_return_val_if_fail (GST_IS_PLAYER (self), val);
1330 g_object_get (self, "video-multiview-flags", &val, NULL);
1336 * gst_player_set_multiview_flags:
1337 * @player: #GstPlayer instance
1338 * @flags: The new value for the @type
1340 * Sets the current value of the indicated mode @type to the passed
1346 gst_player_set_multiview_flags (GstPlayer * self, GstVideoMultiviewFlags flags)
1348 g_return_if_fail (GST_IS_PLAYER (self));
1350 g_object_set (self, "video-multiview-flags", flags, NULL);
1354 * gst_player_get_audio_video_offset:
1355 * @player: #GstPlayer instance
1357 * Retrieve the current value of audio-video-offset property
1359 * Returns: The current value of audio-video-offset in nanoseconds
1364 gst_player_get_audio_video_offset (GstPlayer * self)
1368 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_AUDIO_VIDEO_OFFSET);
1370 g_object_get (self, "audio-video-offset", &val, NULL);
1376 * gst_player_set_audio_video_offset:
1377 * @player: #GstPlayer instance
1378 * @offset: #gint64 in nanoseconds
1380 * Sets audio-video-offset property by value of @offset
1385 gst_player_set_audio_video_offset (GstPlayer * self, gint64 offset)
1387 g_return_if_fail (GST_IS_PLAYER (self));
1389 g_object_set (self, "audio-video-offset", offset, NULL);
1393 * gst_player_get_subtitle_video_offset:
1394 * @player: #GstPlayer instance
1396 * Retrieve the current value of subtitle-video-offset property
1398 * Returns: The current value of subtitle-video-offset in nanoseconds
1403 gst_player_get_subtitle_video_offset (GstPlayer * self)
1407 g_return_val_if_fail (GST_IS_PLAYER (self), DEFAULT_SUBTITLE_VIDEO_OFFSET);
1409 g_object_get (self, "subtitle-video-offset", &val, NULL);
1415 * gst_player_set_subtitle_video_offset:
1416 * @player: #GstPlayer instance
1417 * @offset: #gint64 in nanoseconds
1419 * Sets subtitle-video-offset property by value of @offset
1424 gst_player_set_subtitle_video_offset (GstPlayer * self, gint64 offset)
1426 g_return_if_fail (GST_IS_PLAYER (self));
1428 g_object_set (self, "subtitle-video-offset", offset, NULL);
1432 #define C_ENUM(v) ((gint) v)
1433 #define C_FLAGS(v) ((guint) v)
1436 gst_player_color_balance_type_get_type (void)
1438 static gsize id = 0;
1439 static const GEnumValue values[] = {
1440 {C_ENUM (GST_PLAYER_COLOR_BALANCE_HUE), "GST_PLAYER_COLOR_BALANCE_HUE",
1442 {C_ENUM (GST_PLAYER_COLOR_BALANCE_BRIGHTNESS),
1443 "GST_PLAYER_COLOR_BALANCE_BRIGHTNESS", "brightness"},
1444 {C_ENUM (GST_PLAYER_COLOR_BALANCE_SATURATION),
1445 "GST_PLAYER_COLOR_BALANCE_SATURATION", "saturation"},
1446 {C_ENUM (GST_PLAYER_COLOR_BALANCE_CONTRAST),
1447 "GST_PLAYER_COLOR_BALANCE_CONTRAST", "contrast"},
1451 if (g_once_init_enter (&id)) {
1452 GType tmp = g_enum_register_static ("GstPlayerColorBalanceType", values);
1453 g_once_init_leave (&id, tmp);
1460 * gst_player_color_balance_type_get_name:
1461 * @type: a #GstPlayerColorBalanceType
1463 * Gets a string representing the given color balance type.
1465 * Returns: (transfer none): a string with the name of the color
1469 gst_player_color_balance_type_get_name (GstPlayerColorBalanceType type)
1471 g_return_val_if_fail (type >= GST_PLAYER_COLOR_BALANCE_BRIGHTNESS &&
1472 type <= GST_PLAYER_COLOR_BALANCE_HUE, NULL);
1474 return cb_channel_map[type].name;
1478 gst_player_state_get_type (void)
1480 static gsize id = 0;
1481 static const GEnumValue values[] = {
1482 {C_ENUM (GST_PLAYER_STATE_STOPPED), "GST_PLAYER_STATE_STOPPED", "stopped"},
1483 {C_ENUM (GST_PLAYER_STATE_BUFFERING), "GST_PLAYER_STATE_BUFFERING",
1485 {C_ENUM (GST_PLAYER_STATE_PAUSED), "GST_PLAYER_STATE_PAUSED", "paused"},
1486 {C_ENUM (GST_PLAYER_STATE_PLAYING), "GST_PLAYER_STATE_PLAYING", "playing"},
1490 if (g_once_init_enter (&id)) {
1491 GType tmp = g_enum_register_static ("GstPlayerState", values);
1492 g_once_init_leave (&id, tmp);
1499 * gst_player_state_get_name:
1500 * @state: a #GstPlayerState
1502 * Gets a string representing the given state.
1504 * Returns: (transfer none): a string with the name of the state.
1507 gst_player_state_get_name (GstPlayerState state)
1510 case GST_PLAYER_STATE_STOPPED:
1512 case GST_PLAYER_STATE_BUFFERING:
1514 case GST_PLAYER_STATE_PAUSED:
1516 case GST_PLAYER_STATE_PLAYING:
1520 g_assert_not_reached ();
1525 gst_player_error_get_type (void)
1527 static gsize id = 0;
1528 static const GEnumValue values[] = {
1529 {C_ENUM (GST_PLAYER_ERROR_FAILED), "GST_PLAYER_ERROR_FAILED", "failed"},
1533 if (g_once_init_enter (&id)) {
1534 GType tmp = g_enum_register_static ("GstPlayerError", values);
1535 g_once_init_leave (&id, tmp);
1542 * gst_player_error_get_name:
1543 * @error: a #GstPlayerError
1545 * Gets a string representing the given error.
1547 * Returns: (transfer none): a string with the given error.
1550 gst_player_error_get_name (GstPlayerError error)
1553 case GST_PLAYER_ERROR_FAILED:
1557 g_assert_not_reached ();
1562 * gst_player_set_config:
1563 * @player: #GstPlayer instance
1564 * @config: (transfer full): a #GstStructure
1566 * Set the configuration of the player. If the player is already configured, and
1567 * the configuration haven't change, this function will return %TRUE. If the
1568 * player is not in the GST_PLAYER_STATE_STOPPED, this method will return %FALSE
1569 * and active configuration will remain.
1571 * @config is a #GstStructure that contains the configuration parameters for
1574 * This function takes ownership of @config.
1576 * Returns: %TRUE when the configuration could be set.
1580 gst_player_set_config (GstPlayer * self, GstStructure * config)
1582 g_return_val_if_fail (GST_IS_PLAYER (self), FALSE);
1583 g_return_val_if_fail (config != NULL, FALSE);
1585 return gst_play_set_config (self->play, config);
1589 * gst_player_get_config:
1590 * @player: #GstPlayer instance
1592 * Get a copy of the current configuration of the player. This configuration
1593 * can either be modified and used for the gst_player_set_config() call
1594 * or it must be freed after usage.
1596 * Returns: (transfer full): a copy of the current configuration of @player. Use
1597 * gst_structure_free() after usage or gst_player_set_config().
1602 gst_player_get_config (GstPlayer * self)
1604 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1606 return gst_play_get_config (self->play);
1610 * gst_player_config_set_user_agent:
1611 * @config: a #GstPlayer configuration
1612 * @agent: (nullable): the string to use as user agent
1614 * Set the user agent to pass to the server if @player needs to connect
1615 * to a server during playback. This is typically used when playing HTTP
1621 gst_player_config_set_user_agent (GstStructure * config, const gchar * agent)
1623 g_return_if_fail (config != NULL);
1624 g_return_if_fail (agent != NULL);
1626 gst_structure_id_set (config,
1627 CONFIG_QUARK (USER_AGENT), G_TYPE_STRING, agent, NULL);
1631 * gst_player_config_get_user_agent:
1632 * @config: a #GstPlayer configuration
1634 * Return the user agent which has been configured using
1635 * gst_player_config_set_user_agent() if any.
1637 * Returns: (transfer full) (nullable): the configured agent, or %NULL
1642 gst_player_config_get_user_agent (const GstStructure * config)
1644 gchar *agent = NULL;
1646 g_return_val_if_fail (config != NULL, NULL);
1648 gst_structure_id_get (config,
1649 CONFIG_QUARK (USER_AGENT), G_TYPE_STRING, &agent, NULL);
1655 * gst_player_config_set_position_update_interval:
1656 * @config: a #GstPlayer configuration
1657 * @interval: interval in ms
1659 * set interval in milliseconds between two position-updated signals.
1660 * pass 0 to stop updating the position.
1665 gst_player_config_set_position_update_interval (GstStructure * config,
1668 g_return_if_fail (config != NULL);
1669 g_return_if_fail (interval <= 10000);
1671 gst_structure_id_set (config,
1672 CONFIG_QUARK (POSITION_INTERVAL_UPDATE), G_TYPE_UINT, interval, NULL);
1676 * gst_player_config_get_position_update_interval:
1677 * @config: a #GstPlayer configuration
1679 * Returns: current position update interval in milliseconds
1684 gst_player_config_get_position_update_interval (const GstStructure * config)
1686 guint interval = DEFAULT_POSITION_UPDATE_INTERVAL_MS;
1688 g_return_val_if_fail (config != NULL, DEFAULT_POSITION_UPDATE_INTERVAL_MS);
1690 gst_structure_id_get (config,
1691 CONFIG_QUARK (POSITION_INTERVAL_UPDATE), G_TYPE_UINT, &interval, NULL);
1697 * gst_player_config_set_seek_accurate:
1698 * @config: a #GstPlayer configuration
1699 * @accurate: accurate seek or not
1701 * Enable or disable accurate seeking. When enabled, elements will try harder
1702 * to seek as accurately as possible to the requested seek position. Generally
1703 * it will be slower especially for formats that don't have any indexes or
1704 * timestamp markers in the stream.
1706 * If accurate seeking is disabled, elements will seek as close as the request
1707 * position without slowing down seeking too much.
1709 * Accurate seeking is disabled by default.
1714 gst_player_config_set_seek_accurate (GstStructure * config, gboolean accurate)
1716 g_return_if_fail (config != NULL);
1718 gst_structure_id_set (config,
1719 CONFIG_QUARK (ACCURATE_SEEK), G_TYPE_BOOLEAN, accurate, NULL);
1723 * gst_player_config_get_seek_accurate:
1724 * @config: a #GstPlayer configuration
1726 * Returns: %TRUE if accurate seeking is enabled
1731 gst_player_config_get_seek_accurate (const GstStructure * config)
1733 gboolean accurate = FALSE;
1735 g_return_val_if_fail (config != NULL, FALSE);
1737 gst_structure_id_get (config,
1738 CONFIG_QUARK (ACCURATE_SEEK), G_TYPE_BOOLEAN, &accurate, NULL);
1744 * gst_player_get_video_snapshot:
1745 * @player: #GstPlayer instance
1746 * @format: output format of the video snapshot
1747 * @config: (allow-none): Additional configuration
1749 * Get a snapshot of the currently selected video stream, if any. The format can be
1750 * selected with @format and optional configuration is possible with @config
1751 * Currently supported settings are:
1752 * - width, height of type G_TYPE_INT
1753 * - pixel-aspect-ratio of type GST_TYPE_FRACTION
1754 * Except for GST_PLAYER_THUMBNAIL_RAW_NATIVE format, if no config is set, pixel-aspect-ratio would be 1/1
1756 * Returns: (transfer full) (nullable): Current video snapshot sample or %NULL on failure
1761 gst_player_get_video_snapshot (GstPlayer * self,
1762 GstPlayerSnapshotFormat format, const GstStructure * config)
1764 g_return_val_if_fail (GST_IS_PLAYER (self), NULL);
1766 return gst_play_get_video_snapshot (self->play,
1767 (GstPlaySnapshotFormat) format, config);