gstreamer-encoder: Add SPICE_ENCODE_GPU to select gpu for va plugin

This commit is contained in:
Michael Scherle 2025-05-14 16:46:59 +02:00
parent 6c1a518539
commit 04de0657cf

View File

@ -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++) {