From 1ce533259ba9d221a51476a6d8f717f5fb544d85 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Mon, 21 Sep 2020 20:51:01 +0200 Subject: [PATCH] Auto initialize Gst and change one player function name --- clapper_src/player.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/clapper_src/player.js b/clapper_src/player.js index f8f2691e..6592b052 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -16,7 +16,10 @@ class ClapperPlayer extends GstPlayer.Player _init(opts) { opts = opts || {}; - Object.assign(opts, GSTPLAYER_DEFAULTS); + opts = Object.assign({}, GSTPLAYER_DEFAULTS, opts); + + if(!Gst.is_initialized()) + Gst.init(null); let gtkglsink = Gst.ElementFactory.make('gtkglsink', null); let glsinkbin = Gst.ElementFactory.make('glsinkbin', null); @@ -183,18 +186,18 @@ class ClapperPlayer extends GstPlayer.Player pipeline.subtitle_font_desc = desc; } - set_codec_rank(codec, rank) + set_plugin_rank(name, rank) { - debug(`changing rank of codec: ${codec}`); + debug(`changing rank of plugin: ${name}`); - let feature = this.gstRegistry.lookup_feature(codec); + let feature = this.gstRegistry.lookup_feature(name); if(!feature) - return debug(`codec unavailable: ${codec}`); + return debug(`plugin unavailable: ${name}`); let oldRank = feature.get_rank(); feature.set_rank(rank); - debug(`changed rank: ${oldRank} -> ${rank} for ${codec}`); + debug(`changed rank: ${oldRank} -> ${rank} for ${name}`); } connect(signal, fn) @@ -248,5 +251,8 @@ class ClapperPlayer extends GstPlayer.Player if(this.state !== GstPlayer.PlayerState.STOPPED) this.stop(); + + if(this.run_loop && this.loop.is_running()) + this.loop.quit(); } });