Skip to content

Instantly share code, notes, and snippets.

@kanaka
Created November 6, 2010 17:49
Show Gist options
  • Save kanaka/665575 to your computer and use it in GitHub Desktop.
Save kanaka/665575 to your computer and use it in GitHub Desktop.
Patch to aliguori's start of WebSockets support in QEMU
Patch on http://repo.or.cz/w/qemu/aliguori-queue.git/shortlog/refs/heads/vncws
Allow ver 75 and fix header response.
Detect if client is version 75 or 76 and respond appropriately. Also,
parse the path from the request and return the correct Location field
using the host and path.
Also fix some i386 compile errors:
- Hide ivshmem.c under kvm
- type cast some variables in prints
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index c4c9c3b..64a4967 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -322,23 +322,30 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
VncPalette **palette) { \
uint##bpp##_t *data; \
uint##bpp##_t c0, c1, ci; \
+ VNC_DEBUG(">> tight_fill_pallette%d 1\n", bpp); \
int i, n0, n1; \
\
data = (uint##bpp##_t *)vs->tight.tight.buffer; \
\
+ VNC_DEBUG(">> tight_fill_pallette%d 1.1\n", bpp); \
+ VNC_DEBUG(">> tight_fill_pallette%d 1.1: data: %p\n", bpp, data); \
c0 = data[0]; \
i = 1; \
+ VNC_DEBUG(">> tight_fill_pallette%d 1.2\n", bpp); \
while (i < count && data[i] == c0) \
i++; \
+ VNC_DEBUG(">> tight_fill_pallette%d 1.3\n", bpp); \
if (i >= count) { \
*bg = *fg = c0; \
return 1; \
} \
+ VNC_DEBUG(">> tight_fill_pallette%d 1.4\n", bpp); \
\
if (max < 2) { \
return 0; \
} \
\
+ VNC_DEBUG(">> tight_fill_pallette%d 2\n", bpp); \
n0 = i; \
c1 = data[i]; \
n1 = 0; \
@@ -362,6 +369,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
return 2; \
} \
\
+ VNC_DEBUG(">> tight_fill_pallette%d 3\n", bpp); \
if (max == 2) { \
return 0; \
} \
@@ -371,6 +379,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
palette_put(*palette, c1); \
palette_put(*palette, ci); \
\
+ VNC_DEBUG(">> tight_fill_pallette%d 4\n", bpp); \
for (i++; i < count; i++) { \
if (data[i] == ci) { \
continue; \
@@ -382,6 +391,7 @@ tight_detect_smooth_image(VncState *vs, int w, int h)
} \
} \
\
+ VNC_DEBUG(">> tight_fill_pallette%d 5\n", bpp); \
return palette_size(*palette); \
}
@@ -1512,18 +1522,23 @@ static int send_sub_rect_jpeg(VncState *vs, int x, int y, int w, int h,
static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
{
+ VNC_DEBUG(">> send_sub_rect(%d, %d, %d, %d)\n", x, y, w, h);
VncPalette *palette = NULL;
uint32_t bg = 0, fg = 0;
int colors;
int ret = 0;
+ VNC_DEBUG(">> send_sub_rect 1\n");
vnc_framebuffer_update(vs, x, y, w, h, vs->tight.type);
+ VNC_DEBUG(">> send_sub_rect 2\n");
vnc_tight_start(vs);
vnc_raw_send_framebuffer_update(vs, x, y, w, h);
vnc_tight_stop(vs);
+ VNC_DEBUG(">> send_sub_rect 3\n");
colors = tight_fill_palette(vs, x, y, w * h, &fg, &bg, &palette);
+ VNC_DEBUG(">> send_sub_rect 4\n");
#ifdef CONFIG_VNC_JPEG
if (vs->tight.quality != (uint8_t)-1) {
@@ -1535,7 +1550,9 @@ static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
ret = send_sub_rect_nojpeg(vs, x, y, w, h, bg, fg, colors, palette);
#endif
+ VNC_DEBUG(">> send_sub_rect 5\n");
palette_destroy(palette);
+ VNC_DEBUG("<< send_sub_rect(%d, %d, %d, %d)\n", x, y, w, h);
return ret;
}
@@ -1558,6 +1575,7 @@ static int send_rect_simple(VncState *vs, int x, int y, int w, int h)
int rw, rh;
int n = 0;
+ VNC_DEBUG(">> send_rect_simple\n");
max_size = tight_conf[vs->tight.compression].max_rect_size;
max_width = tight_conf[vs->tight.compression].max_rect_width;
diff --git a/ui/vnc.c b/ui/vnc.c
index a551dce..453f613 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1076,9 +1076,9 @@ long vnc_client_write_buf(VncState *vs, const uint8_t *data, size_t datalen)
ret = send(vs->csock, (const void *)data, datalen, 0);
VNC_DEBUG("Wrote wire %p %zd -> %ld\n", data, datalen, ret);
if (vs->websockets && vs->encode_ws) {
- VNC_DEBUG("data {\n%s\n}\n", data+1);
+ //VNC_DEBUG("data {\n%s\n}\n", data+1);
} else {
- VNC_DEBUG("data {\n%s\n}\n", data);
+ //VNC_DEBUG("data {\n%s\n}\n", data);
}
return vnc_client_io_error(vs, ret, socket_error());
}
@@ -1414,7 +1414,7 @@ void vnc_client_read(void *opaque)
void vnc_write(VncState *vs, const void *data, size_t len)
{
if (vs->encode_ws) {
- VNC_DEBUG("writing encoded data\n");
+ //VNC_DEBUG("writing encoded data\n");
buffer_append(&vs->ws_output, data, len);
} else {
buffer_reserve(&vs->output, len);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment