You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vlc/SOURCES/freerdp2.patch

240 lines
8.4 KiB

From 1c27f57498b7e0f52acc7b4520c4172a2462632d Mon Sep 17 00:00:00 2001
From: Juliane de Sartiges <jill@videolabs.io>
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 <freerdp/version.h>
#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 <errno.h>
#ifdef HAVE_POLL
# include <poll.h>
@@ -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