diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c index 0957a2b2..d449f073 100644 --- a/server/gstreamer-encoder.c +++ b/server/gstreamer-encoder.c @@ -958,10 +958,29 @@ static bool gst_features_lookup(const gchar *feature_name) return true; } +static const gchar *get_encode_gpu(){ + + const gchar* env_encode_gpu_str = g_getenv("SPICE_ENCODE_GPU"); + if ((!env_encode_gpu_str) || (strcmp(env_encode_gpu_str, "renderD128") == 0)) { + return NULL; + } + + g_autoptr(GRegex) regex = g_regex_new("renderD1[[:digit:]]{2}", 0, 0, NULL); + if (g_regex_match(regex, env_encode_gpu_str, 0, NULL)) { + return env_encode_gpu_str; + } + return NULL; +} + static gchar *find_best_hw_plugin(const gchar *codec_name) { - static const char plugins[][8] = {"msdk", "va", "vaapi"}; + char plugins[][20] = {"msdk", "va", "vaapi"}; gchar *feature_name; + const gchar *encode_gpu = get_encode_gpu(); + if (encode_gpu) { + g_strlcat(plugins[1], encode_gpu, sizeof(plugins[1])); + } + int i; for (i = 0; i < G_N_ELEMENTS(plugins); i++) {