From 71659491c092a46f715362a8ecf49e392ddbb110 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sun, 13 Sep 2020 20:21:46 +0200 Subject: [PATCH] Support changing rank of codecs The used GStreamer codecs are picked using rank hierarchy. When there are 2 or more decoders available that can handle the same stream type, the one with higher rank is always picked. This commit adds a function for the codec rank manipulation that can be used for e.g. force disable/enable VAAPI. Should be a neat feature once we have a settings dialog where it can be used. --- clapper_src/player.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/clapper_src/player.js b/clapper_src/player.js index 32ece64a..82d28640 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -38,6 +38,8 @@ class ClapperPlayer extends GstPlayer.Player this.dispatcher = dispatcher; this.renderer = renderer; + this.gstRegistry = Gst.Registry.get(); + this._playerSignals = []; this._widgetSignals = []; @@ -172,6 +174,20 @@ class ClapperPlayer extends GstPlayer.Player pipeline.subtitle_font_desc = desc; } + set_codec_rank(codec, rank) + { + debug(`changing rank of codec: ${codec}`); + + let feature = this.gstRegistry.lookup_feature(codec); + if(!feature) + return debug(`codec unavailable: ${codec}`); + + let oldRank = feature.get_rank(); + feature.set_rank(rank); + + debug(`changed rank: ${oldRank} -> ${rank} for ${codec}`); + } + connect(signal, fn) { this._playerSignals.push(super.connect(signal, fn));