From 2c2585cc90e525b72620440cb857a151c042d6f5 Mon Sep 17 00:00:00 2001 From: Koichiro Iwao Date: Mon, 26 Aug 2024 18:23:10 +0900 Subject: [PATCH] GFX: use the preferred codec preferred in the config (H264 or RFX) --- xrdp/xrdp_mm.c | 22 +++++++++++++++++----- xrdp/xrdp_types.h | 3 +++ xrdp/xrdp_wm.c | 10 +++++++++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index a22f2f192..1853b7b2f 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -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", diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 110b1d004..c5c80975e 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -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; diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index c93d959d8..1efffc150 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -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 */