From abd833c27e98be6175a10addcf5410091770a5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 3 Jun 2014 13:38:10 -0400 Subject: [PATCH] libfreerdp-codec: stub new ZGFX (RDP8) bulk compressor/decompressor --- channels/rdpgfx/client/rdpgfx_main.c | 20 +++++- include/freerdp/codec/zgfx.h | 57 ++++++++++++++++ libfreerdp/codec/CMakeLists.txt | 1 + libfreerdp/codec/test/CMakeLists.txt | 1 + libfreerdp/codec/test/TestFreeRDPCodecZGfx.c | 10 +++ libfreerdp/codec/zgfx.c | 72 ++++++++++++++++++++ 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 include/freerdp/codec/zgfx.h create mode 100644 libfreerdp/codec/test/TestFreeRDPCodecZGfx.c create mode 100644 libfreerdp/codec/zgfx.c diff --git a/channels/rdpgfx/client/rdpgfx_main.c b/channels/rdpgfx/client/rdpgfx_main.c index 218cecd41..ec77ba68f 100644 --- a/channels/rdpgfx/client/rdpgfx_main.c +++ b/channels/rdpgfx/client/rdpgfx_main.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -144,6 +145,23 @@ int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback) int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { + RDPGFX_HEADER header; + + /* RDPGFX_HEADER */ + + /* data needs to be decompressed first */ + + //winpr_HexDump(Stream_Buffer(s), 32); + + return 0; + + Stream_Read_UINT16(s, header.cmdId); /* cmdId (2 bytes) */ + Stream_Read_UINT16(s, header.flags); /* flags (2 bytes) */ + Stream_Read_UINT32(s, header.pduLength); /* pduLength (4 bytes) */ + + printf("cmdId: 0x%04X flags: 0x%04X pduLength: %d\n", + header.cmdId, header.flags, header.pduLength); + return 0; } @@ -153,7 +171,7 @@ static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, int status = 0; RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback; - fprintf(stderr, "RdpGfxOnDataReceived\n"); + fprintf(stderr, "RdpGfxOnDataReceived: cbSize: %d\n", cbSize); s = Stream_New(pBuffer, cbSize); diff --git a/include/freerdp/codec/zgfx.h b/include/freerdp/codec/zgfx.h new file mode 100644 index 000000000..b0bc9a8a6 --- /dev/null +++ b/include/freerdp/codec/zgfx.h @@ -0,0 +1,57 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * ZGFX (RDP8) Bulk Data Compression + * + * Copyright 2014 Marc-Andre Moreau + * + * 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_CODEC_ZGFX_H +#define FREERDP_CODEC_ZGFX_H + +#include +#include + +#include + +#pragma pack(push,1) + + + +#pragma pack(pop) + +struct _ZGFX_CONTEXT +{ + BOOL Compressor; +}; +typedef struct _ZGFX_CONTEXT ZGFX_CONTEXT; + +#ifdef __cplusplus +extern "C" { +#endif + +FREERDP_API int zgfx_compress(ZGFX_CONTEXT* zgfx, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32* pFlags); +FREERDP_API int zgfx_decompress(ZGFX_CONTEXT* zgfx, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags); + +FREERDP_API void zgfx_context_reset(ZGFX_CONTEXT* zgfx, BOOL flush); + +FREERDP_API ZGFX_CONTEXT* zgfx_context_new(BOOL Compressor); +FREERDP_API void zgfx_context_free(ZGFX_CONTEXT* zgfx); + +#ifdef __cplusplus +} +#endif + +#endif /* FREERDP_CODEC_ZGFX_H */ + diff --git a/libfreerdp/codec/CMakeLists.txt b/libfreerdp/codec/CMakeLists.txt index f0ba7f746..abe48739b 100644 --- a/libfreerdp/codec/CMakeLists.txt +++ b/libfreerdp/codec/CMakeLists.txt @@ -50,6 +50,7 @@ set(${MODULE_PREFIX}_SRCS ncrush.c xcrush.c mppc.c + zgfx.c jpeg.c) set(${MODULE_PREFIX}_SSE2_SRCS diff --git a/libfreerdp/codec/test/CMakeLists.txt b/libfreerdp/codec/test/CMakeLists.txt index b63feac4c..fa268c270 100644 --- a/libfreerdp/codec/test/CMakeLists.txt +++ b/libfreerdp/codec/test/CMakeLists.txt @@ -9,6 +9,7 @@ set(${MODULE_PREFIX}_TESTS TestFreeRDPCodecMppc.c TestFreeRDPCodecNCrush.c TestFreeRDPCodecXCrush.c + TestFreeRDPCodecZGfx.c TestFreeRDPCodecPlanar.c TestFreeRDPCodecRemoteFX.c) diff --git a/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c b/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c new file mode 100644 index 000000000..7284424e5 --- /dev/null +++ b/libfreerdp/codec/test/TestFreeRDPCodecZGfx.c @@ -0,0 +1,10 @@ +#include +#include + +#include + +int TestFreeRDPCodecZGfx(int argc, char* argv[]) +{ + return 0; +} + diff --git a/libfreerdp/codec/zgfx.c b/libfreerdp/codec/zgfx.c new file mode 100644 index 000000000..7d7ab67e0 --- /dev/null +++ b/libfreerdp/codec/zgfx.c @@ -0,0 +1,72 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * ZGFX (RDP8) Bulk Data Compression + * + * Copyright 2014 Marc-Andre Moreau + * + * 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 +#include +#include + +#include + +int zgfx_decompress(ZGFX_CONTEXT* zgfx, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32 flags) +{ + int status = 0; + + return status; +} + +int zgfx_compress(ZGFX_CONTEXT* zgfx, BYTE* pSrcData, UINT32 SrcSize, BYTE** ppDstData, UINT32* pDstSize, UINT32* pFlags) +{ + int status = 0; + + return 1; +} + +void zgfx_context_reset(ZGFX_CONTEXT* zgfx, BOOL flush) +{ + +} + +ZGFX_CONTEXT* zgfx_context_new(BOOL Compressor) +{ + ZGFX_CONTEXT* zgfx; + + zgfx = (ZGFX_CONTEXT*) calloc(1, sizeof(ZGFX_CONTEXT)); + + if (zgfx) + { + zgfx->Compressor = Compressor; + + zgfx_context_reset(zgfx, FALSE); + } + + return zgfx; +} + +void zgfx_context_free(ZGFX_CONTEXT* zgfx) +{ + if (zgfx) + { + free(zgfx); + } +} +