[Spice-devel] [PATCH spice-html5 v2 3/4] Display: Implement change preferred video codec type message
Jeremy White
jwhite at codeweavers.com
Mon Sep 18 15:53:37 UTC 2017
Ack.
Cheers,
Jeremy
On 09/18/2017 06:13 AM, Tomáš Bohdálek wrote:
> Sorry for send-email mistakes.
> ---
> display.js | 16 ++++++++++++++++
> enums.js | 11 +++++++++--
> spicemsg.js | 24 ++++++++++++++++++++++++
> 3 files changed, 49 insertions(+), 2 deletions(-)
>
> diff --git a/display.js b/display.js
> index 4649ef2..5786792 100644
> --- a/display.js
> +++ b/display.js
> @@ -881,6 +881,22 @@ SpiceDisplayConn.prototype.change_preferred_compression = function(compression_i
> 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);
> +}
> +
> function handle_mouseover(e)
> {
> this.focus();
> diff --git a/enums.js b/enums.js
> index b37cb20..d3d5bf2 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;
> @@ -347,8 +352,10 @@ var SPICE_CURSOR_TYPE_ALPHA = 0,
> SPICE_CURSOR_TYPE_COLOR24 = 5,
> SPICE_CURSOR_TYPE_COLOR32 = 6;
>
> -var SPICE_VIDEO_CODEC_TYPE_MJPEG = 1;
> -var SPICE_VIDEO_CODEC_TYPE_VP8 = 2;
> +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 VD_AGENT_PROTOCOL = 1;
> var VD_AGENT_MAX_DATA_SIZE = 2048;
> 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;
> + }
> +}
>
More information about the Spice-devel
mailing list