From 8d73b65789f3fbb853d4cba4c70a9921bfc4a438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 5 Aug 2023 17:27:31 +0100 Subject: [PATCH] shout2send: use version template in user-agent property Avoids documentation churn when the version changes. Part-of: --- .../gst-plugins-good/docs/gst_plugins_cache.json | 2 +- .../gst-plugins-good/ext/shout2/gstshout2.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/subprojects/gst-plugins-good/docs/gst_plugins_cache.json b/subprojects/gst-plugins-good/docs/gst_plugins_cache.json index c657c3d1bf..aacde23e7a 100644 --- a/subprojects/gst-plugins-good/docs/gst_plugins_cache.json +++ b/subprojects/gst-plugins-good/docs/gst_plugins_cache.json @@ -22187,7 +22187,7 @@ "construct": false, "construct-only": false, "controllable": false, - "default": "GStreamer 1.23.0.1", + "default": "GStreamer {VERSION}", "mutable": "null", "readable": true, "type": "gchararray", diff --git a/subprojects/gst-plugins-good/ext/shout2/gstshout2.c b/subprojects/gst-plugins-good/ext/shout2/gstshout2.c index 2564408ecf..99f57a5827 100644 --- a/subprojects/gst-plugins-good/ext/shout2/gstshout2.c +++ b/subprojects/gst-plugins-good/ext/shout2/gstshout2.c @@ -45,6 +45,8 @@ #include +#include + #ifndef HAVE_SHOUT_2_4_6_OR_NEWER #define shout_set_metadata_utf8 shout_set_metadata #endif @@ -88,7 +90,7 @@ enum #define DEFAULT_PUBLIC FALSE #define DEFAULT_STREAMNAME "" #define DEFAULT_DESCRIPTION "" -#define DEFAULT_USERAGENT "GStreamer " PACKAGE_VERSION +#define DEFAULT_USERAGENT "GStreamer {VERSION}" #define DEFAULT_GENRE "" #define DEFAULT_MOUNT "" #define DEFAULT_URL "" @@ -235,6 +237,9 @@ gst_shout2send_class_init (GstShout2sendClass * klass) * * User agent of the source * + * If the string contains `{VERSION}` that will be replaced with the + * GStreamer version at runtime (since GStreamer 1.24). + * * Since: 1.22 **/ @@ -574,10 +579,14 @@ gst_shout2send_start (GstBaseSink * basesink) goto set_failed; cur_prop = "agent"; - GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, sink->user_agent); - if (shout_set_agent (sink->conn, sink->user_agent) != SHOUTERR_SUCCESS) { + GString *user_agent = g_string_new (sink->user_agent); + g_string_replace (user_agent, "{VERSION}", PACKAGE_VERSION, 0); + GST_DEBUG_OBJECT (sink, "setting %s: %s", cur_prop, user_agent->str); + if (shout_set_agent (sink->conn, user_agent->str) != SHOUTERR_SUCCESS) { + g_string_free (user_agent, TRUE); goto set_failed; } + g_string_free (user_agent, TRUE); return TRUE;