20#ifndef FREERDP_SERVER_SHADOW_H 
   21#define FREERDP_SERVER_SHADOW_H 
   23#include <freerdp/api.h> 
   24#include <freerdp/types.h> 
   26#include <freerdp/freerdp.h> 
   27#include <freerdp/settings.h> 
   28#include <freerdp/listener.h> 
   30#include <freerdp/channels/wtsvc.h> 
   31#include <freerdp/channels/channels.h> 
   33#include <freerdp/server/encomsp.h> 
   34#include <freerdp/server/remdesk.h> 
   35#include <freerdp/server/rdpsnd.h> 
   36#if defined(CHANNEL_AUDIN_SERVER) 
   37#include <freerdp/server/audin.h> 
   39#include <freerdp/server/rdpgfx.h> 
   41#include <freerdp/codec/color.h> 
   42#include <freerdp/codec/region.h> 
   45#include <winpr/synch.h> 
   46#include <winpr/collections.h> 
   47#include <winpr/cmdline.h> 
   61  typedef struct rdp_shadow_multiclient_event rdpShadowMultiClientEvent;
 
   64  typedef int (*pfnShadowSubsystemEntry)(RDP_SHADOW_ENTRY_POINTS* pEntryPoints);
 
   66  typedef rdpShadowSubsystem* (*pfnShadowSubsystemNew)(void);
 
   67  typedef void (*pfnShadowSubsystemFree)(rdpShadowSubsystem* subsystem);
 
   69  typedef int (*pfnShadowSubsystemInit)(rdpShadowSubsystem* subsystem);
 
   70  typedef int (*pfnShadowSubsystemUninit)(rdpShadowSubsystem* subsystem);
 
   72  typedef int (*pfnShadowSubsystemStart)(rdpShadowSubsystem* subsystem);
 
   73  typedef int (*pfnShadowSubsystemStop)(rdpShadowSubsystem* subsystem);
 
   75  typedef UINT32 (*pfnShadowEnumMonitors)(
MONITOR_DEF* monitors, UINT32 maxMonitors);
 
   77  typedef int (*pfnShadowAuthenticate)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
 
   78                                       const char* user, 
