[Spice-devel] [RFC spice-server] Give priority to video-codecs for encoding

Victor Toso victortoso at redhat.com
Fri Jan 6 14:45:22 UTC 2017


From: Victor Toso <me at victortoso.com>

Hi,

This is the splitted patch from the thread [0] 'Add preferred video
codec type message'. It basically expands the string parameter from the
public API spice_server_set_video_codecs() to have an optional priority
value -> encoder:video-codec:priority.

[0] https://lists.freedesktop.org/archives/spice-devel/2017-January/034815.html

With the current approach for prefer-video-codec message, the client's
preference would always be picked (if capabilities to encode the stream
allow it). That's not great as server admin might want to use host's
resources in a different way.

I think that giving the video-codecs a priority (or rank) can satisfy
the host's preferences and it might as well satisfy client's preferences
too :)

A-) What we have now, without an explicit priority value.

* 1) Default (or auto): If the sysadmin does not call the
  spice_server_set_video_codecs(), spice-server is entitled to do what
  it think is best. At the moment, we just set an array with a default
  order for each tuple encoder:codec;

* 2) sysadmin sets encoder:codec order: This would mean that
  spice-server can't do much besides following its user request.

B-) What this patch proposes

* 1) Priority to video-codecs for encoding. Lowest priority is 1 and
  highest priority is 9; a video-codec with priority 9 is preferable
  to one with lower value.

* 2) Priority of 0 can be used to disable a video-codec (this is
  considered bad redundancy by Francois)

* 3) By default, we have the same priority for every video codec. That
  means that the order of the arguments in
  spice_server_set_video_codecs() should not be relevant, only if
  the priority of them are set.

* 4) We sort the video-codec based on client's preference but always
  giving high priority for what the host has set. This means that the
  preferred-video-codec message never changes the video-codecs priority
  for encoding, only sort the ones with the same priority value based in
  client's preference.

** Example 1: Using default (same priority in the host)

Default is .. : spice:mjpeg, gst:mjpeg, vp8, vp9, h264
Client sends  : vp8, h264
Encoding order: vp8, h264, spice:mjpeg, gst:mjpeg, vp9

** Example 2: sysadmin prefers encoding with h264

sysadmin sets : gst:h264:5, spice:mjpeg, gst:vp8
Client sends  : vp8, h264
Encoding order: h264, vp8, spice:mjpeg

PS: Nowadays we don't have code focused on hw enconding. When we do, we
still need to improve the default/auto options to give preference to hw
encoding codecs instead of using a default order for every instance.

Let me know if I'm not clear enough or if there are something else that
I'm not considering.  Thanks for any comments on it.

Cheers,
  toso

Victor Toso (1):
  reds: add support to priority for video codecs

 server/dcc.c                       | 29 +++++++++++++++--------------
 server/reds.c                      | 17 +++++++++++++++--
 server/tests/test-codecs-parsing.c |  5 +++++
 server/video-encoder.h             |  1 +
 4 files changed, 36 insertions(+), 16 deletions(-)

-- 
2.9.3



More information about the Spice-devel mailing list