[Spice-devel] [PATCH spice-html5 3/4] Display: Implement change preferred video codec type message
Pavel Grunt
pgrunt at redhat.com
Thu Jun 8 14:27:40 UTC 2017
From: Tomáš Bohdálek <tom.bohdalek at gmail.com>
---
display.js | 16 ++++++++++++++++
enums.js | 10 ++++++++++
spicemsg.js | 24 ++++++++++++++++++++++++
3 files changed, 50 insertions(+)
diff --git a/display.js b/display.js
index 60c79b4..0868f91 100644
--- a/display.js
+++ b/display.js
@@ -1261,3 +1261,19 @@ SpiceDisplayConn.prototype.change_preferred_compression = function(compression_i
msg.build_msg(SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION, compression);
this.send_msg(msg);
}
+
+SpiceDisplayConn.prototype.change_preferred_video_codec_type = function(video_codecs)
+{
+ var ch = this.channel_type();
+ if (!this.channel_test_capability(SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE))
+ {
+ this.log_warn(ch + " does not have capability to change the preferred video codec type");
+ return;
+ }
+
+ var msg = new SpiceMiniData();
+ var video_codec_type = new SpiceMsgcDisplayPreferredVideoCodecType(video_codecs);
+
+ msg.build_msg(SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE, video_codec_type);
+ this.send_msg(msg);
+}
diff --git a/enums.js b/enums.js
index b37cb20..b69bf3e 100644
--- a/enums.js
+++ b/enums.js
@@ -135,6 +135,8 @@ var SPICE_MSG_DISPLAY_STREAM_ACTIVATE_REPORT = 319;
var SPICE_MSGC_DISPLAY_INIT = 101;
var SPICE_MSGC_DISPLAY_STREAM_REPORT = 102;
var SPICE_MSGC_DISPLAY_PREFERRED_COMPRESSION = 103;
+var SPICE_MSGC_DISPLAY_GL_DRAW_DONE = 104;
+var SPICE_MSGC_DISPLAY_PREFERRED_VIDEO_CODEC_TYPE = 105;
var SPICE_MSG_INPUTS_INIT = 101;
var SPICE_MSG_INPUTS_KEY_MODIFIERS = 102;
@@ -197,6 +199,9 @@ var SPICE_DISPLAY_CAP_GL_SCANOUT = 7;
var SPICE_DISPLAY_CAP_MULTI_CODEC = 8;
var SPICE_DISPLAY_CAP_CODEC_MJPEG = 9;
var SPICE_DISPLAY_CAP_CODEC_VP8 = 10;
+var SPICE_DISPLAY_CAP_CODEC_H264 = 11;
+var SPICE_DISPLAY_CAP_PREF_VIDEO_CODEC_TYPE = 12;
+var SPICE_DISPLAY_CAP_CODEC_VP9 = 13;
var SPICE_AUDIO_DATA_MODE_INVALID = 0;
var SPICE_AUDIO_DATA_MODE_RAW = 1;
@@ -231,6 +236,11 @@ var SPICE_MOUSE_MODE_SERVER = (1 << 0),
var SPICE_CLIP_TYPE_NONE = 0;
var SPICE_CLIP_TYPE_RECTS = 1;
+var SPICE_VIDEO_CODEC_TYPE_MJPEG = 1,
+ SPICE_VIDEO_CODEC_TYPE_VP8 = 2,
+ SPICE_VIDEO_CODEC_TYPE_H264 = 3,
+ SPICE_VIDEO_CODEC_TYPE_VP9 = 4;
+
var SPICE_IMAGE_TYPE_BITMAP = 0;
var SPICE_IMAGE_TYPE_QUIC = 1;
var SPICE_IMAGE_TYPE_RESERVED = 2;
diff --git a/spicemsg.js b/spicemsg.js
index 8a9eeed..dd684b7 100644
--- a/spicemsg.js
+++ b/spicemsg.js
@@ -1316,3 +1316,27 @@ SpiceMsgcDisplayPreferredCompression.prototype =
return 1;
}
}
+
+function SpiceMsgcDisplayPreferredVideoCodecType(codecs)
+{
+ this.codecs = codecs;
+ this.num_of_codecs = codecs.length;
+}
+
+SpiceMsgcDisplayPreferredVideoCodecType.prototype =
+{
+ to_buffer: function(a, at)
+ {
+ at = at || 0;
+ var dv = new SpiceDataView(a);
+ dv.setUint8(at, this.num_of_codecs, true); at += 1;
+ for (var i = 0; i < this.codecs.length; i++)
+ dv.setUint8(at + i, this.codecs[i], true);
+ at += this.num_of_codecs;
+ return at;
+ },
+ buffer_size: function()
+ {
+ return this.num_of_codecs + 1;
+ }
+}
--
2.13.0
More information about the Spice-devel
mailing list