FreeRDP
server/rdpgfx_main.c File Reference
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winpr/crt.h>
#include <winpr/synch.h>
#include <winpr/thread.h>
#include <winpr/stream.h>
#include <freerdp/channels/wtsvc.h>
#include <freerdp/channels/log.h>
#include "rdpgfx_common.h"
#include "rdpgfx_main.h"

Macros

#define TAG   CHANNELS_TAG("rdpgfx.server")
 
#define RDPGFX_RESET_GRAPHICS_PDU_SIZE   340
 

Functions

static INLINE UINT32 rdpgfx_pdu_length (UINT32 dataLen)
 
static INLINE UINT rdpgfx_server_packet_init_header (wStream *s, UINT16 cmdId, UINT32 pduLength)
 
static INLINE void rdpgfx_server_packet_complete_header (wStream *s, size_t start)
 
static UINT rdpgfx_server_packet_send (RdpgfxServerContext *context, wStream *s)
 
static wStream * rdpgfx_server_single_packet_new (UINT16 cmdId, UINT32 dataLen)
 
static INLINE UINT rdpgfx_server_single_packet_send (RdpgfxServerContext *context, wStream *s)
 
static UINT rdpgfx_send_caps_confirm_pdu (RdpgfxServerContext *context, RDPGFX_CAPS_CONFIRM_PDU *capsConfirm)
 
static UINT rdpgfx_send_reset_graphics_pdu (RdpgfxServerContext *context, RDPGFX_RESET_GRAPHICS_PDU *pdu)
 
static UINT rdpgfx_send_evict_cache_entry_pdu (RdpgfxServerContext *context, RDPGFX_EVICT_CACHE_ENTRY_PDU *pdu)
 
static UINT rdpgfx_send_cache_import_reply_pdu (RdpgfxServerContext *context, RDPGFX_CACHE_IMPORT_REPLY_PDU *pdu)
 
static UINT rdpgfx_send_create_surface_pdu (RdpgfxServerContext *context, RDPGFX_CREATE_SURFACE_PDU *pdu)
 
static UINT rdpgfx_send_delete_surface_pdu (RdpgfxServerContext *context, RDPGFX_DELETE_SURFACE_PDU *pdu)
 
static INLINE void rdpgfx_write_start_frame_pdu (wStream *s, RDPGFX_START_FRAME_PDU *pdu)
 
static INLINE void rdpgfx_write_end_frame_pdu (wStream *s, RDPGFX_END_FRAME_PDU *pdu)
 
static UINT rdpgfx_send_start_frame_pdu (RdpgfxServerContext *context, RDPGFX_START_FRAME_PDU *pdu)
 
static UINT rdpgfx_send_end_frame_pdu (RdpgfxServerContext *context, RDPGFX_END_FRAME_PDU *pdu)
 
static INLINE UINT32 rdpgfx_estimate_h264_avc420 (RDPGFX_AVC420_BITMAP_STREAM *havc420)
 
static INLINE UINT32 rdpgfx_estimate_surface_command (RDPGFX_SURFACE_COMMAND *cmd)
 
static INLINE UINT16 rdpgfx_surface_command_cmdid (RDPGFX_SURFACE_COMMAND *cmd)
 
static UINT rdpgfx_write_h264_metablock (wStream *s, RDPGFX_H264_METABLOCK *meta)
 
static INLINE UINT rdpgfx_write_h264_avc420 (wStream *s, RDPGFX_AVC420_BITMAP_STREAM *havc420)
 
static UINT rdpgfx_write_surface_command (wStream *s, RDPGFX_SURFACE_COMMAND *cmd)
 
static UINT rdpgfx_send_surface_command (RdpgfxServerContext *context, RDPGFX_SURFACE_COMMAND *cmd)
 
static UINT rdpgfx_send_surface_frame_command (RdpgfxServerContext *context, RDPGFX_SURFACE_COMMAND *cmd, RDPGFX_START_FRAME_PDU *startFrame, RDPGFX_END_FRAME_PDU *endFrame)
 
static UINT rdpgfx_send_delete_encoding_context_pdu (RdpgfxServerContext *context, RDPGFX_DELETE_ENCODING_CONTEXT_PDU *pdu)
 
static UINT rdpgfx_send_solid_fill_pdu (RdpgfxServerContext *context, RDPGFX_SOLID_FILL_PDU *pdu)
 
static UINT rdpgfx_send_surface_to_surface_pdu (RdpgfxServerContext *context, RDPGFX_SURFACE_TO_SURFACE_PDU *pdu)
 
static UINT rdpgfx_send_surface_to_cache_pdu (RdpgfxServerContext *context, RDPGFX_SURFACE_TO_CACHE_PDU *pdu)
 
