Skip to content

Commit

Permalink
Merge pull request neutrinolabs#3329 from neutrinolabs/v0.10-h264
Browse files Browse the repository at this point in the history
Merge v0.10-h264 into v0.10
  • Loading branch information
metalefty authored Dec 4, 2024
2 parents b866c50 + 9ac1558 commit f8d9f16
Show file tree
Hide file tree
Showing 37 changed files with 2,725 additions and 42 deletions.
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 --enable-openh264"
CONF_FLAGS_i386_max: "--enable-ipv6 --enable-jpeg --enable-mp3lame
--enable-opus --enable-rfxcodec --enable-painter
--disable-pixman --with-imlib2 --with-freetype2
Expand Down
23 changes: 21 additions & 2 deletions common/xrdp_client_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ enum client_resize_mode
CRMODE_MULTI_SCREEN
};

enum xrdp_capture_code
{
CC_SIMPLE = 0,
CC_SUF_A16 = 1,
CC_SUF_RFX = 2,
CC_SUF_A2 = 3,
CC_GFX_PRO = 4,
CC_GFX_A2 = 5
};

/**
* Information about the xrdp client
*
Expand Down Expand Up @@ -170,7 +180,7 @@ struct xrdp_client_info
int mcs_early_capability_flags;

int max_fastpath_frag_bytes;
int capture_code;
int pad0; /* unused */
int capture_format;

char certificate[1024];
Expand All @@ -182,6 +192,13 @@ struct xrdp_client_info
char variant[16];
char options[256];

enum xrdp_capture_code capture_code;

/* xorgxrdp: frame capture interval (milliseconds) */
int rfx_frame_interval;
int h264_frame_interval;
int normal_frame_interval;

/* ==================================================================== */
/* Private to xrdp below this line */
/* ==================================================================== */
Expand Down Expand Up @@ -228,6 +245,8 @@ struct xrdp_client_info

// Can we resize the desktop by using a Deactivation-Reactivation Sequence?
enum client_resize_mode client_resize_mode;

int pad1; /* unused; unicode_input_state */
};

enum xrdp_encoder_flags
Expand All @@ -247,6 +266,6 @@ enum xrdp_encoder_flags

/* yyyymmdd of last incompatible change to xrdp_client_info */
/* also used for changes to all the xrdp installed headers */
#define CLIENT_INFO_CURRENT_VERSION 20230425
#define CLIENT_INFO_CURRENT_VERSION 20241118

#endif
5 changes: 5 additions & 0 deletions common/xrdp_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@
#define MCS_SDRQ 25 /* Send Data Request */
#define MCS_SDIN 26 /* Send Data Indication */

/* xorgxrdp: frame capture interval (milliseconds) */
#define DEFAULT_RFX_FRAME_INTERVAL 32
#define DEFAULT_H264_FRAME_INTERVAL 16
#define DEFAULT_NORMAL_FRAME_INTERVAL 40

/******************************************************************************
*
* Constants come from other Microsoft products
Expand Down
15 changes: 14 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,14 @@ AC_ARG_ENABLE(pixman, AS_HELP_STRING([--enable-pixman],
[Use pixman library (default: no)]),
[], [enable_pixman=no])
AM_CONDITIONAL(XRDP_PIXMAN, [test x$enable_pixman = xyes])

AC_ARG_ENABLE(x264, AS_HELP_STRING([--enable-x264],
[Use x264 library (default: no)]),
[], [enable_x264=no])
AM_CONDITIONAL(XRDP_X264, [test x$enable_x264 = xyes])
AC_ARG_ENABLE(openh264, AS_HELP_STRING([--enable-openh264],
[Use Cisco OpenH264 library (default: no)]),
[], [enable_openh264=no])
AM_CONDITIONAL(XRDP_OPENH264, [test x$enable_openh264 = xyes])
AC_ARG_ENABLE(painter, AS_HELP_STRING([--disable-painter],
[Do not use included painter library (default: no)]),
[], [enable_painter=yes])
Expand Down Expand Up @@ -467,6 +474,10 @@ fi

AS_IF( [test "x$enable_pixman" = "xyes"] , [PKG_CHECK_MODULES(PIXMAN, pixman-1 >= 0.1.0)] )

AS_IF( [test "x$enable_x264" = "xyes"] , [PKG_CHECK_MODULES(XRDP_X264, x264 >= 0.3.0)] )

AS_IF( [test "x$enable_openh264" = "xyes"] , [PKG_CHECK_MODULES(XRDP_OPENH264, openh264 >= 2.0.0)] )

# checking for TurboJPEG
if test "x$enable_tjpeg" = "xyes"
then
Expand Down Expand Up @@ -624,6 +635,8 @@ echo " fdkaac $enable_fdkaac"
echo " jpeg $enable_jpeg"
echo " turbo jpeg $enable_tjpeg"
echo " rfxcodec $enable_rfxcodec"
echo " x264 $enable_x264"
echo " openh264 $enable_openh264"
echo " painter $enable_painter"
echo " pixman $enable_pixman"
echo " fuse $enable_fuse"
Expand Down
4 changes: 3 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,9 @@ in
libfdk-aac-dev \
libimlib2-dev \
libopus-dev \
libpixman-1-dev"
libpixman-1-dev \
libx264-dev
libopenh264-dev"
;;
*)
echo "unsupported feature set: $FEATURE_SET"
Expand Down
32 changes: 31 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,19 @@ 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_h264_only.toml \
gfx/gfx_codec_h264_preferred.toml \
gfx/gfx_codec_order_undefined.toml \
gfx/gfx_codec_rfx_only.toml \
gfx/gfx_codec_rfx_preferred_odd.toml \
gfx/gfx_codec_rfx_preferred.toml \
gfx/gfx_h264_encoder_invalid.toml \
gfx/gfx_h264_encoder_openh264.toml \
gfx/gfx_h264_encoder_undefined.toml \
gfx/gfx_h264_encoder_x264.toml \
gfx/gfx_missing_h264.toml

TESTS = test_xrdp
check_PROGRAMS = test_xrdp
Expand All @@ -28,6 +41,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 +61,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 +75,23 @@ 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

if XRDP_OPENH264
AM_CPPFLAGS += -DXRDP_X264 $(XRDP_OPENH264_CFLAGS)
test_xrdp_LDADD += \
$(top_builddir)/xrdp/xrdp_encoder_openh264.o \
$(XRDP_OPENH264_LIBS)
endif
86 changes: 86 additions & 0 deletions tests/xrdp/gfx/gfx.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[codec]
order = [ "H.264", "RFX" ]

# Specify a preferred H.264 encoder, "x264" or "OpenH264".
# This parameter takes effect only when more than one encoder is
# enabled at compile time. If only one encoder is enabled, the encoder
# will be used regardless the value of this parameter.
h264_encoder = "OpenH264"

#
# Configurations for x264
#
[x264.default]
# NOTE: x264 specifies bitrate in unit of kbps.
preset = "ultrafast"
tune = "zerolatency"
profile = "main" # profile is forced to baseline if preset == ultrafast
vbv_max_bitrate = 0
vbv_buffer_size = 0
fps_num = 60
fps_den = 1

[x264.lan]
# inherits default

[x264.wan]
vbv_max_bitrate = 15_000
vbv_buffer_size = 1_500

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

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

[x264.broadband_low]
preset = "veryfast"
vbv_max_bitrate = 1_600
vbv_buffer_size = 66

[x264.modem]
preset = "fast"
vbv_max_bitrate = 1_200
vbv_buffer_size = 50

#
# Configurations for OpenH264
#
[OpenH264.default]
# NOTE: OpenH264 specifies bitrate in unit of bps, not kbps.
EnableFrameSkip = false
TargetBitrate = 20_000_000
MaxBitrate = 0 # unspecified
MaxFrameRate = 60.0

[OpenH264.lan]
# inherits default

[OpenH264.wan]
TargetBitrate = 10_000_000
MaxBitrate = 12_000_000

[OpenH264.broadband_high]
EnableFrameSkip = true
TargetBitrate = 8_000_000
MaxBitrate = 10_000_000

[OpenH264.satellite]
EnableFrameSkip = true
TargetBitrate = 4_000_000
MaxBitrate = 6_000_000

[OpenH264.broadband_low]
EnableFrameSkip = true
TargetBitrate = 1_600_000
MaxBitrate = 1_800_000

[OpenH264.modem]
EnableFrameSkip = true
TargetBitrate = 600_000
MaxBitrate = 1_200_000

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]
Loading

0 comments on commit f8d9f16

Please sign in to comment.