[PATCH spice-html5 2/3] Implement support for sized data streams.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx>
---
 display.js   | 60 ++++++++++++++++++++++++++++++++++++++----------------------
 enums.js     | 11 +++++++++++
 spiceconn.js |  4 ++++
 spicemsg.js  | 23 +++++++++++++++++++++++
 4 files changed, 76 insertions(+), 22 deletions(-)

diff --git a/display.js b/display.js
index a749dae..7027230 100644
--- a/display.js
+++ b/display.js
@@ -487,32 +487,21 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
         }
         if (this.streams[m.base.id].codec_type === SPICE_VIDEO_CODEC_TYPE_MJPEG)
         {
-            var tmpstr = "data:image/jpeg,";
-            var img = new Image;
-            var i;
-            for (i = 0; i < m.data.length; i++)
-            {
-                tmpstr +=  '%';
-                if (m.data[i] < 16)
-                tmpstr += '0';
-                tmpstr += m.data[i].toString(16);
-            }
-            var strm_base = new SpiceMsgDisplayBase();
-            strm_base.surface_id = this.streams[m.base.id].surface_id;
-            strm_base.box = this.streams[m.base.id].dest;
-            strm_base.clip = this.streams[m.base.id].clip;
-            img.o =
-                { base: strm_base,
-                  tag: "mjpeg." + m.base.id,
-                  descriptor: null,
-                  sc : this,
-                };
-            img.onload = handle_draw_jpeg_onload;
-            img.src = tmpstr;
+            process_mjpeg_stream_data(this, m);
+
         }
         return true;
     }
 
+    if (msg.type == SPICE_MSG_DISPLAY_STREAM_DATA_SIZED)
+    {
+        var m = new SpiceMsgDisplayStreamDataSized(msg.data);
+        if (this.streams[m.base.id].codec_type === SPICE_VIDEO_CODEC_TYPE_MJPEG)
+            process_mjpeg_stream_data(this, m);
+        return true;
+    }
+
+
     if (msg.type == SPICE_MSG_DISPLAY_STREAM_CLIP)
     {
         var m = new SpiceMsgDisplayStreamClip(msg.data);
@@ -821,3 +810,30 @@ function handle_draw_jpeg_onload()
         this.o.sc.surfaces[this.o.base.surface_id].draw_count++;
     }
 }
+
+function process_mjpeg_stream_data(sc, m)
+{
+    var tmpstr = "data:image/jpeg,";
+    var img = new Image;
+    var i;
+    for (i = 0; i < m.data.length; i++)
+    {
+        tmpstr +=  '%';
+        if (m.data[i] < 16)
+        tmpstr += '0';
+        tmpstr += m.data[i].toString(16);
+    }
+    var strm_base = new SpiceMsgDisplayBase();
+    strm_base.surface_id = sc.streams[m.base.id].surface_id;
+    strm_base.box = m.dest || sc.streams[m.base.id].dest;
+    strm_base.clip = sc.streams[m.base.id].clip;
+    img.o =
+        { base: strm_base,
+          tag: "mjpeg." + m.base.id,
+          descriptor: null,
+          sc : sc,
+        };
+    img.onload = handle_draw_jpeg_onload;
+    img.src = tmpstr;
+}
+
diff --git a/enums.js b/enums.js
index 17d77cb..7f55e46 100644
--- a/enums.js
+++ b/enums.js
@@ -127,6 +127,10 @@ 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_MSG_DISPLAY_STREAM_DATA_SIZED = 316;
+var SPICE_MSG_DISPLAY_MONITORS_CONFIG   = 317;
+var SPICE_MSG_DISPLAY_DRAW_COMPOSITE    = 318;
+var SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT = 319;
 
 var SPICE_MSGC_DISPLAY_INIT             = 101;
 
@@ -171,6 +175,13 @@ var SPICE_MAIN_CAP_NAME_AND_UUID          = 1;
 var SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS = 2;
 var SPICE_MAIN_CAP_SEAMLESS_MIGRATE       = 3;
 
+var SPICE_DISPLAY_CAP_SIZED_STREAM        = 0;
+var SPICE_DISPLAY_CAP_MONITORS_CONFIG     = 1;
+var SPICE_DISPLAY_CAP_COMPOSITE           = 2;
+var SPICE_DISPLAY_CAP_A8_SURFACE          = 3;
+var SPICE_DISPLAY_CAP_STREAM_REPORT       = 4;
+var SPICE_DISPLAY_CAP_LZ4_COMPRESSION     = 5;
+
 var SPICE_AUDIO_DATA_MODE_INVALID       = 0;
 var SPICE_AUDIO_DATA_MODE_RAW           = 1;
 var SPICE_AUDIO_DATA_MODE_CELT_0_5_1    = 2;
diff --git a/spiceconn.js b/spiceconn.js
index ec42d8d..b7043c0 100644
--- a/spiceconn.js
+++ b/spiceconn.js
@@ -133,6 +133,10 @@ SpiceConn.prototype =
             msg.channel_caps.push(
                 (1 << SPICE_MAIN_CAP_AGENT_CONNECTED_TOKENS)
             );
+        else if (msg.channel_type == SPICE_CHANNEL_DISPLAY)
+            msg.channel_caps.push(
+                (1 << SPICE_DISPLAY_CAP_SIZED_STREAM)
+            );
 
         hdr.size = msg.buffer_size();
 
diff --git a/spicemsg.js b/spicemsg.js
index e167b3d..4b78d94 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -1146,6 +1146,29 @@ SpiceMsgDisplayStreamData.prototype =
     },
 }
 
+function SpiceMsgDisplayStreamDataSized(a, at)
+{
+    this.from_buffer(a, at);
+}
+
+SpiceMsgDisplayStreamDataSized.prototype =
+{
+    from_buffer: function(a, at)
+    {
+        at = at || 0;
+        var dv = new SpiceDataView(a);
+        this.base = new SpiceStreamDataHeader;
+        at = this.base.from_dv(dv, at, a);
+        this.width = dv.getUint32(at, true); at += 4;
+        this.height = dv.getUint32(at, true); at += 4;
+        this.dest = new SpiceRect;
+        at = this.dest.from_dv(dv, at, a);
+        this.data_size = dv.getUint32(at, true); at += 4;
+        this.data = dv.u8.subarray(at, at + this.data_size);
+    },
+}
+
+
 function SpiceMsgDisplayStreamClip(a, at)
 {
     this.from_buffer(a, at);
-- 
2.1.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]