diff --git a/tests/xrdp/Makefile.am b/tests/xrdp/Makefile.am index b80cae1d3..f8a630ed3 100644 --- a/tests/xrdp/Makefile.am +++ b/tests/xrdp/Makefile.am @@ -25,8 +25,9 @@ EXTRA_DIST = \ gfx/gfx.toml\ gfx/gfx_codec_order_undefined.toml \ gfx/gfx_codec_h264_preferred.toml \ + gfx/gfx_codec_h264_only.toml \ gfx/gfx_codec_rfx_preferred.toml - + gfx/gfx_codec_rfx_only.toml TESTS = test_xrdp check_PROGRAMS = test_xrdp diff --git a/tests/xrdp/gfx/gfx_codec_h264_only.toml b/tests/xrdp/gfx/gfx_codec_h264_only.toml new file mode 100644 index 000000000..c7d45605b --- /dev/null +++ b/tests/xrdp/gfx/gfx_codec_h264_only.toml @@ -0,0 +1,18 @@ +[codec] +order = [ "H264" ] + +[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] diff --git a/tests/xrdp/gfx/gfx_codec_h264_preferred.toml b/tests/xrdp/gfx/gfx_codec_h264_preferred.toml index 828a65cb6..948f94201 100644 --- a/tests/xrdp/gfx/gfx_codec_h264_preferred.toml +++ b/tests/xrdp/gfx/gfx_codec_h264_preferred.toml @@ -1,3 +1,18 @@ [codec] - order = [ "H264", "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] diff --git a/tests/xrdp/gfx/gfx_codec_order_undefined.toml b/tests/xrdp/gfx/gfx_codec_order_undefined.toml index e31872683..7432cb97b 100644 --- a/tests/xrdp/gfx/gfx_codec_order_undefined.toml +++ b/tests/xrdp/gfx/gfx_codec_order_undefined.toml @@ -1,3 +1,18 @@ [codec] - order = [ ] + +[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] diff --git a/tests/xrdp/gfx/gfx_codec_rfx_only.toml b/tests/xrdp/gfx/gfx_codec_rfx_only.toml new file mode 100644 index 000000000..9ab14ea2f --- /dev/null +++ b/tests/xrdp/gfx/gfx_codec_rfx_only.toml @@ -0,0 +1,18 @@ +[codec] +order = [ "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] diff --git a/tests/xrdp/gfx/gfx_codec_rfx_preferred.toml b/tests/xrdp/gfx/gfx_codec_rfx_preferred.toml index e9d52f02e..b0b6a56a8 100644 --- a/tests/xrdp/gfx/gfx_codec_rfx_preferred.toml +++ b/tests/xrdp/gfx/gfx_codec_rfx_preferred.toml @@ -1,3 +1,18 @@ [codec] - order = [ "RFX", "H264" ] + +[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] diff --git a/tests/xrdp/test_tconfig.c b/tests/xrdp/test_tconfig.c index bdc5797f1..9bcffd3be 100644 --- a/tests/xrdp/test_tconfig.c +++ b/tests/xrdp/test_tconfig.c @@ -37,14 +37,30 @@ START_TEST(test_tconfig_gfx_codec_order) /* H264 earlier */ tconfig_load_gfx("./gfx/gfx_codec_h264_preferred.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.h264_idx, gfxconfig.codec.rfx_idx); + /* H264 only */ + tconfig_load_gfx("./gfx/gfx_codec_h264_only.toml", &gfxconfig); + ck_assert_int_gt(gfxconfig.codec.h264_idx, -1); + ck_assert_int_eq(gfxconfig.codec.rfx_idx, -1); + /* RFX earlier */ tconfig_load_gfx("./gfx/gfx_codec_rfx_preferred.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("./gfx/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 */ tconfig_load_gfx("./gfx/gfx_codec_order_undefined.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.h264_idx, gfxconfig.codec.rfx_idx); } END_TEST diff --git a/xrdp/xrdp_tconfig.c b/xrdp/xrdp_tconfig.c index d71959086..58d6d8deb 100644 --- a/xrdp/xrdp_tconfig.c +++ b/xrdp/xrdp_tconfig.c @@ -201,11 +201,19 @@ tconfig_load_gfx_x264_ct(toml_table_t *tfile, const int connection_type, static int tconfig_load_gfx_order(toml_table_t *tfile, struct xrdp_tconfig_gfx *config) { + /* + * This config loader is not responsible to check if xrdp is built with + * H264/RFX support. Just loads configurations as-is. + */ + TCLOG(LOG_LEVEL_DEBUG, "tconfig_load_gfx_order:"); int h264_found = 0; int rfx_found = 0; + config->codec.h264_idx = -1; + config->codec.rfx_idx = -1; + toml_table_t *codec = toml_table_in(tfile, "codec"); if (!codec) { @@ -253,6 +261,7 @@ static int tconfig_load_gfx_order(toml_table_t *tfile, struct xrdp_tconfig_gfx * return 0; return_default_codec_order: + /* prefer H264 if no priority found */ config->codec.h264_idx = 0; config->codec.rfx_idx = 1;