[Spice-commits] 5 commits - display.js spiceconn.js utils.js

Jeremy White jwhite at kemper.freedesktop.org
Mon Oct 10 16:31:58 UTC 2016


 display.js   |   36 ++++++++++++++++++------------------
 spiceconn.js |   27 +++++++++++++++++----------
 utils.js     |    5 +++++
 3 files changed, 40 insertions(+), 28 deletions(-)

New commits:
commit bed406adf343d4ca4898f5bc62332a2783b9a82b
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Wed Sep 28 10:16:24 2016 -0500

    Protect against an mjpeg stream image draw occuring after stream destruction.

diff --git a/display.js b/display.js
index d9bdd9f..e26bff8 100644
--- a/display.js
+++ b/display.js
@@ -963,8 +963,8 @@ function handle_draw_jpeg_onload()
         this.o.sc.surfaces[this.o.base.surface_id].draw_count++;
     }
 
-    if ("report" in this.o.sc.streams[this.o.id])
-            process_stream_data_report(this.o.sc, this.o.id, this.o.msg_mmtime, this.o.msg_mmtime - this.o.sc.parent.relative_now())
+    if (this.o.sc.streams[this.o.id] && "report" in this.o.sc.streams[this.o.id])
+        process_stream_data_report(this.o.sc, this.o.id, this.o.msg_mmtime, this.o.msg_mmtime - this.o.sc.parent.relative_now());
 }
 
 function process_mjpeg_stream_data(sc, m, time_until_due)
commit 42134d3e56f5c7551eeb2d0dac9fced89b7e49b6
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Wed Sep 28 10:11:55 2016 -0500

    Use empty image instead of null to avoid warnings

diff --git a/display.js b/display.js
index 6c6b962..d9bdd9f 100644
--- a/display.js
+++ b/display.js
@@ -933,7 +933,7 @@ function handle_draw_jpeg_onload()
 
         // Give the Garbage collector a clue to recycle this; avoids
         //  fairly massive memory leaks during video playback
-        this.src = null;
+        this.src = EMPTY_GIF_IMAGE;
 
         if (this.o.descriptor &&
             (this.o.descriptor.flags & SPICE_IMAGE_FLAGS_CACHE_ME))
diff --git a/utils.js b/utils.js
index a22d0ae..7aeefdb 100644
--- a/utils.js
+++ b/utils.js
@@ -27,6 +27,11 @@ var STREAM_DEBUG = 0;
 var DUMP_DRAWS = false;
 var DUMP_CANVASES = false;
 