const char* domain,
 
   79                                       const char* password);
 
   80  typedef BOOL (*pfnShadowClientConnect)(rdpShadowSubsystem* subsystem, rdpShadowClient* client);
 
   81  typedef void (*pfnShadowClientDisconnect)(rdpShadowSubsystem* subsystem,
 
   82                                            rdpShadowClient* client);
 
   83  typedef BOOL (*pfnShadowClientCapabilities)(rdpShadowSubsystem* subsystem,
 
   84                                              rdpShadowClient* client);
 
   86  typedef BOOL (*pfnShadowSynchronizeEvent)(rdpShadowSubsystem* subsystem,
 
   87                                            rdpShadowClient* client, UINT32 flags);
 
   88  typedef BOOL (*pfnShadowKeyboardEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
 
   89                                         UINT16 flags, UINT8 code);
 
   90  typedef BOOL (*pfnShadowUnicodeKeyboardEvent)(rdpShadowSubsystem* subsystem,
 
   91                                                rdpShadowClient* client, UINT16 flags,
 
   93  typedef BOOL (*pfnShadowMouseEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
 
   94                                      UINT16 flags, UINT16 x, UINT16 y);
 
   95  typedef BOOL (*pfnShadowRelMouseEvent)(rdpShadowSubsystem* subsystem, rdpShadowClient* client,
 
   96                                         UINT16 flags, INT16 xDelta,
 
   99  typedef BOOL (*pfnShadowExtendedMouseEvent)(rdpShadowSubsystem* subsystem,
 
  100                                              rdpShadowClient* client, UINT16 flags, UINT16 x,
 
  103  typedef BOOL (*pfnShadowChannelAudinServerReceiveSamples)(rdpShadowSubsystem* subsystem,
 
  104                                                            rdpShadowClient* client,
 
  120    wMessageQueue* MsgQueue;
 
  123    rdpShadowServer* server;
 
  124    rdpShadowEncoder* encoder;
 
  125    rdpShadowSubsystem* subsystem;
 
  131    EncomspServerContext* encomsp;
 
  132    RemdeskServerContext* remdesk;
 
  133    RdpsndServerContext* rdpsnd;
 
  134#if defined(CHANNEL_AUDIN_SERVER) 
  135    audin_server_context* audin;
 
  137    RdpgfxServerContext* rdpgfx;
 
  139    BOOL resizeRequested;
 
  142    BOOL areGfxCapsReady; 
 
 
  151    rdpSettings* settings;
 
  152    rdpShadowScreen* screen;
 
  153    rdpShadowSurface* surface;
 
  154    rdpShadowSurface* lobby;
 
  155    rdpShadowCapture* capture;
 
  156    rdpShadowSubsystem* subsystem;
 
  163    UINT32 selectedMonitor;
 
  168    H264_RATECONTROL_MODE h264RateControlMode;
 
  170    UINT32 h264FrameRate;
 
  175    char* CertificateFile;
 
  176    char* PrivateKeyFile;
 
  178    freerdp_listener* listener;
 
  180    size_t maxClientsConnected;
 
  181    BOOL SupportMultiRectBitmapUpdates; 
 
 
  187    rdpShadowServer* server;
 
 
  203    pfnShadowSubsystemNew New;
 
  204    pfnShadowSubsystemFree Free;
 
  206    pfnShadowSubsystemInit Init;
 
  207    pfnShadowSubsystemUninit Uninit;
 
  209    pfnShadowSubsystemStart Start;
 
  210    pfnShadowSubsystemStop Stop;
 
  212    pfnShadowEnumMonitors EnumMonitors;
 
 
  217    RDP_SHADOW_ENTRY_POINTS ep;
 
  220    UINT32 captureFrameRate;
 
  221    UINT32 selectedMonitor;
 
  228    rdpShadowMultiClientEvent* updateEvent;
 
  235    size_t nRdpsndFormats;
 
  237    size_t nAudinFormats;
 
  239    pfnShadowSynchronizeEvent SynchronizeEvent;
 
  240    pfnShadowKeyboardEvent KeyboardEvent;
 
  241    pfnShadowUnicodeKeyboardEvent UnicodeKeyboardEvent;
 
  242    pfnShadowMouseEvent MouseEvent;
 
  243    pfnShadowExtendedMouseEvent ExtendedMouseEvent;
 
  244    pfnShadowChannelAudinServerReceiveSamples AudinServerReceiveSamples;
 
  246    pfnShadowAuthenticate Authenticate;
 
  247    pfnShadowClientConnect ClientConnect;
 
  248    pfnShadowClientDisconnect ClientDisconnect;
 
  249    pfnShadowClientCapabilities ClientCapabilities;
 
  251    rdpShadowServer* server;
 
  253    pfnShadowRelMouseEvent RelMouseEvent; 
 
 
  257#define SHADOW_MSG_IN_REFRESH_REQUEST_ID 1001 
  260  typedef void (*MSG_OUT_FREE_FN)(UINT32 id,
 
  261                                  SHADOW_MSG_OUT* msg); 
 
  266    MSG_OUT_FREE_FN Free;
 
 
  269#define SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID 2001 
  270#define SHADOW_MSG_OUT_POINTER_ALPHA_UPDATE_ID 2002 
  271#define SHADOW_MSG_OUT_AUDIO_OUT_SAMPLES_ID 2003 
  272#define SHADOW_MSG_OUT_AUDIO_OUT_VOLUME_ID 2004 
  276    SHADOW_MSG_OUT common;
 
 
  283    SHADOW_MSG_OUT common;
 
  288    UINT32 lengthAndMask;
 
  289    UINT32 lengthXorMask;
 
 
  296    SHADOW_MSG_OUT common;
 
 
  305    SHADOW_MSG_OUT common;
 
 
  310  FREERDP_API 
void shadow_subsystem_set_entry_builtin(
const char* name);
 
  311  FREERDP_API 
void shadow_subsystem_set_entry(pfnShadowSubsystemEntry pEntry);
 
  313#if !defined(WITHOUT_FREERDP_3x_DEPRECATED) 
  314  WINPR_DEPRECATED_VAR(
 
  315      "[since 3.4.0] Use shadow_subsystem_pointer_convert_alpha_pointer_data_to_format instead",
 
  316      FREERDP_API 
int shadow_subsystem_pointer_convert_alpha_pointer_data(
 
  317          const BYTE* WINPR_RESTRICT pixels, BOOL premultiplied, UINT32 width, UINT32 height,
 
  334  FREERDP_API 
int shadow_subsystem_pointer_convert_alpha_pointer_data_to_format(
 
  335      const BYTE* WINPR_RESTRICT pixels, UINT32 format, BOOL premultiplied, UINT32 width,
 
  338  FREERDP_API 
int shadow_server_parse_command_line(rdpShadowServer* server, 
int argc, 
char** argv,
 
  340  FREERDP_API 
int shadow_server_command_line_status_print(rdpShadowServer* server, 
int argc,
 
  341                                                          char** argv, 
int status,
 
  344  FREERDP_API 
int shadow_server_start(rdpShadowServer* server);
 
  345  FREERDP_API 
int shadow_server_stop(rdpShadowServer* server);
 
  347  FREERDP_API 
int shadow_server_init(rdpShadowServer* server);
 
  348  FREERDP_API 
int shadow_server_uninit(rdpShadowServer* server);
 
  350  FREERDP_API UINT32 shadow_enum_monitors(
MONITOR_DEF* monitors, UINT32 maxMonitors);
 
  352  FREERDP_API 
void shadow_server_free(rdpShadowServer* server);
 
  354  WINPR_ATTR_MALLOC(shadow_server_free, 1)
 
  355  FREERDP_API rdpShadowServer* shadow_server_new(
void);
 
  359#if !defined(WITHOUT_FREERDP_3x_DEPRECATED) 
  360  WINPR_DEPRECATED_VAR(
"[since 3.4.0] Use shadow_capture_compare_with_format",
 
  361                       FREERDP_API 
int shadow_capture_compare(
 
  362                           const BYTE* WINPR_RESTRICT pData1, UINT32 nStep1, UINT32 nWidth,
 
  363                           UINT32 nHeight, 
const BYTE* WINPR_RESTRICT pData2, UINT32 nStep2,
 
  383  FREERDP_API 
int shadow_capture_compare_with_format(
const BYTE* WINPR_RESTRICT pData1,
 
  384                                                     UINT32 format1, UINT32 nStep1, UINT32 nWidth,
 
  386                                                     const BYTE* WINPR_RESTRICT pData2,
 
  387                                                     UINT32 format2, UINT32 nStep2,
 
  390  FREERDP_API 
void shadow_subsystem_frame_update(rdpShadowSubsystem* subsystem);
 
  392  FREERDP_API BOOL shadow_client_post_msg(rdpShadowClient* client, 
void* context, UINT32 type,
 
  393                                          SHADOW_MSG_OUT* msg, 
void* lParam);
 
  394  FREERDP_API 
int shadow_client_boardcast_msg(rdpShadowServer* server, 
void* context, UINT32 type,
 
  395                                              SHADOW_MSG_OUT* msg, 
void* lParam);
 
  396  FREERDP_API 
int shadow_client_boardcast_quit(rdpShadowServer* server, 
int nExitCode);
 
  398  FREERDP_API UINT32 shadow_encoder_preferred_fps(rdpShadowEncoder* encoder);
 
  399  FREERDP_API UINT32 shadow_encoder_inflight_frames(rdpShadowEncoder* encoder);
 
  401  FREERDP_API BOOL shadow_screen_resize(rdpShadowScreen* screen);