From 922471688521f50568bfc625c3b747d17ca40f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 29 Jun 2024 14:49:01 +0200 Subject: [PATCH] clapper-gtk: video: Use "scaletempo" by default Do not require applications to import GStreamer and their devs to learn its basics just to set this single element. Similarly as ClapperGtkVideo sets "clappersink" during construction, it can also set "scaletempo" as this is the most common choice for an audio filter. Elements can still be changed like before if desired by setting corresponding player properties. --- src/bin/clapper-app/clapper-app-window.c | 4 ---- src/lib/clapper-gtk/clapper-gtk-video.c | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/bin/clapper-app/clapper-app-window.c b/src/bin/clapper-app/clapper-app-window.c index d591e573..2c0471ae 100644 --- a/src/bin/clapper-app/clapper-app-window.c +++ b/src/bin/clapper-app/clapper-app-window.c @@ -997,7 +997,6 @@ clapper_app_window_constructed (GObject *object) ClapperPlayer *player = clapper_app_window_get_player (self); ClapperQueue *queue = clapper_player_get_queue (player); ClapperGtkExtraMenuButton *button; - GstElement *element; AdwStyleManager *manager; static const GActionEntry win_entries[] = { @@ -1038,9 +1037,6 @@ clapper_app_window_constructed (GObject *object) /* FIXME: Allow setting sink/filter elements from prefs window * (this should include parsing bin descriptions) */ - element = gst_element_factory_make ("scaletempo", NULL); - if (G_LIKELY (element != NULL)) - clapper_player_set_audio_filter (player, element); clapper_player_set_autoplay (player, TRUE); diff --git a/src/lib/clapper-gtk/clapper-gtk-video.c b/src/lib/clapper-gtk/clapper-gtk-video.c index c50e661a..1bebea7c 100644 --- a/src/lib/clapper-gtk/clapper-gtk-video.c +++ b/src/lib/clapper-gtk/clapper-gtk-video.c @@ -1108,6 +1108,11 @@ _fading_overlay_revealed_cb (GtkRevealer *revealer, * * Creates a new #ClapperGtkVideo instance. * + * Newly created video widget will also set some default GStreamer elements + * on its [class@Clapper.Player]. This includes Clapper own video sink and + * a "scaletempo" element as audio filter. Both can still be changed after + * construction by setting corresponding player properties. + * * Returns: a new video #GtkWidget. */ GtkWidget * @@ -1397,7 +1402,7 @@ static void clapper_gtk_video_constructed (GObject *object) { ClapperGtkVideo *self = CLAPPER_GTK_VIDEO_CAST (object); - GstElement *vsink = gst_element_factory_make ("clappersink", NULL); + GstElement *afilter, *vsink; ClapperQueue *queue; self->player = clapper_player_new (); @@ -1408,6 +1413,8 @@ clapper_gtk_video_constructed (GObject *object) g_signal_connect (self->player, "notify::video-sink", G_CALLBACK (_video_sink_changed_cb), self); + vsink = gst_element_factory_make ("clappersink", NULL); + /* FIXME: This is a temporary workaround for lack * of DMA_DRM negotiation support in sink itself */ if (G_LIKELY (vsink != NULL)) { @@ -1422,9 +1429,13 @@ clapper_gtk_video_constructed (GObject *object) vsink = bin; } } + + clapper_player_set_video_sink (self->player, vsink); } - clapper_player_set_video_sink (self->player, vsink); + afilter = gst_element_factory_make ("scaletempo", NULL); + if (G_LIKELY (afilter != NULL)) + clapper_player_set_audio_filter (self->player, afilter); g_signal_connect (self->player, "error", G_CALLBACK (_player_error_cb), self);