Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.10] H264 cherry picks #3225

Merged
merged 12 commits into from
Aug 29, 2024
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ jobs:
--disable-pixman"
CONF_FLAGS_amd64_max: "--enable-ipv6 --enable-jpeg --enable-fuse --enable-mp3lame
--enable-fdkaac --enable-opus --enable-rfxcodec --enable-painter
--enable-pixman --with-imlib2 --with-freetype2 --enable-tests"
--enable-pixman --with-imlib2 --with-freetype2 --enable-tests
--enable-x264"
CONF_FLAGS_i386_max: "--enable-ipv6 --enable-jpeg --enable-mp3lame
--enable-opus --enable-rfxcodec --enable-painter
--disable-pixman --with-imlib2 --with-freetype2
Expand Down
3 changes: 2 additions & 1 deletion scripts/install_xrdp_build_dependencies_with_apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ in
libfdk-aac-dev \
libimlib2-dev \
libopus-dev \
libpixman-1-dev"
libpixman-1-dev \
libx264-dev"
;;
*)
echo "unsupported feature set: $FEATURE_SET"
Expand Down
20 changes: 19 additions & 1 deletion tests/xrdp/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
AM_CPPFLAGS = \
-DXRDP_TOP_SRCDIR=\"$(top_srcdir)\" \
-I$(top_builddir) \
-I$(top_srcdir)/xrdp \
-I$(top_srcdir)/libxrdp \
Expand All @@ -18,7 +19,14 @@ EXTRA_DIST = \
test_not4_8bit.bmp \
test_not4_24bit.bmp \
test1.jpg \
test_alpha_blend.png
test_alpha_blend.png \
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_preferred_odd.toml \
gfx/gfx_codec_rfx_only.toml

TESTS = test_xrdp
check_PROGRAMS = test_xrdp
Expand All @@ -28,6 +36,7 @@ test_xrdp_SOURCES = \
test_xrdp_main.c \
test_xrdp_egfx.c \
test_xrdp_region.c \
test_tconfig.c \
test_bitmap_load.c

test_xrdp_CFLAGS = \
Expand All @@ -47,6 +56,7 @@ test_xrdp_LDADD = \
$(top_builddir)/libxrdp/libxrdp.la \
$(top_builddir)/libpainter/src/libpainter.la \
$(top_builddir)/librfxcodec/src/librfxencode.la \
$(top_builddir)/third_party/tomlc99/libtoml.la \
$(top_builddir)/xrdp/lang.o \
$(top_builddir)/xrdp/xrdp_mm.o \
$(top_builddir)/xrdp/xrdp_wm.o \
Expand All @@ -60,8 +70,16 @@ test_xrdp_LDADD = \
$(top_builddir)/xrdp/xrdp_encoder.o \
$(top_builddir)/xrdp/xrdp_process.o \
$(top_builddir)/xrdp/xrdp_login_wnd.o \
$(top_builddir)/xrdp/xrdp_tconfig.o \
$(top_builddir)/xrdp/xrdp_main_utils.o \
$(PIXMAN_LIBS) \
$(IMLIB2_LIBS) \
@CHECK_LIBS@ \
@CMOCKA_LIBS@

if XRDP_X264
AM_CPPFLAGS += -DXRDP_X264 $(XRDP_X264_CFLAGS)
test_xrdp_LDADD += \
$(top_builddir)/xrdp/xrdp_encoder_x264.o \
$(XRDP_X264_LIBS)
endif
40 changes: 40 additions & 0 deletions tests/xrdp/gfx/gfx.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[codec]
order = [ "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]
# inherits default

[x264.wan]
vbv_max_bitrate = 15000
vbv_buffer_size = 1500

[x264.broadband_high]
preset = "superfast"
vbv_max_bitrate = 8000
vbv_buffer_Size = 800

[x264.satellite]
preset = "superfast"
vbv_max_bitrate = 5000
vbv_buffer_size = 500

[x264.broadband_low]
preset = "veryfast"
tune = "zerolatency"
vbv_max_bitrate = 1600
vbv_buffer_size = 66

[x264.modem]
preset = "fast"
tune = "zerolatency"
vbv_max_bitrate = 1200
vbv_buffer_size = 50
18 changes: 18 additions & 0 deletions tests/xrdp/gfx/gfx_codec_h264_only.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[codec]
order = [ "H.264" ]

[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]
18 changes: 18 additions & 0 deletions tests/xrdp/gfx/gfx_codec_h264_preferred.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[codec]
order = [ "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]
18 changes: 18 additions & 0 deletions tests/xrdp/gfx/gfx_codec_order_undefined.toml
Original file line number Diff line number Diff line change
@@ -0,0 +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]
18 changes: 18 additions & 0 deletions tests/xrdp/gfx/gfx_codec_rfx_only.toml
Original file line number Diff line number Diff line change
@@ -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]
18 changes: 18 additions & 0 deletions tests/xrdp/gfx/gfx_codec_rfx_preferred.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[codec]
order = [ "RFX", "H.264" ]

[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]
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]
9 changes: 9 additions & 0 deletions tests/xrdp/gfx/gfx_missing_h264.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[codec]
order = [ "H.264", "RFX" ]

[x264.lan]
[x264.wan]
[x264.broadband_high]
[x264.satellite]
[x264.broadband_low]
[x264.modem]
117 changes: 117 additions & 0 deletions tests/xrdp/test_tconfig.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#if defined(HAVE_CONFIG_H)
#include "config_ac.h"
#endif

