Skip to content

Commit

Permalink
tconfig: review fixes
Browse files Browse the repository at this point in the history
- Use H.264 (with a dot) in config
- Take care of odd case
- Fix an incorrect comment
  • Loading branch information
metalefty committed Aug 24, 2024
1 parent 3076724 commit 12287b9
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions tests/xrdp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ EXTRA_DIST = \
gfx/gfx_codec_h264_preferred.toml \
gfx/gfx_codec_h264_only.toml \
gfx/gfx_codec_rfx_preferred.toml \
gfx/gfx_codec_rfx_preferred_odd.toml \
gfx/gfx_codec_rfx_only.toml

TESTS = test_xrdp
Expand Down
2 changes: 1 addition & 1 deletion tests/xrdp/gfx/gfx.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codec]
order = [ "H264", "RFX" ]
order = [ "H.264", "RFX" ]

[x264.default]
preset = "ultrafast"
Expand Down
2 changes: 1 addition & 1 deletion tests/xrdp/gfx/gfx_codec_h264_only.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codec]
order = [ "H264" ]
order = [ "H.264" ]

[x264.default]
preset = "ultrafast"
Expand Down
2 changes: 1 addition & 1 deletion tests/xrdp/gfx/gfx_codec_h264_preferred.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codec]
order = [ "H264", "RFX" ]
order = [ "H.264", "RFX" ]

[x264.default]
preset = "ultrafast"
Expand Down
2 changes: 1 addition & 1 deletion tests/xrdp/gfx/gfx_codec_rfx_preferred.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codec]
order = [ "RFX", "H264" ]
order = [ "RFX", "H.264" ]

[x264.default]
preset = "ultrafast"
Expand Down
18 changes: 18 additions & 0 deletions tests/xrdp/gfx/gfx_codec_rfx_preferred_odd.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[codec]
order = [ "RFX", "H.264", "RFX" ]

[x264.default]
preset = "ultrafast"
tune = "zerolatency"
profile = "main" # profile is forced to baseline if preset == ultrafast
vbv_max_bitrate = 0
vbv_buffer_size = 0
fps_num = 24
fps_den = 1

[x264.lan]
[x264.wan]
[x264.broadband_high]
[x264.satellite]
[x264.broadband_low]
[x264.modem]
8 changes: 7 additions & 1 deletion tests/xrdp/test_tconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ START_TEST(test_tconfig_gfx_codec_order)
ck_assert_int_gt(gfxconfig.codec.rfx_idx, -1);
ck_assert_int_lt(gfxconfig.codec.rfx_idx, gfxconfig.codec.h264_idx);

/* RFX appears twice like: RFX, H264, RFX */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_rfx_preferred_odd.toml", &gfxconfig);
ck_assert_int_gt(gfxconfig.codec.h264_idx, -1);
ck_assert_int_gt(gfxconfig.codec.rfx_idx, -1);
ck_assert_int_lt(gfxconfig.codec.rfx_idx, gfxconfig.codec.h264_idx);

/* RFX only */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_rfx_only.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.h264_idx, -1);
ck_assert_int_gt(gfxconfig.codec.rfx_idx, -1);

/* RFX is preferred if order undefined */
/* H264 is preferred if order undefined */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_order_undefined.toml", &gfxconfig);
ck_assert_int_gt(gfxconfig.codec.h264_idx, -1);
ck_assert_int_gt(gfxconfig.codec.rfx_idx, -1);
Expand Down
8 changes: 5 additions & 3 deletions xrdp/xrdp_tconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,15 @@ static int tconfig_load_gfx_order(toml_table_t *tfile, struct xrdp_tconfig_gfx *

if (datum.ok)
{
if (g_strcasecmp(datum.u.s, "h264") == 0 ||
g_strcasecmp(datum.u.s, "h.264") == 0)
if (h264_found == 0 &&
(g_strcasecmp(datum.u.s, "h264") == 0 ||
g_strcasecmp(datum.u.s, "h.264") == 0))
{
h264_found = 1;
config->codec.h264_idx = i;
}
if (g_strcasecmp(datum.u.s, "rfx") == 0)
if (rfx_found == 0 &&
g_strcasecmp(datum.u.s, "rfx") == 0)
{
rfx_found = 1;
config->codec.rfx_idx = i;
Expand Down

0 comments on commit 12287b9

Please sign in to comment.