static UINT rdpgfx_send_cache_to_surface_pdu (RdpgfxServerContext *context, RDPGFX_CACHE_TO_SURFACE_PDU *pdu)
 
static UINT rdpgfx_send_map_surface_to_output_pdu (RdpgfxServerContext *context, RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU *pdu)
 
static UINT rdpgfx_send_map_surface_to_window_pdu (RdpgfxServerContext *context, RDPGFX_MAP_SURFACE_TO_WINDOW_PDU *pdu)
 
static UINT rdpgfx_recv_frame_acknowledge_pdu (RdpgfxServerContext *context, wStream *s)
 
static UINT rdpgfx_recv_cache_import_offer_pdu (RdpgfxServerContext *context, wStream *s)
 
static UINT rdpgfx_recv_caps_advertise_pdu (RdpgfxServerContext *context, wStream *s)
 
static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu (RdpgfxServerContext *context, wStream *s)
 
static UINT rdpgfx_server_receive_pdu (RdpgfxServerContext *context, wStream *s)
 
static DWORD WINAPI rdpgfx_server_thread_func (LPVOID arg)
 
static BOOL rdpgfx_server_open (RdpgfxServerContext *context)
 
static BOOL rdpgfx_server_close (RdpgfxServerContext *context)
 
RdpgfxServerContext * rdpgfx_server_context_new (HANDLE vcm)
 
void rdpgfx_server_context_free (RdpgfxServerContext *context)
 
HANDLE rdpgfx_server_get_event_handle (RdpgfxServerContext *context)
 
UINT rdpgfx_server_handle_messages (RdpgfxServerContext *context)
 

Macro Definition Documentation

#define RDPGFX_RESET_GRAPHICS_PDU_SIZE   340
#define TAG   CHANNELS_TAG("rdpgfx.server")

FreeRDP: A Remote Desktop Protocol Implementation Graphics Pipeline Extension

Copyright 2016 Jiang Zihao zihao.nosp@m..jia.nosp@m.ng@ya.nosp@m.hoo..nosp@m.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

static INLINE UINT32 rdpgfx_estimate_h264_avc420 ( RDPGFX_AVC420_BITMAP_STREAM *  havc420)
static

Function description Estimate RFX_AVC420_BITMAP_STREAM structure size in stream

Returns
estimated size

Here is the caller graph for this function:

static INLINE UINT32 rdpgfx_estimate_surface_command ( RDPGFX_SURFACE_COMMAND *  cmd)
static

Function description Estimate surface command packet size in stream without header

Returns
estimated size

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE UINT32 rdpgfx_pdu_length ( UINT32  dataLen)
static

Function description Calculate packet size from data length. It would be data length + header.

Parameters
dataLenestimated data length without header
Returns
new stream

Here is the caller graph for this function:

