diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c index c97243b7..d329874d 100644 --- a/server/gstreamer-encoder.c +++ b/server/gstreamer-encoder.c @@ -968,11 +968,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[][16] = {"va","msdk", "vaapi"}; + char plugins[][16] = {"va","msdk", "vaapi"}; gchar *feature_name; int i; + const gchar *encode_gpu = get_encode_gpu(); + if (encode_gpu) { + g_strlcat(plugins[0], encode_gpu, sizeof(plugins[0])); + } for (i = 0; i < G_N_ELEMENTS(plugins); i++) { feature_name = !codec_name ? g_strconcat(plugins[i], "postproc", NULL) : @@ -2123,7 +2141,7 @@ VideoEncoder *gstreamer_encoder_new(SpiceVideoCodecType codec_type, pthread_mutex_init(&encoder->outbuf_mutex, NULL); pthread_cond_init(&encoder->outbuf_cond, NULL); encoder->scaling = 1; - printf("Trying Codec: %s", get_gst_codec_name(encoder)); + printf("Trying Codec: %s \n", get_gst_codec_name(encoder)); /* All the other fields are initialized to zero by g_new0(). */ if (!create_pipeline(encoder)) {