GFX: use the preferred codec preferred in the config (H264 or RFX)

This commit is contained in:
Koichiro Iwao 2024-08-26 18:23:10 +09:00
parent 7238f8f99d
commit 2c2585cc90
3 changed files with 29 additions and 6 deletions

View File

@ -1432,19 +1432,31 @@ xrdp_mm_egfx_caps_advertise(void *user, int caps_count,
break;
}
}
#if defined(XRDP_H264)
struct xrdp_tconfig_gfx_codec_order co = self->wm->gfx_config->codec;
bool_t use_h264 = (best_h264_index >= 0 && (best_pro_index < 0 || (co.h264_idx >= 0 && co.h264_idx < co.rfx_idx)));
if (use_h264)
{
best_index = best_h264_index;
self->egfx_flags = XRDP_EGFX_H264;
}
else if (best_pro_index >= 0)
{
best_index = best_pro_index;
self->egfx_flags = XRDP_EGFX_RFX_PRO;
}
#else
if (best_pro_index >= 0)
{
best_index = best_pro_index;
self->egfx_flags = XRDP_EGFX_RFX_PRO;
}
/* prefer h264, todo use setting in xrdp.ini for this */
if (best_h264_index >= 0)
{
#if defined(XRDP_H264)
best_index = best_h264_index;
self->egfx_flags = XRDP_EGFX_H264;
#endif
}
#endif
if (best_index >= 0)
{
LOG(LOG_LEVEL_INFO, " replying version 0x%8.8x flags 0x%8.8x",

View File

@ -30,6 +30,7 @@
#include "guid.h"
#include "scancode.h"
#include "xrdp_client_info.h"
#include "xrdp_tconfig.h"
#define MAX_NR_CHANNELS 16
#define MAX_CHANNEL_NAME 16
@ -581,6 +582,8 @@ struct xrdp_wm
/* configuration derived from xrdp.ini */
struct xrdp_config *xrdp_config;
/* configuration derived from gfx.toml */
struct xrdp_tconfig_gfx *gfx_config;
struct xrdp_region *screen_dirty_region;
int last_screen_draw_time;

View File

@ -115,8 +115,9 @@ xrdp_wm_create(struct xrdp_process *owner,
self->target_surface = self->screen;
self->current_surface_index = 0xffff; /* screen */
/* to store configuration from xrdp.ini */
/* to store configuration from xrdp.ini, gfx.toml */
self->xrdp_config = g_new0(struct xrdp_config, 1);
self->gfx_config = g_new0(struct xrdp_tconfig_gfx, 1);
/* Load the channel config so libxrdp can check whether
drdynvc is enabled or not */
@ -163,6 +164,11 @@ xrdp_wm_delete(struct xrdp_wm *self)
g_free(self->xrdp_config);
}
if (self->gfx_config)
{
g_free(self->gfx_config);
}
/* free self */
g_free(self);
}
@ -643,6 +649,8 @@ xrdp_wm_init(struct xrdp_wm *self)
load_xrdp_config(self->xrdp_config, self->session->xrdp_ini,
self->screen->bpp);
tconfig_load_gfx(XRDP_CFG_PATH "/gfx.toml", self->gfx_config);
/* Remove a font loaded on the previous config */
xrdp_font_delete(self->default_font);
self->painter->font = NULL; /* May be set to the default_font */