diff options
author | Tomáš Bohdálek <tom.bohdalek@gmail.com> | 2017-05-29 08:57:21 +0200 |
---|---|---|
committer | Pavel Grunt <pgrunt@redhat.com> | 2017-06-08 16:19:29 +0200 |
commit | ce0e5a554b7c5072c4805cf7bff5fb482d19cdf5 (patch) | |
tree | 78516b1175a1ba753eafedb04071fb0f3b87c3cb | |
parent | 28535dbf0235172b826e783bcf8f7252e64ae480 (diff) |
Display: Add support for the VP9 codec typedisplay_improvements
-rw-r--r-- | display.js | 26 | ||||
-rw-r--r-- | spiceconn.js | 2 | ||||
-rw-r--r-- | webm.js | 12 |
3 files changed, 32 insertions, 8 deletions
@@ -543,7 +543,8 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg) else this.streams[m.id] = m; - if (m.codec_type == SPICE_VIDEO_CODEC_TYPE_VP8) + if (m.codec_type == SPICE_VIDEO_CODEC_TYPE_VP8 || + m.codec_type == SPICE_VIDEO_CODEC_TYPE_VP9) { var media = new MediaSource(); var v = document.createElement("video"); @@ -606,7 +607,8 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg) if (this.streams[m.base.id].codec_type === SPICE_VIDEO_CODEC_TYPE_MJPEG) process_mjpeg_stream_data(this, m, time_until_due); - if (this.streams[m.base.id].codec_type === SPICE_VIDEO_CODEC_TYPE_VP8) + if (this.streams[m.base.id].codec_type === SPICE_VIDEO_CODEC_TYPE_VP8 || + this.streams[m.base.id].codec_type == SPICE_VIDEO_CODEC_TYPE_VP9) process_video_stream_data(this.streams[m.base.id], m); return true; @@ -640,7 +642,8 @@ SpiceDisplayConn.prototype.process_channel_message = function(msg) var m = new SpiceMsgDisplayStreamDestroy(msg.data); STREAM_DEBUG > 0 && console.log(this.type + ": MsgStreamDestroy id" + m.id); - if (this.streams[m.id].codec_type == SPICE_VIDEO_CODEC_TYPE_VP8) + if (this.streams[m.id].codec_type == SPICE_VIDEO_CODEC_TYPE_VP8 || + this.streams[m.id].codec_type == SPICE_VIDEO_CODEC_TYPE_VP9) { document.getElementById(this.parent.screen_id).removeChild(this.streams[m.id].video); this.streams[m.id].source_buffer = null; @@ -1036,14 +1039,24 @@ function handle_video_source_open(e) { var stream = this.stream; var p = this.spiceconn; + var codec_type; if (stream.source_buffer) return; - var s = this.addSourceBuffer(SPICE_VP8_CODEC); + if (this.stream.codec_type == SPICE_VIDEO_CODEC_TYPE_VP8) + { + codec_type = SPICE_VP8_CODEC; + } + else + { + codec_type = SPICE_VP9_CODEC; + } + + var s = this.addSourceBuffer(codec_type); if (! s) { - p.log_err('Codec ' + SPICE_VP8_CODEC + ' not available.'); + p.log_err('Codec ' + codec_type + ' not available.'); return; } @@ -1054,7 +1067,8 @@ function handle_video_source_open(e) listen_for_video_events(stream); var h = new webm_Header(); - var te = new webm_VideoTrackEntry(this.stream.stream_width, this.stream.stream_height); + var te = new webm_VideoTrackEntry(this.stream.stream_width, this.stream.stream_height, + this.stream.codec_type); var t = new webm_Tracks(te); var mb = new ArrayBuffer(h.buffer_size() + t.buffer_size()) diff --git a/spiceconn.js b/spiceconn.js index d76f8e2..72b7934 100644 --- a/spiceconn.js +++ b/spiceconn.js @@ -147,6 +147,8 @@ SpiceConn.prototype = (1 << SPICE_DISPLAY_CAP_CODEC_MJPEG); if ('MediaSource' in window && MediaSource.isTypeSupported(SPICE_VP8_CODEC)) caps |= (1 << SPICE_DISPLAY_CAP_CODEC_VP8); + if ('MediaSource' in window && MediaSource.isTypeSupported(SPICE_VP9_CODEC)) + caps |= (1 << SPICE_DISPLAY_CAP_CODEC_VP9); msg.channel_caps.push(caps); } @@ -88,6 +88,7 @@ var EXPECTED_PACKET_DURATION = 10; var GAP_DETECTION_THRESHOLD = 50; var SPICE_VP8_CODEC = 'video/webm; codecs="vp8"'; +var SPICE_VP9_CODEC = 'video/webm; codecs="vp9"'; /*---------------------------------------------------------------------------- ** EBML utility functions @@ -467,7 +468,7 @@ webm_AudioTrackEntry.prototype = }, } -function webm_VideoTrackEntry(width, height) +function webm_VideoTrackEntry(width, height, codec_type) { this.id = WEBM_TRACK_ENTRY; this.number = 1; @@ -482,8 +483,15 @@ function webm_VideoTrackEntry(width, height) this.codec_decode_all = 0; // fixme - check this.seek_pre_roll = 0; // 80000000; // fixme - check this.codec_delay = 80000000; // Must match codec_private.preskip - this.codec_id = "V_VP8"; this.video = new webm_Video(width, height); + if (codec_type == SPICE_VIDEO_CODEC_TYPE_VP8) + { + this.codec_id = "V_VP8"; + } + else + { + this.codec_id = "V_VP9"; + } } webm_VideoTrackEntry.prototype = |