diff options
author | Jeremy White <jwhite@codeweavers.com> | 2015-06-03 11:45:18 -0500 |
---|---|---|
committer | Jeremy White <jwhite@codeweavers.com> | 2015-06-04 15:41:41 -0500 |
commit | 84562db7e4d978486343fbc6146f93f82606d169 (patch) | |
tree | b6c83e0f40584fdfbbfce58bcf6ff72a208ad767 /display.js | |
parent | e542bda56fa204631b44d100ffe2cc560113857d (diff) |
Implement support for sized data streams.
Diffstat (limited to 'display.js')
-rw-r--r-- | display.js | 60 |
1 files changed, 38 insertions, 22 deletions
@@ -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; +} + |