Skip to content

Commit

Permalink
GFX: use the preferred codec preferred in the config (H264 or RFX)
Browse files Browse the repository at this point in the history
  • Loading branch information
metalefty committed Aug 27, 2024
1 parent 0b26fb3 commit e5f3602
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
22 changes: 17 additions & 5 deletions xrdp/xrdp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions xrdp/xrdp_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion xrdp/xrdp_wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit e5f3602

Please sign in to comment.