static UINT rdpgfx_recv_cache_import_offer_pdu ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_recv_caps_advertise_pdu ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_recv_frame_acknowledge_pdu ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_recv_qoe_frame_acknowledge_pdu ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_cache_import_reply_pdu ( RdpgfxServerContext *  context,
RDPGFX_CACHE_IMPORT_REPLY_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_cache_to_surface_pdu ( RdpgfxServerContext *  context,
RDPGFX_CACHE_TO_SURFACE_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_caps_confirm_pdu ( RdpgfxServerContext *  context,
RDPGFX_CAPS_CONFIRM_PDU *  capsConfirm 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_create_surface_pdu ( RdpgfxServerContext *  context,
RDPGFX_CREATE_SURFACE_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_delete_encoding_context_pdu ( RdpgfxServerContext *  context,
RDPGFX_DELETE_ENCODING_CONTEXT_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_delete_surface_pdu ( RdpgfxServerContext *  context,
RDPGFX_DELETE_SURFACE_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_end_frame_pdu ( RdpgfxServerContext *  context,
RDPGFX_END_FRAME_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_evict_cache_entry_pdu ( RdpgfxServerContext *  context,
RDPGFX_EVICT_CACHE_ENTRY_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_map_surface_to_output_pdu ( RdpgfxServerContext *  context,
RDPGFX_MAP_SURFACE_TO_OUTPUT_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_map_surface_to_window_pdu ( RdpgfxServerContext *  context,
RDPGFX_MAP_SURFACE_TO_WINDOW_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_reset_graphics_pdu ( RdpgfxServerContext *  context,
RDPGFX_RESET_GRAPHICS_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_solid_fill_pdu ( RdpgfxServerContext *  context,
RDPGFX_SOLID_FILL_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_start_frame_pdu ( RdpgfxServerContext *  context,
RDPGFX_START_FRAME_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_surface_command ( RdpgfxServerContext *  context,
RDPGFX_SURFACE_COMMAND *  cmd 
)
static

Function description Send RDPGFX_CMDID_WIRETOSURFACE_1 or RDPGFX_CMDID_WIRETOSURFACE_2 message according to codecId

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_surface_frame_command ( RdpgfxServerContext *  context,
RDPGFX_SURFACE_COMMAND *  cmd,
RDPGFX_START_FRAME_PDU *  startFrame,
RDPGFX_END_FRAME_PDU *  endFrame 
)
static

Function description Send RDPGFX_CMDID_WIRETOSURFACE_1 or RDPGFX_CMDID_WIRETOSURFACE_2 message according to codecId. Prepend/append start/end frame message in same packet if exists.

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_surface_to_cache_pdu ( RdpgfxServerContext *  context,
RDPGFX_SURFACE_TO_CACHE_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_send_surface_to_surface_pdu ( RdpgfxServerContext *  context,
RDPGFX_SURFACE_TO_SURFACE_PDU *  pdu 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL rdpgfx_server_close ( RdpgfxServerContext *  context)
static

Here is the call graph for this function:

Here is the caller graph for this function:

void rdpgfx_server_context_free ( RdpgfxServerContext *  context)

Here is the call graph for this function:

Here is the caller graph for this function:

RdpgfxServerContext* rdpgfx_server_context_new ( HANDLE  vcm)

Here is the call graph for this function:

Here is the caller graph for this function:

HANDLE rdpgfx_server_get_event_handle ( RdpgfxServerContext *  context)
UINT rdpgfx_server_handle_messages ( RdpgfxServerContext *  context)

Here is the call graph for this function:

Here is the caller graph for this function:

static BOOL rdpgfx_server_open ( RdpgfxServerContext *  context)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE void rdpgfx_server_packet_complete_header ( wStream *  s,
size_t  start 
)
static

Function description Complete the rdpgfx packet header.

Parameters
sstream
startsaved start pos of the packet in the stream

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE UINT rdpgfx_server_packet_init_header ( wStream *  s,
UINT16  cmdId,
UINT32  pduLength 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_server_packet_send ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description Send the stream for rdpgfx server packet. The packet would be compressed according to [MS-RDPEGFX].

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_server_receive_pdu ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static wStream* rdpgfx_server_single_packet_new ( UINT16  cmdId,
UINT32  dataLen 
)
static

Function description Create new stream for single rdpgfx packet. The new stream length would be required data length + header. The header will be written to the stream before return, but the pduLength field might be changed in rdpgfx_server_single_packet_send.

Parameters
cmdId
dataLenestimated data length without header
Returns
new stream

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE UINT rdpgfx_server_single_packet_send ( RdpgfxServerContext *  context,
wStream *  s 
)
static

Function description Send the stream for single rdpgfx packet. The header will be filled with actual length. The packet would be compressed according to [MS-RDPEGFX].

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static DWORD WINAPI rdpgfx_server_thread_func ( LPVOID  arg)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE UINT16 rdpgfx_surface_command_cmdid ( RDPGFX_SURFACE_COMMAND *  cmd)
static

Function description Resolve RDPGFX_CMDID_WIRETOSURFACE_1 or RDPGFX_CMDID_WIRETOSURFACE_2 according to codecId

Returns
0 on success, otherwise a Win32 error code

Here is the caller graph for this function:

static INLINE void rdpgfx_write_end_frame_pdu ( wStream *  s,
RDPGFX_END_FRAME_PDU *  pdu 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE UINT rdpgfx_write_h264_avc420 ( wStream *  s,
RDPGFX_AVC420_BITMAP_STREAM *  havc420 
)
static

Function description Write RFX_AVC420_BITMAP_STREAM structure to stream

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_write_h264_metablock ( wStream *  s,
RDPGFX_H264_METABLOCK *  meta 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function:

static INLINE void rdpgfx_write_start_frame_pdu ( wStream *  s,
RDPGFX_START_FRAME_PDU *  pdu 
)
static

Here is the call graph for this function:

Here is the caller graph for this function:

static UINT rdpgfx_write_surface_command ( wStream *  s,
RDPGFX_SURFACE_COMMAND *  cmd 
)
static

Function description Write RDPGFX_CMDID_WIRETOSURFACE_1 or RDPGFX_CMDID_WIRETOSURFACE_2 to the stream according to RDPGFX_SURFACE_COMMAND message

Returns
0 on success, otherwise a Win32 error code

Here is the call graph for this function:

Here is the caller graph for this function: