summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2010-06-20 15:24:49 +0300
committerAlexander Larsson <alexl@redhat.com>2010-06-21 15:05:37 +0200
commit25bb38f643af6f0015df369a22176275b6ebfae0 (patch)
tree5bfc75812c6ba89086d1ab8782552de806fd53bb /client
parentcfc1e95bda0e150b3de225c3572bb1004dad070e (diff)
applying zlib compression over glz on WAN connection
Diffstat (limited to 'client')
-rw-r--r--client/Makefile.am2
-rw-r--r--client/canvas.h3
-rw-r--r--client/red_gdi_canvas.cpp3
-rw-r--r--client/red_gl_canvas.cpp3
-rw-r--r--client/red_sw_canvas.cpp6
-rw-r--r--client/windows/redc.vcproj12
-rw-r--r--client/x11/Makefile.am3
-rw-r--r--client/zlib_decoder.cpp58
-rw-r--r--client/zlib_decoder.h41
9 files changed, 125 insertions, 6 deletions
diff --git a/client/Makefile.am b/client/Makefile.am
index f700ed6..fb69ce6 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -111,6 +111,8 @@ RED_COMMON_SRCS = \
threads.h \
utils.cpp \
utils.h \
+ zlib_decoder.cpp \
+ zlib_decoder.h \
$(NULL)
MAINTAINERCLEANFILES = $(spice_built_sources)
diff --git a/client/canvas.h b/client/canvas.h
index ff70e11..87bc060 100644
--- a/client/canvas.h
+++ b/client/canvas.h
@@ -30,6 +30,7 @@
#include "glz_decoded_image.h"
#include "glz_decoder.h"
#include "jpeg_decoder.h"
+#include "zlib_decoder.h"
enum CanvasType {
CANVAS_TYPE_INVALID,
@@ -446,6 +447,7 @@ protected:
GlzDecoder& glz_decoder() {return _glz_decoder;}
JpegDecoder& jpeg_decoder() { return _jpeg_decoder;}
+ ZlibDecoder& zlib_decoder() { return _zlib_decoder;}
private:
void access_test(void* ptr, size_t size);
@@ -468,6 +470,7 @@ private:
GlzDecoder _glz_decoder;
JpegDecoder _jpeg_decoder;
+ ZlibDecoder _zlib_decoder;
CSurfaces& _csurfaces;
diff --git a/client/red_gdi_canvas.cpp b/client/red_gdi_canvas.cpp
index 453023e..72b31df 100644
--- a/client/red_gdi_canvas.cpp
+++ b/client/red_gdi_canvas.cpp
@@ -38,7 +38,8 @@ GDICanvas::GDICanvas(int width, int height, uint32_t format,
&palette_cache.base,
&csurfaces.base,
&glz_decoder(),
- &jpeg_decoder()))) {
+ &jpeg_decoder(),
+ &zlib_decoder()))) {
THROW("create canvas failed");
}
}
diff --git a/client/red_gl_canvas.cpp b/client/red_gl_canvas.cpp
index 1a219cd..d7841b9 100644
--- a/client/red_gl_canvas.cpp
+++ b/client/red_gl_canvas.cpp
@@ -41,7 +41,8 @@ GCanvas::GCanvas(int width, int height, uint32_t format, RedWindow *win,
&palette_cache.base,
&csurfaces.base,
&glz_decoder(),
- &jpeg_decoder()))) {
+ &jpeg_decoder(),
+ &zlib_decoder()))) {
THROW("create canvas failed");
}
}
diff --git a/client/red_sw_canvas.cpp b/client/red_sw_canvas.cpp
index 7a8daf4..b580e61 100644
--- a/client/red_sw_canvas.cpp
+++ b/client/red_sw_canvas.cpp
@@ -43,14 +43,16 @@ SCanvas::SCanvas(bool onscreen,
&palette_cache.base,
&csurfaces.base,
&glz_decoder(),
- &jpeg_decoder());
+ &jpeg_decoder(),
+ &zlib_decoder());
} else {
_canvas = canvas_create(width, height, format,
&pixmap_cache.base,
&palette_cache.base,
&csurfaces.base,
&glz_decoder(),
- &jpeg_decoder());
+ &jpeg_decoder(),
+ &zlib_decoder());
}
if (_canvas == NULL) {
THROW("create canvas failed");
diff --git a/client/windows/redc.vcproj b/client/windows/redc.vcproj
index 8f9e509..37ca23a 100644
--- a/client/windows/redc.vcproj
+++ b/client/windows/redc.vcproj
@@ -69,7 +69,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="log4cppD.lib pixman-1D.lib libeay32MTd.lib ssleay32MTd.lib ws2_32.lib msimg32.lib winmm.lib libcelt_0_5_1D.lib pthreadVC2d.lib version.lib CEGUIBase_Static_d.lib CEGUITGAImageCodec_Static_d.lib CEGUIExpatParser_Static_d.lib freetype2312MT_D.lib libexpatMT_D.lib pcre_D.lib CEGUIFalagardWRBase_Static_d.lib libjpeg-static-mt-debug.lib"
+ AdditionalDependencies="log4cppD.lib pixman-1D.lib libeay32MTd.lib ssleay32MTd.lib ws2_32.lib msimg32.lib winmm.lib libcelt_0_5_1D.lib pthreadVC2d.lib version.lib CEGUIBase_Static_d.lib CEGUITGAImageCodec_Static_d.lib CEGUIExpatParser_Static_d.lib freetype2312MT_D.lib libexpatMT_D.lib pcre_D.lib CEGUIFalagardWRBase_Static_d.lib libjpeg-static-mt-debug.lib zlibwapi.lib"
OutputFile="$(OutDir)\spicec.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib&quot;"
@@ -148,7 +148,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="log4cpp.lib pixman-1.lib libeay32MT.lib ssleay32MT.lib ws2_32.lib msimg32.lib winmm.lib libcelt_0_5_1.lib pthreadVC2.lib version.lib CEGUIBase_Static.lib CEGUITGAImageCodec_Static.lib CEGUIExpatParser_Static.lib freetype2312MT.lib libexpatMT.lib pcre.lib CEGUIFalagardWRBase_Static.lib libjpeg-static-mt.lib"
+ AdditionalDependencies="log4cpp.lib pixman-1.lib libeay32MT.lib ssleay32MT.lib ws2_32.lib msimg32.lib winmm.lib libcelt_0_5_1.lib pthreadVC2.lib version.lib CEGUIBase_Static.lib CEGUITGAImageCodec_Static.lib CEGUIExpatParser_Static.lib freetype2312MT.lib libexpatMT.lib pcre.lib CEGUIFalagardWRBase_Static.lib libjpeg-static-mt.lib zlibwapi.lib"
OutputFile="$(OutDir)\spicec.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(SPICE_LIBS)\lib&quot;"
@@ -437,6 +437,10 @@
RelativePath="..\utils.cpp"
>
</File>
+ <File
+ RelativePath="..\zlib_decoder.cpp"
+ >
+ </File>
</Filter>
<Filter
Name="Header Files"
@@ -671,6 +675,10 @@
RelativePath=".\win_platform.h"
>
</File>
+ <File
+ RelativePath="..\zlib_decoder.h"
+ >
+ </File>
</Filter>
<Filter
Name="Resource Files"
diff --git a/client/x11/Makefile.am b/client/x11/Makefile.am
index 3d90e9f..81036fb 100644
--- a/client/x11/Makefile.am
+++ b/client/x11/Makefile.am
@@ -112,6 +112,8 @@ RED_COMMON_SRCS = \
$(CLIENT_DIR)/tunnel_channel.h \
$(CLIENT_DIR)/utils.cpp \
$(CLIENT_DIR)/utils.h \
+ $(CLIENT_DIR)/zlib_decoder.cpp \
+ $(CLIENT_DIR)/zlib_decoder.h \
$(CLIENT_DIR)/icon.h \
$(CLIENT_DIR)/gui/softrenderer.h \
$(CLIENT_DIR)/gui/softrenderer.cpp \
@@ -174,6 +176,7 @@ spicec_LDFLAGS = \
$(SSL_LIBS) \
$(CEGUI_LIBS) \
$(JPEG_LIBS) \
+ $(Z_LIBS) \
$(SPICE_NONPKGCONFIG_LIBS)
spicec_LDADD = \
diff --git a/client/zlib_decoder.cpp b/client/zlib_decoder.cpp
new file mode 100644
index 0000000..68b1b33
--- /dev/null
+++ b/client/zlib_decoder.cpp
@@ -0,0 +1,58 @@
+#include "common.h"
+#include "zlib_decoder.h"
+#include "debug.h"
+#include "utils.h"
+
+static void op_decode(SpiceZlibDecoder *decoder,
+ uint8_t *data,
+ int data_size,
+ uint8_t *dest,
+ int dest_size)
+{
+ ZlibDecoder* _decoder = static_cast<ZlibDecoder*>(decoder);
+ _decoder->decode(data, data_size, dest, dest_size);
+}
+
+ZlibDecoder::ZlibDecoder()
+{
+ int z_ret;
+
+ _z_strm.zalloc = Z_NULL;
+ _z_strm.zfree = Z_NULL;
+ _z_strm.opaque = Z_NULL;
+ _z_strm.next_in = Z_NULL;
+ _z_strm.avail_in = 0;
+ z_ret = inflateInit(&_z_strm);
+ if (z_ret != Z_OK) {
+ THROW("zlib decoder init failed, error %d", z_ret);
+ }
+
+ static SpiceZlibDecoderOps decoder_ops = {
+ op_decode,
+ };
+
+ ops = &decoder_ops;
+}
+
+ZlibDecoder::~ZlibDecoder()
+{
+ inflateEnd(&_z_strm);
+}
+
+
+void ZlibDecoder::decode(uint8_t *data, int data_size, uint8_t *dest, int dest_size)
+{
+ int z_ret;
+
+ inflateReset(&_z_strm);
+ _z_strm.next_in = data;
+ _z_strm.avail_in = data_size;
+ _z_strm.next_out = dest;
+ _z_strm.avail_out = dest_size;
+
+ z_ret = inflate(&_z_strm, Z_FINISH);
+
+ if (z_ret != Z_STREAM_END) {
+ THROW("zlib inflate failed, error %d", z_ret);
+ }
+}
diff --git a/client/zlib_decoder.h b/client/zlib_decoder.h
new file mode 100644
index 0000000..84b6f83
--- /dev/null
+++ b/client/zlib_decoder.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ Copyright (C) 2010 Red Hat, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _H_ZLIB_DECODER
+#define _H_ZLIB_DECODER
+
+#include "common.h"
+#include "canvas_base.h"
+
+#define ZLIB_WINAPI
+#include <zlib.h>
+
+
+class ZlibDecoder : public SpiceZlibDecoder {
+public:
+ ZlibDecoder();
+ ~ZlibDecoder();
+
+ void decode(uint8_t *data, int data_size, uint8_t *dest, int dest_size);
+
+private:
+ z_stream _z_strm;
+
+};
+
+#endif