shadow: stub more components

This commit is contained in:
Marc-André Moreau 2014-07-11 20:49:56 -04:00
parent 8ae00f7385
commit 5135467037
13 changed files with 482 additions and 11 deletions

View File

@ -27,22 +27,29 @@
typedef struct rdp_shadow_client rdpShadowClient;
typedef struct rdp_shadow_server rdpShadowServer;
typedef struct rdp_shadow_screen rdpShadowScreen;
typedef struct rdp_shadow_surface rdpShadowSurface;
typedef struct rdp_shadow_encoder rdpShadowEncoder;
struct rdp_shadow_client
{
rdpContext context;
rdpShadowServer* server;
void* ext;
HANDLE thread;
rdpShadowServer* server;
};
struct rdp_shadow_server
{
DWORD port;
HANDLE thread;
freerdp_listener* listener;
void* ext;
HANDLE thread;
rdpShadowScreen* screen;
rdpShadowSurface* surface;
rdpShadowEncoder* encoder;
DWORD port;
freerdp_listener* listener;
};
#endif /* FREERDP_SERVER_SHADOW_H */

View File

@ -117,8 +117,15 @@ endif()
set(${MODULE_PREFIX}_SRCS
shadow_client.c
shadow_client.h
shadow_input.c
shadow_update.c
shadow_input.h
shadow_screen.c
shadow_screen.h
shadow_surface.c
shadow_surface.h
shadow_encoder.c
shadow_encoder.h
shadow.c
shadow.h)

View File

@ -106,6 +106,16 @@ rdpShadowServer* shadow_server_new(int argc, char** argv)
server->listener->info = (void*) server;
server->listener->PeerAccepted = shadow_client_accepted;
server->screen = shadow_screen_new(server);
if (!server->screen)
return NULL;
server->encoder = shadow_encoder_new(server);
if (!server->encoder)
return NULL;
server->ext = x11_shadow_server_new(server);
if (!server->ext)
@ -121,6 +131,8 @@ void shadow_server_free(rdpShadowServer* server)
freerdp_listener_free(server->listener);
shadow_encoder_free(server->encoder);
x11_shadow_server_free(server->ext);
free(server);

View File

@ -1,6 +1,5 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* FreeRDP Shadow Server
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.com>
*
@ -24,6 +23,10 @@
#include "X11/x11_shadow.h"
#include "shadow_screen.h"
#include "shadow_surface.h"
#include "shadow_encoder.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -0,0 +1,34 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifndef FREERDP_SHADOW_SERVER_CLIENT_H
#define FREERDP_SHADOW_SERVER_CLIENT_H
#include <freerdp/server/shadow.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_CLIENT_H */

View File

@ -0,0 +1,152 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "shadow_encoder.h"
int shadow_encoder_grid_init(rdpShadowEncoder* encoder)
{
int i, j, k;
int tileSize;
int tileCount;
encoder->gridWidth = ((encoder->width + (encoder->maxTileWidth - 1)) / encoder->maxTileWidth);
encoder->gridHeight = ((encoder->height + (encoder->maxTileHeight - 1)) / encoder->maxTileHeight);
tileSize = encoder->maxTileWidth * encoder->maxTileHeight * 4;
tileCount = encoder->gridWidth * encoder->gridHeight;
encoder->gridBuffer = (BYTE*) malloc(tileSize * tileCount);
if (!encoder->gridBuffer)
return -1;
encoder->grid = (BYTE**) malloc(tileCount * sizeof(BYTE*));
if (!encoder->grid)
return -1;
for (i = 0; i < encoder->gridHeight; i++)
{
for (j = 0; j < encoder->gridWidth; j++)
{
k = (i * encoder->gridHeight) + j;
encoder->grid[k] = &(encoder->gridBuffer[k * tileSize]);
}
}
return 0;
}
int shadow_encoder_grid_uninit(rdpShadowEncoder* encoder)
{
if (encoder->gridBuffer)
{
free(encoder->gridBuffer);
encoder->gridBuffer = NULL;
}
if (encoder->grid)
{
free(encoder->grid);
encoder->grid = NULL;
}
encoder->gridWidth = 0;
encoder->gridHeight = 0;
return 0;
}
rdpShadowEncoder* shadow_encoder_new(rdpShadowServer* server)
{
DWORD planarFlags;
rdpShadowEncoder* encoder;
encoder = (rdpShadowEncoder*) calloc(1, sizeof(rdpShadowEncoder));
if (!encoder)
return NULL;
encoder->server = server;
encoder->width = 1024;
encoder->height = 768;
encoder->bitsPerPixel = 32;
encoder->bytesPerPixel = 4;
encoder->scanline = (encoder->width + (encoder->width % 4)) * 4;
encoder->data = (BYTE*) malloc(encoder->scanline * encoder->height);
if (!encoder->data)
return NULL;
encoder->maxTileWidth = 64;
encoder->maxTileHeight = 64;
encoder->bs = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4);
encoder->bts = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4);
planarFlags = PLANAR_FORMAT_HEADER_NA;
planarFlags |= PLANAR_FORMAT_HEADER_RLE;
encoder->planar = freerdp_bitmap_planar_context_new(planarFlags,
encoder->maxTileWidth, encoder->maxTileHeight);
encoder->rfx = rfx_context_new(TRUE);
encoder->rfx_s = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4);
encoder->rfx->mode = RLGR3;
encoder->rfx->width = encoder->width;
encoder->rfx->height = encoder->height;
encoder->nsc = nsc_context_new();
encoder->nsc_s = Stream_New(NULL, encoder->maxTileWidth * encoder->maxTileHeight * 4);
rfx_context_set_pixel_format(encoder->rfx, RDP_PIXEL_FORMAT_B8G8R8A8);
nsc_context_set_pixel_format(encoder->nsc, RDP_PIXEL_FORMAT_B8G8R8A8);
shadow_encoder_grid_init(encoder);
return encoder;
}
void shadow_encoder_free(rdpShadowEncoder* encoder)
{
if (!encoder)
return;
Stream_Free(encoder->bs, TRUE);
Stream_Free(encoder->bts, TRUE);
Stream_Free(encoder->rfx_s, TRUE);
rfx_context_free(encoder->rfx);
Stream_Free(encoder->nsc_s, TRUE);
nsc_context_free(encoder->nsc);
freerdp_bitmap_planar_context_free(encoder->planar);
shadow_encoder_grid_uninit(encoder);
free(encoder);
}