#include "xrdp_tconfig.h"
#include "test_xrdp.h"
#include "xrdp.h"

#define GFXCONF_STUBDIR XRDP_TOP_SRCDIR "/tests/xrdp/gfx/"

START_TEST(test_tconfig_gfx_always_success)
{
ck_assert_int_eq(1, 1);
}
END_TEST

START_TEST(test_tconfig_gfx_x264_load_basic)
{
struct xrdp_tconfig_gfx gfxconfig;
int rv = tconfig_load_gfx(GFXCONF_STUBDIR "/gfx.toml", &gfxconfig);

ck_assert_int_eq(rv, 0);

/* default */
ck_assert_str_eq(gfxconfig.x264_param[0].preset, "ultrafast");
ck_assert_str_eq(gfxconfig.x264_param[0].tune, "zerolatency");
ck_assert_str_eq(gfxconfig.x264_param[0].profile, "main");
ck_assert_int_eq(gfxconfig.x264_param[0].vbv_max_bitrate, 0);
ck_assert_int_eq(gfxconfig.x264_param[0].vbv_buffer_size, 0);
ck_assert_int_eq(gfxconfig.x264_param[0].fps_num, 24);
ck_assert_int_eq(gfxconfig.x264_param[0].fps_den, 1);

}
END_TEST

START_TEST(test_tconfig_gfx_codec_order)
{
struct xrdp_tconfig_gfx gfxconfig;

/* H264 earlier */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_h264_preferred.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 2);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_H264);
ck_assert_int_eq(gfxconfig.codec.codecs[1], XTC_RFX);

/* H264 only */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_h264_only.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 1);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_H264);

/* RFX earlier */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_rfx_preferred.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 2);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_RFX);
ck_assert_int_eq(gfxconfig.codec.codecs[1], XTC_H264);

/* RFX appears twice like: RFX, H264, RFX */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_rfx_preferred_odd.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 2);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_RFX);
ck_assert_int_eq(gfxconfig.codec.codecs[1], XTC_H264);

/* RFX only */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_rfx_only.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 1);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_RFX);

/* H264 is preferred if order undefined */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_codec_order_undefined.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 2);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_H264);
ck_assert_int_eq(gfxconfig.codec.codecs[1], XTC_RFX);
}
END_TEST

START_TEST(test_tconfig_gfx_missing_file)
{
struct xrdp_tconfig_gfx gfxconfig;

/* Check RFX config is returned if the file doesn't exist */
tconfig_load_gfx(GFXCONF_STUBDIR "/no_such_file.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 1);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_RFX);
}
END_TEST

START_TEST(test_tconfig_gfx_missing_h264)
{
struct xrdp_tconfig_gfx gfxconfig;

/* Check RFX config only is returned if H.264 parameters are missing */
tconfig_load_gfx(GFXCONF_STUBDIR "/gfx_missing_h264.toml", &gfxconfig);
ck_assert_int_eq(gfxconfig.codec.codec_count, 1);
ck_assert_int_eq(gfxconfig.codec.codecs[0], XTC_RFX);
}
END_TEST

/******************************************************************************/
Suite *
make_suite_tconfig_load_gfx(void)
{
Suite *s;
TCase *tc_tconfig_load_gfx;

s = suite_create("GfxLoad");

tc_tconfig_load_gfx = tcase_create("xrdp_tconfig_load_gfx");
tcase_add_test(tc_tconfig_load_gfx, test_tconfig_gfx_always_success);
tcase_add_test(tc_tconfig_load_gfx, test_tconfig_gfx_x264_load_basic);
tcase_add_test(tc_tconfig_load_gfx, test_tconfig_gfx_codec_order);
tcase_add_test(tc_tconfig_load_gfx, test_tconfig_gfx_missing_file);
tcase_add_test(tc_tconfig_load_gfx, test_tconfig_gfx_missing_h264);

suite_add_tcase(s, tc_tconfig_load_gfx);

return s;
}
1 change: 1 addition & 0 deletions tests/xrdp/test_xrdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
Suite *make_suite_test_bitmap_load(void);
Suite *make_suite_egfx_base_functions(void);
Suite *make_suite_region(void);
Suite *make_suite_tconfig_load_gfx(void);

#endif /* TEST_XRDP_H */
1 change: 1 addition & 0 deletions tests/xrdp/test_xrdp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ int main (void)
sr = srunner_create (make_suite_test_bitmap_load());
srunner_add_suite(sr, make_suite_egfx_base_functions());
srunner_add_suite(sr, make_suite_region());
srunner_add_suite(sr, make_suite_tconfig_load_gfx());

srunner_set_tap(sr, "-");
srunner_run_all (sr, CK_ENV);
Expand Down
3 changes: 3 additions & 0 deletions xrdp/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ xrdp_SOURCES = \
xrdp_egfx.h \
xrdp_wm.c \
xrdp_main_utils.c \
xrdp_tconfig.c \
xrdp_tconfig.h \
$(XRDP_EXTRA_SOURCES)

xrdp_LDADD = \
Expand Down Expand Up @@ -103,6 +105,7 @@ SUFFIXES = .in
$(subst_verbose)$(SUBST_VARS) $< > $@

dist_xrdpsysconf_DATA = \
gfx.toml \
xrdp_keyboard.ini

nodist_xrdpsysconf_DATA = \
Expand Down
Loading