libfreerdp-codec: stub new ZGFX (RDP8) bulk compressor/decompressor
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 3 Jun 2014 17:38:10 +0000 (13:38 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 3 Jun 2014 17:38:10 +0000 (13:38 -0400)
channels/rdpgfx/client/rdpgfx_main.c
include/freerdp/codec/zgfx.h [new file with mode: 0644]
libfreerdp/codec/CMakeLists.txt
libfreerdp/codec/test/CMakeLists.txt
libfreerdp/codec/test/TestFreeRDPCodecZGfx.c [new file with mode: 0644]
libfreerdp/codec/zgfx.c [new file with mode: 0644]

index 218cecd..ec77ba6 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <winpr/crt.h>
 #include <winpr/wlog.h>
+#include <winpr/print.h>
 #include <winpr/synch.h>
 #include <winpr/thread.h>
 #include <winpr/stream.h>
@@ -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 (file)
index 0000000..b0bc9a8
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * ZGFX (RDP8) Bulk Data Compression
+ *
+ * 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_CODEC_ZGFX_H
+#define FREERDP_CODEC_ZGFX_H
+
+#include <freerdp/api.h>
+#include <freerdp/types.h>
+
+#include <freerdp/codec/bulk.h>
+
+#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 */
index f0ba7f7..abe4873 100644 (file)
@@ -50,6 +50,7 @@ set(${MODULE_PREFIX}_SRCS
        ncrush.c
        xcrush.c
        mppc.c
+       zgfx.c
        jpeg.c)
 
 set(${MODULE_PREFIX}_SSE2_SRCS
index b63feac..fa268c2 100644 (file)
@@ -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 (file)
index 0000000..7284424
--- /dev/null
@@ -0,0 +1,10 @@
+#include <winpr/crt.h>
+#include <winpr/print.h>
+
+#include <freerdp/codec/zgfx.h>
+
+int TestFreeRDPCodecZGfx(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/libfreerdp/codec/zgfx.c b/libfreerdp/codec/zgfx.c
new file mode 100644 (file)
index 0000000..7d7ab67
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ * FreeRDP: A Remote Desktop Protocol Implementation
+ * ZGFX (RDP8) Bulk Data Compression
+ *
+ * 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 <winpr/crt.h>
+#include <winpr/print.h>
+#include <winpr/bitstream.h>
+
+#include <freerdp/codec/zgfx.h>
+
+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);
+       }
+}
+