View File

@ -0,0 +1,73 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifndef FREERDP_SHADOW_SERVER_ENCODER_H
#define FREERDP_SHADOW_SERVER_ENCODER_H
#include <winpr/crt.h>
#include <winpr/stream.h>
#include <freerdp/freerdp.h>
#include <freerdp/codec/rfx.h>
#include <freerdp/codec/nsc.h>
#include <freerdp/codec/bitmap.h>
#include <freerdp/server/shadow.h>
struct rdp_shadow_encoder
{
rdpShadowServer* server;
BYTE* data;
int width;
int height;
int scanline;
UINT32 bitsPerPixel;
UINT32 bytesPerPixel;
BYTE** grid;
int gridWidth;
int gridHeight;
BYTE* gridBuffer;
int maxTileWidth;
int maxTileHeight;
wStream* rfx_s;
RFX_CONTEXT* rfx;
wStream* nsc_s;
NSC_CONTEXT* nsc;
wStream* bs;
wStream* bts;
BITMAP_PLANAR_CONTEXT* planar;
};
#ifdef __cplusplus
extern "C" {
#endif
rdpShadowEncoder* shadow_encoder_new(rdpShadowServer* server);
void shadow_encoder_free(rdpShadowEncoder* encoder);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_ENCODER_H */

View File

@ -55,4 +55,3 @@ void shadow_input_register_callbacks(rdpInput* input)
input->MouseEvent = shadow_input_mouse_event;
input->ExtendedMouseEvent = shadow_input_extended_mouse_event;
}

View File

@ -16,9 +16,19 @@
* limitations under the License.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#ifndef FREERDP_SHADOW_SERVER_INPUT_H
#define FREERDP_SHADOW_SERVER_INPUT_H
#include <freerdp/server/shadow.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "shadow.h"
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_INPUT_H */

View File

@ -0,0 +1,44 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "shadow_screen.h"
rdpShadowScreen* shadow_screen_new(rdpShadowServer* server)
{
rdpShadowScreen* screen;
screen = (rdpShadowScreen*) calloc(1, sizeof(rdpShadowScreen));
if (!screen)
return NULL;
screen->server = server;
return screen;
}
void shadow_screen_free(rdpShadowScreen* screen)
{
if (!screen)
return;
}

View File

@ -0,0 +1,42 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifndef FREERDP_SHADOW_SERVER_SCREEN_H
#define FREERDP_SHADOW_SERVER_SCREEN_H
#include <freerdp/server/shadow.h>
struct rdp_shadow_screen
{
rdpShadowServer* server;
rdpShadowSurface* primary;
};
#ifdef __cplusplus
extern "C" {
#endif
rdpShadowScreen* shadow_screen_new(rdpShadowServer* server);
void shadow_screen_free(rdpShadowScreen* screen);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_SCREEN_H */

View File

@ -0,0 +1,43 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "shadow_surface.h"
rdpShadowSurface* shadow_surface_new(rdpShadowServer* server)
{
rdpShadowSurface* surface;
surface = (rdpShadowSurface*) calloc(1, sizeof(rdpShadowSurface));
if (!surface)
return NULL;
surface->server = server;
return surface;
}
void shadow_surface_free(rdpShadowSurface* surface)
{
if (!surface)
return;
}

View File

@ -0,0 +1,45 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
*
* Copyright 2014 Marc-Andre Moreau <marcandre.moreau@gmail.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.
*/
#ifndef FREERDP_SHADOW_SERVER_SURFACE_H
#define FREERDP_SHADOW_SERVER_SURFACE_H
#include <freerdp/server/shadow.h>
struct rdp_shadow_surface
{
rdpShadowServer* server;
int width;
int height;
int scanline;
BYTE* data;
};
#ifdef __cplusplus
extern "C" {
#endif
rdpShadowSurface* shadow_surface_new(rdpShadowServer* server);
void shadow_surface_free(rdpShadowSurface* surface);
#ifdef __cplusplus
}
#endif
#endif /* FREERDP_SHADOW_SERVER_SURFACE_H */