From 50c8c3bc9f298630b17a598fb306456d50ec72c9 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Sun, 14 Jul 2024 19:09:35 -0400 Subject: [PATCH] Enable RDP access plugin --- freerdp2.patch | 239 +++++++++++++++++++++++++++++++++++++++++++++++++ vlc.spec | 17 +++- 2 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 freerdp2.patch diff --git a/freerdp2.patch b/freerdp2.patch new file mode 100644 index 0000000..0aa2942 --- /dev/null +++ b/freerdp2.patch @@ -0,0 +1,239 @@ +From 1c27f57498b7e0f52acc7b4520c4172a2462632d Mon Sep 17 00:00:00 2001 +From: Juliane de Sartiges +Date: Wed, 27 Jul 2022 09:32:25 +0200 +Subject: [PATCH] freerdp: update to freerdp2 api + +--- + configure.ac | 2 +- + modules/access/rdp.c | 85 ++++++++++++++++++++------------------------ + 2 files changed, 40 insertions(+), 47 deletions(-) + +diff --git a/configure.ac b/configure.ac +index b454198157..cb23a9b2ab 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -2094,7 +2094,7 @@ PKG_ENABLE_MODULES_VLC([VNC], [vnc], [libvncclient >= 0.9.9], (VNC/rfb client su + + dnl RDP/Remote Desktop access module + dnl +-PKG_ENABLE_MODULES_VLC([FREERDP], [rdp], [freerdp >= 1.0.1], (RDP/Remote Desktop client support) ) ++PKG_ENABLE_MODULES_VLC([FREERDP], [rdp], [freerdp2 >= 2.0.0], (RDP/Remote Desktop client support) ) + + dnl + dnl Real RTSP plugin +diff --git a/modules/access/rdp.c b/modules/access/rdp.c +index 0c39663c64..04ae005938 100644 +--- a/modules/access/rdp.c ++++ b/modules/access/rdp.c +@@ -45,18 +45,6 @@ + # include + #endif + +-#if !defined(FREERDP_VERSION_MAJOR) || \ +- (defined(FREERDP_VERSION_MAJOR) && !(FREERDP_VERSION_MAJOR > 1 || (FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR >= 1))) +-# define SoftwareGdi sw_gdi +-# define Fullscreen fullscreen +-# define ServerHostname hostname +-# define Username username +-# define Password password +-# define ServerPort port +-# define EncryptionMethods encryption +-# define ContextSize context_size +-#endif +- + #include + #ifdef HAVE_POLL + # include +@@ -75,6 +63,8 @@ + + #define CFG_PREFIX "rdp-" + ++#define FREERDP_PIXEL_BPP(_format) (_format >> 24) ++ + /***************************************************************************** + * Module descriptor + *****************************************************************************/ +@@ -139,11 +129,12 @@ typedef struct vlcrdp_context_t vlcrdp_context_t; + + /* updates handlers */ + +-static void desktopResizeHandler( rdpContext *p_context ) ++static BOOL desktopResizeHandler( rdpContext *p_context ) + { + vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_context; + demux_sys_t *p_sys = p_vlccontext->p_demux->p_sys; + rdpGdi *p_gdi = p_context->gdi; ++ int i_colordepth = FREERDP_PIXEL_BPP( p_gdi->dstFormat ); + + if ( p_sys->es ) + { +@@ -151,11 +142,13 @@ static void desktopResizeHandler( rdpContext *p_context ) + p_sys->es = NULL; + } + +- /* Now init and fill es format */ + vlc_fourcc_t i_chroma; +- switch( p_gdi->bytesPerPixel ) ++ /* Now init and fill es format */ ++ switch ( i_colordepth ) + { + default: ++ msg_Dbg( p_vlccontext->p_demux, "invalid color depth %d", i_colordepth); ++ /* fallthrough */ + case 16: + i_chroma = VLC_CODEC_RGB16; + break; +@@ -163,7 +156,7 @@ static void desktopResizeHandler( rdpContext *p_context ) + i_chroma = VLC_CODEC_RGB24; + break; + case 32: +- i_chroma = VLC_CODEC_RGB32; ++ i_chroma = VLC_CODEC_ARGB; + break; + } + es_format_t fmt; +@@ -176,7 +169,7 @@ static void desktopResizeHandler( rdpContext *p_context ) + fmt.video.i_height = p_gdi->height; + fmt.video.i_frame_rate_base = 1000; + fmt.video.i_frame_rate = 1000 * p_sys->f_fps; +- p_sys->i_framebuffersize = p_gdi->width * p_gdi->height * p_gdi->bytesPerPixel; ++ p_sys->i_framebuffersize = p_gdi->width * p_gdi->height * (i_colordepth >> 3); + + if ( p_sys->p_block ) + p_sys->p_block = block_Realloc( p_sys->p_block, 0, p_sys->i_framebuffersize ); +@@ -184,20 +177,21 @@ static void desktopResizeHandler( rdpContext *p_context ) + p_sys->p_block = block_Alloc( p_sys->i_framebuffersize ); + + p_sys->es = es_out_Add( p_vlccontext->p_demux->out, &fmt ); ++ return TRUE; + } + +-static void beginPaintHandler( rdpContext *p_context ) ++static BOOL beginPaintHandler( rdpContext *p_context ) + { + vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_context; + demux_sys_t *p_sys = p_vlccontext->p_demux->p_sys; + rdpGdi *p_gdi = p_context->gdi; +- p_gdi->primary->hdc->hwnd->invalid->null = 1; +- p_gdi->primary->hdc->hwnd->ninvalid = 0; ++ p_gdi->primary->hdc->hwnd->invalid->null = TRUE; + if ( ! p_sys->p_block && p_sys->i_framebuffersize ) + p_sys->p_block = block_Alloc( p_sys->i_framebuffersize ); ++ return TRUE; + } + +-static void endPaintHandler( rdpContext *p_context ) ++static BOOL endPaintHandler( rdpContext *p_context ) + { + vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_context; + demux_sys_t *p_sys = p_vlccontext->p_demux->p_sys; +@@ -208,11 +202,12 @@ static void endPaintHandler( rdpContext *p_context ) + p_sys->p_block->i_buffer = p_sys->i_framebuffersize; + memcpy( p_sys->p_block->p_buffer, p_gdi->primary_buffer, p_sys->p_block->i_buffer ); + } ++ return TRUE; + } + + /* instance handlers */ + +-static bool preConnectHandler( freerdp *p_instance ) ++static BOOL preConnectHandler( freerdp *p_instance ) + { + vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_instance->context; + demux_sys_t *p_sys = p_vlccontext->p_demux->p_sys; +@@ -229,49 +224,54 @@ static bool preConnectHandler( freerdp *p_instance ) + p_instance->settings->EncryptionMethods = + var_InheritBool( p_vlccontext->p_demux, CFG_PREFIX "encrypt" ); + +- return true; ++ return TRUE; + } + +-static bool postConnectHandler( freerdp *p_instance ) ++static BOOL postConnectHandler( freerdp *p_instance ) + { + vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_instance->context; + + msg_Dbg( p_vlccontext->p_demux, "connected to desktop %dx%d (%d bpp)", +-#if defined(FREERDP_VERSION_MAJOR) && (FREERDP_VERSION_MAJOR > 1 || (FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR >= 1)) + p_instance->settings->DesktopWidth, + p_instance->settings->DesktopHeight, + p_instance->settings->ColorDepth +-#else +- p_instance->settings->width, +- p_instance->settings->height, +- p_instance->settings->color_depth +-#endif + ); + + p_instance->update->DesktopResize = desktopResizeHandler; + p_instance->update->BeginPaint = beginPaintHandler; + p_instance->update->EndPaint = endPaintHandler; ++ UINT32 format; ++ switch ( p_instance->settings->ColorDepth ) ++ { ++ default: ++ msg_Dbg( p_vlccontext->p_demux, "no valid pixel format found for color depth %d bpp", p_instance->settings->ColorDepth); ++ /* fallthrough */ ++ case 16: ++ format = PIXEL_FORMAT_RGB16; ++ break; ++ case 24: ++ format = PIXEL_FORMAT_RGB24; ++ break; ++ case 32: ++ format = PIXEL_FORMAT_ARGB32; ++ break; ++ } + + gdi_init( p_instance, +- CLRBUF_16BPP | +-#if defined(FREERDP_VERSION_MAJOR) && defined(FREERDP_VERSION_MINOR) && \ +- !(FREERDP_VERSION_MAJOR > 1 || (FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR >= 2)) +- CLRBUF_24BPP | +-#endif +- CLRBUF_32BPP, NULL ); ++ format ); + + desktopResizeHandler( p_instance->context ); +- return true; ++ return TRUE; + } + +-static bool authenticateHandler( freerdp *p_instance, char** ppsz_username, ++static BOOL authenticateHandler( freerdp *p_instance, char** ppsz_username, + char** ppsz_password, char** ppsz_domain ) + { + VLC_UNUSED(ppsz_domain); + vlcrdp_context_t * p_vlccontext = (vlcrdp_context_t *) p_instance->context; + *ppsz_username = var_InheritString( p_vlccontext->p_demux, CFG_PREFIX "user" ); + *ppsz_password = var_InheritString( p_vlccontext->p_demux, CFG_PREFIX "password" ); +- return true; ++ return TRUE; + } + + /***************************************************************************** +@@ -432,10 +432,6 @@ static int Open( vlc_object_t *p_this ) + if ( p_sys->f_fps <= 0 ) p_sys->f_fps = 1.0; + p_sys->i_frame_interval = 1000000 / p_sys->f_fps; + +-#if FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR < 2 +- freerdp_channels_global_init(); +-#endif +- + p_sys->p_instance = freerdp_new(); + if ( !p_sys->p_instance ) + { +@@ -512,9 +508,6 @@ static void Close( vlc_object_t *p_this ) + + freerdp_disconnect( p_sys->p_instance ); + freerdp_free( p_sys->p_instance ); +-#if FREERDP_VERSION_MAJOR == 1 && FREERDP_VERSION_MINOR < 2 +- freerdp_channels_global_uninit(); +-#endif + + if ( p_sys->p_block ) + block_Release( p_sys->p_block ); +-- +2.45.2 + diff --git a/vlc.spec b/vlc.spec index 342035e..ec77e11 100644 --- a/vlc.spec +++ b/vlc.spec @@ -47,6 +47,8 @@ Patch: appdata.patch Patch: libidn2.patch # fix deprecated lua math functions (rhbz#2280091) Patch: lua-math.patch +# update to freerdp2 api; backport from master +Patch: freerdp2.patch %{load:%{S:1}} %global __provides_exclude_from ^%{vlc_plugindir}/.*$ @@ -100,7 +102,7 @@ BuildRequires: pkgconfig(flac) #BuildRequires: pkgconfig(fluidlite) BuildRequires: pkgconfig(fluidsynth) >= 1.1.2 BuildRequires: pkgconfig(fontconfig) >= 2.11 -#BuildRequires: pkgconfig(freerdp) +BuildRequires: pkgconfig(freerdp2) BuildRequires: pkgconfig(freetype2) BuildRequires: pkgconfig(fribidi) BuildRequires: pkgconfig(gl) @@ -426,6 +428,14 @@ Requires: %{name}-plugins-base%{?_isa} = %{epoch}:%{version}-%{release} %description plugin-pulseaudio PulseAudio plugins for VLC media player +# requires freerdp2, for RDP remote desktop support +%package plugin-rdp +Summary: VLC media player RDP plugin +Requires: %{name}-libs%{?_isa} = %{epoch}:%{version}-%{release} +Requires: %{name}-plugins-base%{?_isa} = %{epoch}:%{version}-%{release} +%description plugin-rdp +RDP access plugin for VLC media player + # requires libsmbclient, for SMB protocol support %package plugin-samba Summary: VLC media player SMB plugin @@ -532,7 +542,7 @@ export LIVE555_PREFIX=%{_prefix} --enable-libcddb \ --enable-screen \ --enable-vnc \ - --disable-freerdp \ + --enable-freerdp \ --enable-realrtsp \ --enable-asdcp%{!?with_asdcp:=no} \ \ @@ -873,6 +883,9 @@ make check %{vlc_plugindir}/audio_output/libpulse_plugin.so %{vlc_plugindir}/services_discovery/libpulselist_plugin.so +%files plugin-rdp +%{vlc_plugindir}/access/librdp_plugin.so + %files plugin-samba %{vlc_plugindir}/access/libsmb_plugin.so