mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-08-06 18:52:33 +00:00
fix: set device-path for gstreamer plugins correctly
This commit is contained in:
parent
d298bb2f14
commit
d9a4417e7b
@ -977,16 +977,49 @@ static bool gst_features_lookup(const gchar *feature_name)
|
||||
}
|
||||
|
||||
|
||||
int getRenderNum(const char *rendernode){
|
||||
char resolved[PATH_MAX];
|
||||
if (rendernode == NULL){
|
||||
return -1;
|
||||
}
|
||||
if (!realpath(rendernode, resolved)) {
|
||||
perror("realpath");
|
||||
return -1;
|
||||
}
|
||||
char *match = strstr(resolved, "renderD");
|
||||
if (!match) {
|
||||
return -1;
|
||||
}
|
||||
int num;
|
||||
if (sscanf(match, "renderD%d", &num) != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (num > 191 || num < 0){
|
||||
return -1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
static gchar *find_best_hw_plugin(const gchar *codec_name, const char *rendernode)
|
||||
{
|
||||
char plugins[][8] = {"va","msdk", "vaapi"};
|
||||
char postproc[][10] ={"postproc","vpp","postproc"};
|
||||
gchar *feature_name;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(plugins); i++) {
|
||||
if (codec_name == NULL){
|
||||
// first plugin is also va but for a specific render
|
||||
char plugins[][16] = {"", "va", "msdk", "vaapi"};
|
||||
const char *postproc[] = {"postproc", "postproc", "vpp", "postproc"};
|
||||
|
||||
int renderNum = getRenderNum(rendernode);
|
||||
gchar *feature_name = NULL;
|
||||
int i = 1; //
|
||||
|
||||
if (renderNum != -1 && renderNum != 128) {
|
||||
|
||||
snprintf(plugins[0], sizeof(plugins[0]), "varenderD%d", renderNum);
|
||||
i = 0;
|
||||
}
|
||||
|
||||
|
||||
for (; i < G_N_ELEMENTS(plugins); i++) {
|
||||
|
||||
if (codec_name == NULL) {
|
||||
feature_name = g_strdup_printf("%s%s", plugins[i], postproc[i]);
|
||||
if (!gst_features_lookup(feature_name)) {
|
||||
g_free(feature_name);
|
||||
@ -996,6 +1029,8 @@ static gchar *find_best_hw_plugin(const gchar *codec_name, const char *rendernod
|
||||
feature_name = g_strconcat(plugins[i], codec_name, "enc", NULL);
|
||||
if (!gst_features_lookup(feature_name)) {
|
||||
g_free(feature_name);
|
||||
|
||||
// Fallback to low-power encoder alternative
|
||||
feature_name = g_strconcat(plugins[i], codec_name, "lpenc", NULL);
|
||||
if (!gst_features_lookup(feature_name)) {
|
||||
g_free(feature_name);
|
||||
@ -1003,12 +1038,7 @@ static gchar *find_best_hw_plugin(const gchar *codec_name, const char *rendernod
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(i == 0 && rendernode){
|
||||
gchar * feature_name_with_render = g_strdup_printf("%s device-path=%s",feature_name, rendernode);
|
||||
g_free(feature_name);
|
||||
return feature_name_with_render;
|
||||
}
|
||||
return feature_name;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user