[Spice-commits] 2 commits - display.js
Jeremy White
jwhite at kemper.freedesktop.org
Fri Jan 20 15:59:15 UTC 2017
display.js | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
New commits:
commit 4ea12e87a222c5c5df3c3ed3838561505d6c4cc5
Author: Jeremy White <jwhite at codeweavers.com>
Date: Thu Dec 29 15:25:43 2016 -0600
Only drop an mjpeg frame if we are not currently processing one.
diff --git a/display.js b/display.js
index 68e0af5..3f5d7bf 100644
--- a/display.js
+++ b/display.js
@@ -582,7 +582,9 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg)
media.spiceconn = this;
v.spice_stream = s;
}
- else if (m.codec_type != SPICE_VIDEO_CODEC_TYPE_MJPEG)
+ else if (m.codec_type == SPICE_VIDEO_CODEC_TYPE_MJPEG)
+ this.streams[m.id].frames_loading = 0;
+ else
console.log("Unhandled stream codec: "+m.codec_type);
return true;
}
@@ -884,6 +886,9 @@ function handle_draw_jpeg_onload()
var temp_canvas = null;
var context;
+ if (this.o.sc.streams[this.o.id])
+ this.o.sc.streams[this.o.id].frames_loading--;
+
/*------------------------------------------------------------
** FIXME:
** The helper should be extended to be able to handle actual HtmlImageElements
@@ -970,7 +975,10 @@ function handle_draw_jpeg_onload()
function process_mjpeg_stream_data(sc, m, time_until_due)
{
- if (time_until_due < 0)
+ /* If we are currently processing an mjpeg frame when a new one arrives,
+ and the new one is 'late', drop the new frame. This helps the browsers
+ keep up, and provides rate control feedback as well */
+ if (time_until_due < 0 && sc.streams[m.base.id].frames_loading > 0)
{
if ("report" in sc.streams[m.base.id])
sc.streams[m.base.id].report.num_drops++;
@@ -1001,6 +1009,8 @@ function process_mjpeg_stream_data(sc, m, time_until_due)
};
img.onload = handle_draw_jpeg_onload;
img.src = tmpstr;
+
+ sc.streams[m.base.id].frames_loading++;
}
function process_stream_data_report(sc, id, msg_mmtime, time_until_due)
commit 368fdaf51de2478eee9223032b3f7caee58cf132
Author: Jeremy White <jwhite at codeweavers.com>
Date: Thu Dec 29 14:39:08 2016 -0600
Disable the onload function when clearing the image source.
This fixes a bug introduced by my commit 42134d3e, which would
lead to an infinite recursion of onload statements.
diff --git a/display.js b/display.js
index c97f237..68e0af5 100644
--- a/display.js
+++ b/display.js
@@ -933,6 +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.onload = undefined;
this.src = EMPTY_GIF_IMAGE;
if (this.o.descriptor &&
More information about the Spice-commits
mailing list