+/*----------------------------------------------------------------------------
+**  We use an Image temporarily, and the image/src does not get garbage
+**   collected as quickly as we might like.  This blank image helps with that.
+**--------------------------------------------------------------------------*/
+var EMPTY_GIF_IMAGE = "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
 
 /*----------------------------------------------------------------------------
 **  combine_array_buffers
commit dd3fb12678b1769ce3f299b3c4b813bf0bd4dfdd
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Wed Sep 28 10:01:43 2016 -0500

    If MediaSource is not available, do not report the vp8 or opus caps.

diff --git a/spiceconn.js b/spiceconn.js
index 9651b47..33e7388 100644
--- a/spiceconn.js
+++ b/spiceconn.js
@@ -127,21 +127,28 @@ SpiceConn.prototype =
             );
 
         if (msg.channel_type == SPICE_CHANNEL_PLAYBACK)
-            msg.channel_caps.push(
-                (1 << SPICE_PLAYBACK_CAP_OPUS)
-            );
+        {
+            var caps = 0;
+            if ('MediaSource' in window && MediaSource.isTypeSupported(SPICE_PLAYBACK_CODEC))
+                caps |= (1 << SPICE_PLAYBACK_CAP_OPUS);
+            msg.channel_caps.push(caps);
+        }
         else if (msg.channel_type == SPICE_CHANNEL_MAIN)
+        {
             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) |
-                (1 << SPICE_DISPLAY_CAP_STREAM_REPORT) |
-                (1 << SPICE_DISPLAY_CAP_MULTI_CODEC) |
-                (1 << SPICE_DISPLAY_CAP_CODEC_MJPEG) |
-                (1 << SPICE_DISPLAY_CAP_CODEC_VP8)
-            );
+        {
+            var caps =  (1 << SPICE_DISPLAY_CAP_SIZED_STREAM) |
+                        (1 << SPICE_DISPLAY_CAP_STREAM_REPORT) |
+                        (1 << SPICE_DISPLAY_CAP_MULTI_CODEC) |
+                        (1 << SPICE_DISPLAY_CAP_CODEC_MJPEG);
+            if ('MediaSource' in window && MediaSource.isTypeSupported(SPICE_VP8_CODEC))
+                caps |= (1 << SPICE_DISPLAY_CAP_CODEC_VP8);
+            msg.channel_caps.push(caps);
+        }
 
         hdr.size = msg.buffer_size();
 
commit b474c300a8da07b868235c490882f5af050620a0
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Mon Sep 26 15:33:28 2016 -0500

    Improve stream debug messages slightly.

diff --git a/display.js b/display.js
index 9fc13c0..6c6b962 100644
--- a/display.js
+++ b/display.js
@@ -535,7 +535,10 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
     if (msg.type == SPICE_MSG_DISPLAY_STREAM_CREATE)
     {
         var m = new SpiceMsgDisplayStreamCreate(msg.data);
-        DEBUG > 1 && console.log(this.type + ": MsgStreamCreate id" + m.id);
+        STREAM_DEBUG > 1 && console.log(this.type + ": MsgStreamCreate id" + m.id +
+                                        "; width " + m.stream_width + "; height " + m.stream_height +
+                                        "; left " + m.dest.left + "; top " + m.dest.top
+                                        );
         if (!this.streams)
             this.streams = new Array();
         if (this.streams[m.id])
@@ -628,7 +631,7 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
     if (msg.type == SPICE_MSG_DISPLAY_STREAM_CLIP)
     {
         var m = new SpiceMsgDisplayStreamClip(msg.data);
-        DEBUG > 1 && console.log(this.type + ": MsgStreamClip id" + m.id);
+        STREAM_DEBUG > 1 && console.log(this.type + ": MsgStreamClip id" + m.id);
         this.streams[m.id].clip = m.clip;
         return true;
     }
@@ -636,7 +639,7 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
     if (msg.type == SPICE_MSG_DISPLAY_STREAM_DESTROY)
     {
         var m = new SpiceMsgDisplayStreamDestroy(msg.data);
-        DEBUG > 1 && console.log(this.type + ": MsgStreamDestroy id" + m.id);
+        STREAM_DEBUG > 1 && console.log(this.type + ": MsgStreamDestroy id" + m.id);
 
         if (this.streams[m.id].codec_type == SPICE_VIDEO_CODEC_TYPE_VP8)
         {
commit 57134818c306eca9424b204c105b29b224755201
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Mon Sep 26 15:41:29 2016 -0500

    Do not wait for the source buffer open callback to start stream creation.
    
    Otherwise, we end up discarding stream data messages, and our decode
    can become corrupted, notably on Chrome.
    
    This way, we should not lose any messages while we are waiting for
    source buffer creation.

diff --git a/display.js b/display.js
index d8239c2..9fc13c0 100644
--- a/display.js
+++ b/display.js
@@ -567,12 +567,17 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
             media.addEventListener('sourceended', handle_video_source_ended, false);
             media.addEventListener('sourceclosed', handle_video_source_closed, false);
 
-            this.streams[m.id].video = v;
-            this.streams[m.id].media = media;
-
-            media.stream = this.streams[m.id];
+            var s = this.streams[m.id];
+            s.video = v;
+            s.media = media;
+            s.queue = new Array();
+            s.start_time = 0;
+            s.cluster_time = 0;
+            s.append_okay = false;
+
+            media.stream = s;
             media.spiceconn = this;
-            v.spice_stream = this.streams[m.id];
+            v.spice_stream = s;
         }
         else if (m.codec_type != SPICE_VIDEO_CODEC_TYPE_MJPEG)
             console.log("Unhandled stream codec: "+m.codec_type);
@@ -1035,10 +1040,6 @@ function handle_video_source_open(e)
     s.spiceconn = p;
     s.stream = stream;
 
-    stream.queue = new Array();
-    stream.start_time = 0;
-    stream.cluster_time = 0;
-
     listen_for_video_events(stream);
 
     var h = new webm_Header();
@@ -1153,13 +1154,9 @@ function new_video_cluster(stream, msg)
 
 function process_video_stream_data(stream, msg)
 {
-    if (! stream.source_buffer)
-        return true;
-
     if (stream.start_time == 0)
     {
         stream.start_time = msg.base.multi_media_time;
-        stream.video.play();
         new_video_cluster(stream, msg);
     }
 


More information about the Spice-commits mailing list