Commit f8f62215 authored by Jeremy White's avatar Jeremy White Committed by Alon Levy
Browse files

initial

parents
This diff is collapsed.
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
Prototype Spice Javascript client
Instructions and status as of June 1, 2012.
Requirements:
1. Modern Firefox or Chrome
2. A WebSocket proxy
I've used websockify:
https://github.com/kanaka/websockify
works great.
3. A spice server
At this point, I've tested with qemu hosting
a Fedora image, a Vista image, and with Xspice.
Vista was pretty bad; I recommend either Linux or Xspice.
** Xspice has a processing issue; see this email:
http://lists.freedesktop.org/archives/spice-devel/2012-May/009020.html
Optional:
1. A web server
With firefox, you can just open file:///your-path-to-spice.html-here
With Chrome, you have to set a secret config flag to do that, or
serve the files from a web server.
Steps:
1. Start the spice server
2. Start websockify; my command line looks like this:
./websockify 5959 localhost:5900
3. Fire up spice.html, set host + port + password, and click start
Status:
The TODO file should be a fairly comprehensive list of tasks
required to make this client more fully functional.
As of June 1, 2012, this client is a nifty proof of concept,
but a long way from being a useful production tool.
Bugs:
. In my latest Xorg/fluxbox theme test, I get flickering of title
windows, notably when you start up gimp. That seems new.
. In Chrome, I've gotten it to get the parsing out of sync.
Not clear why or how to reproduce. I've added a javascript
alert to hopefully make finding it more possible.
A test case is really needed for it...
. Drawing with Gimp is slow (lack of stream support?)
. If using xspice, you can get two bugs; a complete stall
(until you do something on the X server), or losing the mouse.
Both are probably related to that the watch_add/watch_update_mask functionality
in the qxl driver doesn't work. A patch for that has been submitted
to spice-devel ('Actually process write watches in the wakeup handler').
Medium Tasks:
. Get the mouse event code out of spicemsg (and make spicemsg
*only* about messages)
. Change the message processing to be able to handle
an array of ArrayBuffers so we don't have to
use the combine function, which is presumed slow.
. Use the 'real' DataView if we have it
. Remove main() from quic.c and respin it
- It's causing unneeded bloat and memory use.
. Consider passing a status change event back to the front end
(e.g. indicators for numlock, connection status, all that jazz)
. Try to further Improve mouse position sends
- We now discard motions when we're more than 2 * SPICE_INPUT_MOTION_ACK_BUNCH
from an ack, just like the gtk client
- Other idea 1: queue them and only send when idle, but collapse first?
- Other idea 2: Time limit motion events
. The whole key code to scan code thing is awful and should be
taken out and shot...or revamped
Big Tasks:
. Generate messages + enums from spice.proto
. Video + Audio:
- Need either ogg or webm codec
- Probably need a codec other than celt 0.51
- Need a way to feed stream into a media object
* Javascript uri?
* best would be Media Source Extensions draft, but only in Chrome so far
* some trick with createObjectUrl? see:
- http://dev.w3.org/2011/webrtc/editor/getusermedia.html
. Explore clipboard
- Supporting it may require unpleasant hacks
. Fully flesh out image type support; plt, glz, and jpeg/alpha are likely
to be real work
. Fix the many limitations of Draw operation support (clipping, masking,
scaling, and so on)
. Implement direct websocket support for the spice server
. Profile the whole mess
- Initial profiling suggests image decompression is the big hog
. Quic: faster implementations
* current implementation is approximately 13x slower
than equivalent C code. Should be able to do
much better than that.
. Implement agent support
. Build a test suite for measuring performance
- Latency, bandwidth, packet loss
- But how to quantify 'feel'?
- Suggestion: recordmydesktop to capture videos
Use something like cxtest to create scripts
Do this with varying latency/bandwidth, etc
We can play videos side by side
And potentially use tool like MSU Video Quality Measurement Tool
(SSIM is the concept for measuring how much frames differ)
- Key metric - how much cpu / memory / bandwidth per 'active' user
"use strict";
/*
Copyright (C) 2012 by Jeremy P. White <jwhite@codeweavers.com>
This file is part of spice-html5.
spice-html5 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 3 of the License, or
(at your option) any later version.
spice-html5 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 spice-html5. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
** bitmap.js
** Handle SPICE_IMAGE_TYPE_BITMAP
**--------------------------------------------------------------------------*/
function convert_spice_bitmap_to_web(context, spice_bitmap)
{
var ret;
var offset, x;
var u8 = new Uint8Array(spice_bitmap.data);
if (spice_bitmap.format != SPICE_BITMAP_FMT_32BIT &&
spice_bitmap.format != SPICE_BITMAP_FMT_RGBA)
return undefined;
ret = context.createImageData(spice_bitmap.x, spice_bitmap.y);
for (offset = 0; offset < (spice_bitmap.y * spice_bitmap.stride); )
for (x = 0; x < spice_bitmap.x; x++, offset += 4)
{
ret.data[offset + 0 ] = u8[offset + 2];
ret.data[offset + 1 ] = u8[offset + 1];
ret.data[offset + 2 ] = u8[offset + 0];
// FIXME - We effectively treat all images as having SPICE_IMAGE_FLAGS_HIGH_BITS_SET
if (spice_bitmap.format == SPICE_BITMAP_FMT_32BIT)
ret.data[offset + 3] = 255;
else
ret.data[offset + 3] = u8[offset];
}
return ret;
}
"use strict";
/*
Copyright (C) 2012 by Jeremy P. White <jwhite@codeweavers.com>
This file is part of spice-html5.
spice-html5 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 3 of the License, or
(at your option) any later version.
spice-html5 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 spice-html5. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
** SpiceCursorConn
** Drive the Spice Cursor Channel
**--------------------------------------------------------------------------*/
function SpiceCursorConn()
{
SpiceConn.apply(this, arguments);
}
SpiceCursorConn.prototype = Object.create(SpiceConn.prototype);
SpiceCursorConn.prototype.process_channel_message = function(msg)
{
if (msg.type == SPICE_MSG_CURSOR_INIT)
{
var cursor_init = new SpiceMsgCursorInit(msg.data);
DEBUG > 1 && console.log("SpiceMsgCursorInit");
if (this.parent && this.parent.inputs &&
this.parent.inputs.mouse_mode == SPICE_MOUSE_MODE_SERVER)
{
// FIXME - this imagines that the server actually
// provides the current cursor position,
// instead of 0,0. As of May 11, 2012,
// that assumption was false :-(.
this.parent.inputs.mousex = cursor_init.position.x;
this.parent.inputs.mousey = cursor_init.position.y;
}
// FIXME - We don't handle most of the parameters here...
return true;
}
if (msg.type == SPICE_MSG_CURSOR_SET)
{
var cursor_set = new SpiceMsgCursorSet(msg.data);
DEBUG > 1 && console.log("SpiceMsgCursorSet");
if (cursor_set.flags & SPICE_CURSOR_FLAGS_NONE)
{
document.getElementById(this.parent.screen_id).style.cursor = "none";
return true;
}
if (cursor_set.flags > 0)
this.log_warn("FIXME: No support for cursor flags " + cursor_set.flags);
if (cursor_set.cursor.header.type != SPICE_CURSOR_TYPE_ALPHA)
{
this.log_warn("FIXME: No support for cursor type " + cursor_set.cursor.header.type);
return false;
}
this.set_cursor(cursor_set.cursor);
return true;
}
if (msg.type == SPICE_MSG_CURSOR_HIDE)
{
DEBUG > 1 && console.log("SpiceMsgCursorHide");
document.getElementById(this.parent.screen_id).style.cursor = "none";
return true;
}
return false;
}
SpiceCursorConn.prototype.set_cursor = function(cursor)
{
var pngstr = create_rgba_png(cursor.header.height, cursor.header.width, cursor.data);
var curstr = 'url(data:image/png,' + pngstr + ') ' +
cursor.header.hot_spot_x + ' ' + cursor.header.hot_spot_y + ", default";
document.getElementById(this.parent.screen_id).style.cursor = curstr;
}
This diff is collapsed.
"use strict";
/*
Copyright (C) 2012 by Jeremy P. White <jwhite@codeweavers.com>
This file is part of spice-html5.
spice-html5 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 3 of the License, or
(at your option) any later version.
spice-html5 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 spice-html5. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
** enums.js
** 'constants' for Spice
**--------------------------------------------------------------------------*/
var SPICE_MAGIC = "REDQ";
var SPICE_VERSION_MAJOR = 2;
var SPICE_VERSION_MINOR = 2;
var SPICE_CONNECT_TIMEOUT = (30 * 1000);
var SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION = 0;
var SPICE_COMMON_CAP_AUTH_SPICE = 1;
var SPICE_COMMON_CAP_AUTH_SASL = 2;
var SPICE_COMMON_CAP_MINI_HEADER = 3;
var SPICE_TICKET_KEY_PAIR_LENGTH = 1024;
var SPICE_TICKET_PUBKEY_BYTES = (SPICE_TICKET_KEY_PAIR_LENGTH / 8 + 34);
var SPICE_LINK_ERR_OK = 0,
SPICE_LINK_ERR_ERROR = 1,
SPICE_LINK_ERR_INVALID_MAGIC = 2,
SPICE_LINK_ERR_INVALID_DATA = 3,
SPICE_LINK_ERR_VERSION_MISMATCH = 4,
SPICE_LINK_ERR_NEED_SECURED = 5,
SPICE_LINK_ERR_NEED_UNSECURED = 6,
SPICE_LINK_ERR_PERMISSION_DENIED = 7,
SPICE_LINK_ERR_BAD_CONNECTION_ID = 8,
SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE = 9;
var SPICE_MSG_MIGRATE = 1;
var SPICE_MSG_MIGRATE_DATA = 2;
var SPICE_MSG_SET_ACK = 3;
var SPICE_MSG_PING = 4;
var SPICE_MSG_WAIT_FOR_CHANNELS = 5;
var SPICE_MSG_DISCONNECTING = 6;
var SPICE_MSG_NOTIFY = 7;
var SPICE_MSG_LIST = 8;
var SPICE_MSG_MAIN_MIGRATE_BEGIN = 101;
var SPICE_MSG_MAIN_MIGRATE_CANCEL = 102;
var SPICE_MSG_MAIN_INIT = 103;
var SPICE_MSG_MAIN_CHANNELS_LIST = 104;
var SPICE_MSG_MAIN_MOUSE_MODE = 105;
var SPICE_MSG_MAIN_MULTI_MEDIA_TIME = 106;
var SPICE_MSG_MAIN_AGENT_CONNECTED = 107;
var SPICE_MSG_MAIN_AGENT_DISCONNECTED = 108;
var SPICE_MSG_MAIN_AGENT_DATA = 109;
var SPICE_MSG_MAIN_AGENT_TOKEN = 110;
var SPICE_MSG_MAIN_MIGRATE_SWITCH_HOST = 111;
var SPICE_MSG_MAIN_MIGRATE_END = 112;
var SPICE_MSG_MAIN_NAME = 113;
var SPICE_MSG_MAIN_UUID = 114;
var SPICE_MSG_END_MAIN = 115;
var SPICE_MSGC_ACK_SYNC = 1;
var SPICE_MSGC_ACK = 2;
var SPICE_MSGC_PONG = 3;
var SPICE_MSGC_MIGRATE_FLUSH_MARK = 4;
var SPICE_MSGC_MIGRATE_DATA = 5;
var SPICE_MSGC_DISCONNECTING = 6;
var SPICE_MSGC_MAIN_CLIENT_INFO = 101;
var SPICE_MSGC_MAIN_MIGRATE_CONNECTED = 102;
var SPICE_MSGC_MAIN_MIGRATE_CONNECT_ERROR = 103;
var SPICE_MSGC_MAIN_ATTACH_CHANNELS = 104;
var SPICE_MSGC_MAIN_MOUSE_MODE_REQUEST = 105;
var SPICE_MSGC_MAIN_AGENT_START = 106;
var SPICE_MSGC_MAIN_AGENT_DATA = 107;
var SPICE_MSGC_MAIN_AGENT_TOKEN = 108;
var SPICE_MSGC_MAIN_MIGRATE_END = 109;
var SPICE_MSGC_END_MAIN = 110;
var SPICE_MSG_DISPLAY_MODE = 101;
var SPICE_MSG_DISPLAY_MARK = 102;
var SPICE_MSG_DISPLAY_RESET = 103;
var SPICE_MSG_DISPLAY_COPY_BITS = 104;
var SPICE_MSG_DISPLAY_INVAL_LIST = 105;
var SPICE_MSG_DISPLAY_INVAL_ALL_PIXMAPS = 106;
var SPICE_MSG_DISPLAY_INVAL_PALETTE = 107;
var SPICE_MSG_DISPLAY_INVAL_ALL_PALETTES= 108;
var SPICE_MSG_DISPLAY_STREAM_CREATE = 122;
var SPICE_MSG_DISPLAY_STREAM_DATA = 123;
var SPICE_MSG_DISPLAY_STREAM_CLIP = 124;
var SPICE_MSG_DISPLAY_STREAM_DESTROY = 125;
var SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL= 126;
var SPICE_MSG_DISPLAY_DRAW_FILL = 302;
var SPICE_MSG_DISPLAY_DRAW_OPAQUE = 303;
var SPICE_MSG_DISPLAY_DRAW_COPY = 304;
var SPICE_MSG_DISPLAY_DRAW_BLEND = 305;
var SPICE_MSG_DISPLAY_DRAW_BLACKNESS = 306;
var SPICE_MSG_DISPLAY_DRAW_WHITENESS = 307;
var SPICE_MSG_DISPLAY_DRAW_INVERS = 308;
var SPICE_MSG_DISPLAY_DRAW_ROP3 = 309;
var SPICE_MSG_DISPLAY_DRAW_STROKE = 310;
var SPICE_MSG_DISPLAY_DRAW_TEXT = 311;
var SPICE_MSG_DISPLAY_DRAW_TRANSPARENT = 312;
var SPICE_MSG_DISPLAY_DRAW_ALPHA_BLEND = 313;
var SPICE_MSG_DISPLAY_SURFACE_CREATE = 314;
var SPICE_MSG_DISPLAY_SURFACE_DESTROY = 315;
var SPICE_MSGC_DISPLAY_INIT = 101;
var SPICE_MSG_INPUTS_INIT = 101;
var SPICE_MSG_INPUTS_KEY_MODIFIERS = 102;
var SPICE_MSG_INPUTS_MOUSE_MOTION_ACK = 111;
var SPICE_MSGC_INPUTS_KEY_DOWN = 101;
var SPICE_MSGC_INPUTS_KEY_UP = 102;
var SPICE_MSGC_INPUTS_KEY_MODIFIERS = 103;
var SPICE_MSGC_INPUTS_MOUSE_MOTION = 111;
var SPICE_MSGC_INPUTS_MOUSE_POSITION = 112;
var SPICE_MSGC_INPUTS_MOUSE_PRESS = 113;
var SPICE_MSGC_INPUTS_MOUSE_RELEASE = 114;
var SPICE_MSG_CURSOR_INIT = 101;
var SPICE_MSG_CURSOR_RESET = 102;
var SPICE_MSG_CURSOR_SET = 103;
var SPICE_MSG_CURSOR_MOVE = 104;
var SPICE_MSG_CURSOR_HIDE = 105;
var SPICE_MSG_CURSOR_TRAIL = 106;
var SPICE_MSG_CURSOR_INVAL_ONE = 107;
var SPICE_MSG_CURSOR_INVAL_ALL = 108;
var SPICE_CHANNEL_MAIN = 1;
var SPICE_CHANNEL_DISPLAY = 2;
var SPICE_CHANNEL_INPUTS = 3;
var SPICE_CHANNEL_CURSOR = 4;
var SPICE_CHANNEL_PLAYBACK = 5;
var SPICE_CHANNEL_RECORD = 6;
var SPICE_CHANNEL_TUNNEL = 7;
var SPICE_CHANNEL_SMARTCARD = 8;
var SPICE_CHANNEL_USBREDIR = 9;
var SPICE_SURFACE_FLAGS_PRIMARY = (1 << 0);
var SPICE_NOTIFY_SEVERITY_INFO = 0;
var SPICE_NOTIFY_SEVERITY_WARN = 1;
var SPICE_NOTIFY_SEVERITY_ERROR = 2;
var SPICE_MOUSE_MODE_SERVER = (1 << 0),
SPICE_MOUSE_MODE_CLIENT = (1 << 1),
SPICE_MOUSE_MODE_MASK = 0x3;
var SPICE_CLIP_TYPE_NONE = 0;
var SPICE_CLIP_TYPE_RECTS = 1;
var SPICE_IMAGE_TYPE_BITMAP = 0;
var SPICE_IMAGE_TYPE_QUIC = 1;
var SPICE_IMAGE_TYPE_RESERVED = 2;
var SPICE_IMAGE_TYPE_LZ_PLT = 100;
var SPICE_IMAGE_TYPE_LZ_RGB = 101;
var SPICE_IMAGE_TYPE_GLZ_RGB = 102;
var SPICE_IMAGE_TYPE_FROM_CACHE = 103;
var SPICE_IMAGE_TYPE_SURFACE = 104;