From 5f375f3c2a51a0cff332dfef952f2dcbfd36d568 Mon Sep 17 00:00:00 2001 From: Pierre Wielders Date: Mon, 9 Dec 2024 13:02:16 +0100 Subject: [PATCH] [COMPOSITOR] Prepare for a better Cobalt mapping (assume it is a digit [0] and [1]) [WEBSERVER] Do not rely on the Network as a precondition, sometimes we are serving of localhost [COBALT] Make the media consumption parameters configurable to finetune Cobalt workings. [BLUETOOTH] Set the Audio properties as default, learned from testing.. --- BluetoothControl/BluetoothControl.conf.in | 1 + Cobalt/Cobalt.conf.in | 6 +++- Cobalt/CobaltImplementation.cpp | 37 +++++++++++++++++++++++ Compositor/Compositor.conf.in | 2 ++ Compositor/Compositor.cpp | 21 ++++++++++--- Compositor/Compositor.h | 13 ++++++-- WebServer/WebServer.cpp | 2 +- 7 files changed, 74 insertions(+), 8 deletions(-) diff --git a/BluetoothControl/BluetoothControl.conf.in b/BluetoothControl/BluetoothControl.conf.in index acd700d78..c1d9144dd 100644 --- a/BluetoothControl/BluetoothControl.conf.in +++ b/BluetoothControl/BluetoothControl.conf.in @@ -1,4 +1,5 @@ startmode = "@PLUGIN_BLUETOOTH_STARTMODE@" +startuporder = "999" configuration = JSON() diff --git a/Cobalt/Cobalt.conf.in b/Cobalt/Cobalt.conf.in index 53f62caa1..fd12fb069 100644 --- a/Cobalt/Cobalt.conf.in +++ b/Cobalt/Cobalt.conf.in @@ -3,7 +3,7 @@ resumed = "@PLUGIN_COBALT_RESUMED@" configuration = JSON() -configuration.add("url", "https://www.youtube.com/tv") +configuration.add("url", "@PLUGIN_COBALT_URL@") configuration.add("loglevel", "info") configuration.add("inspector", "@PLUGIN_COBALT_WEBINSPECTOR_ADDRESS@") configuration.add("height", "@PLUGIN_COBALT_HEIGHT@") @@ -15,6 +15,10 @@ configuration.add("operatorname", "@PLUGIN_COBALT_OPERATOR_NAME@") configuration.add("scope", "@PLUGIN_COBALT_SCOPE@") configuration.add("secret", "@PLUGIN_COBALT_SECRET@") configuration.add("playbackrates", "@PLUGIN_COBALT_PLAYBACKRATES@") +configuration.add("audiobufferbudget", "5") +configuration.add("videobufferbudget", "300") +configuration.add("progressivebufferbudget", "12") +configuration.add("mediagarbagecollect", "170") graphics = JSON() graphics.add("height", "@PLUGIN_COBALT_HEIGHT@") diff --git a/Cobalt/CobaltImplementation.cpp b/Cobalt/CobaltImplementation.cpp index 00228c247..c626002b6 100644 --- a/Cobalt/CobaltImplementation.cpp +++ b/Cobalt/CobaltImplementation.cpp @@ -97,6 +97,10 @@ class CobaltImplementation: , Language() , Connection(CABLE) , PlaybackRates(true) + , AudioBufferBudget(5) + , VideoBufferBudget(300) + , ProgressiveBufferBudget(12) + , MediaGarbageCollect(170) { Add(_T("url"), &Url); Add(_T("loglevel"), &LogLevel); @@ -112,6 +116,10 @@ class CobaltImplementation: Add(_T("language"), &Language); Add(_T("connection"), &Connection); Add(_T("playbackrates"), &PlaybackRates); + Add(_T("audiobufferbudget"), &AudioBufferBudget); + Add(_T("videobufferbudget"), &VideoBufferBudget); + Add(_T("progressivebufferbudget"), &ProgressiveBufferBudget); + Add(_T("mediagarbagecollect"), &MediaGarbageCollect); } ~Config() override = default; @@ -130,6 +138,10 @@ class CobaltImplementation: Core::JSON::String Language; Core::JSON::EnumType Connection; Core::JSON::Boolean PlaybackRates; + Core::JSON::DecUInt16 AudioBufferBudget; + Core::JSON::DecUInt16 VideoBufferBudget; + Core::JSON::DecUInt16 ProgressiveBufferBudget; + Core::JSON::DecUInt16 MediaGarbageCollect; }; class NotificationSink: public Core::Thread { @@ -203,6 +215,7 @@ class CobaltImplementation: uint32_t Configure(PluginHost::IShell* service) { + bool bufferSet = false; uint32_t result = Core::ERROR_NONE; Config config; @@ -254,6 +267,30 @@ class CobaltImplementation: Core::SystemInfo::SetEnvironment(_T("COBALT_CERTIFICATION_SECRET"), config.CertificationSecret.Value()); } + if (config.AudioBufferBudget.IsSet() == true) { + bufferSet = true; + Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_AUDIO_BUFFER_BUDGET"), Core::NumberType(config.AudioBufferBudget.Value()).Text()); + } + + if (config.VideoBufferBudget.IsSet() == true) { + bufferSet = true; + Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_VIDEO_BUFFER_BUDGET"), Core::NumberType(config.VideoBufferBudget.Value()).Text()); + } + + if (config.MediaGarbageCollect.IsSet() == true) { + Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_GARBAGE_COLLECT"), Core::NumberType(config.MediaGarbageCollect.Value()).Text()); + } + + if (config.ProgressiveBufferBudget.IsSet() == true) { + bufferSet = true; + Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_PROGRESSIVE_BUFFER_BUDGET"), Core::NumberType(config.ProgressiveBufferBudget.Value()).Text()); + } + + if (bufferSet == true) { + uint32_t value = config.ProgressiveBufferBudget.Value() + config.VideoBufferBudget.Value() + config.AudioBufferBudget.Value(); + Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_MAX_BUFFER_BUDGET"), Core::NumberType(value)); + } + if (config.Language.IsSet() == true) { Language(config.Language.Value()); } diff --git a/Compositor/Compositor.conf.in b/Compositor/Compositor.conf.in index 61acfbc20..3cd115547 100644 --- a/Compositor/Compositor.conf.in +++ b/Compositor/Compositor.conf.in @@ -3,6 +3,8 @@ startmode = "@PLUGIN_COMPOSITOR_STARTMODE@" configuration = JSON() configuration.add("resolution", "@PLUGIN_COMPOSITOR_RESOLUTION@") +configuration.add("newontop", "false") + if "@PLUGIN_COMPOSITOR_CONNECTOR@": configuration.add("connector", "@PLUGIN_COMPOSITOR_CONNECTOR@") diff --git a/Compositor/Compositor.cpp b/Compositor/Compositor.cpp index 5122465a9..09fac001d 100644 --- a/Compositor/Compositor.cpp +++ b/Compositor/Compositor.cpp @@ -160,6 +160,7 @@ namespace Plugin { , _brightness(nullptr) , _service(nullptr) , _connectionId() + , _newOnTop(true) , _inputSwitch(nullptr) , _inputSwitchCallsign() @@ -215,6 +216,7 @@ namespace Plugin { _inputSwitch = _composition->QueryInterface(); _inputSwitchCallsign = config.InputSwitch.Value(); + _newOnTop = config.NewOnTop.Value(); _brightness = _composition->QueryInterface(); } @@ -457,7 +459,13 @@ namespace Plugin { // If this is a sub screen (determined by a colon) make sure it is pushed in the right order, if not just push it to the front.. size_t pos; if ((pos = name.find_first_of(':')) == string::npos) { - list.push_front(entry); + if (_newOnTop == true) { + list.push_front(entry); + } + else { + list.push_back(entry); + } + } else { int value = 1; @@ -477,11 +485,16 @@ namespace Plugin { if (index == list.end()) { TRACE(Trace::Information, (_T("Sub Client %s was not found yet"), name.substr(0, pos).c_str())); // No entry found yet, pushto front than - list.push_front(entry); + if (_newOnTop == true) { + list.push_front(entry); + } + else { + list.push_back(entry); + } } else { - // We got an entry, where do we ant to put ours ? - if (name[pos+1] == 'g') { + // We got an entry, where do we want to put ours ? + if ( (name[pos+1] == 'g') || (name[pos+1] == '0') ) { TRACE(Trace::Information, (_T("Sub Client [%s]:[graphics] was found it is inserted before video: %s"), name.substr(0, pos).c_str(), (*index).name.c_str())); } else { diff --git a/Compositor/Compositor.h b/Compositor/Compositor.h index 34688d935..3b619361c 100644 --- a/Compositor/Compositor.h +++ b/Compositor/Compositor.h @@ -77,10 +77,11 @@ namespace Plugin { class Config : public Core::JSON::Container { public: + Config(Config&&); Config(const Config&); + Config& operator=(Config&&); Config& operator=(const Config&); - public: Config() : Core::JSON::Container() , System(_T("Controller")) @@ -89,6 +90,7 @@ namespace Plugin { , Connector("connector") , BufferConnector(_T("bufferconnector")) , DisplayConnector("displayconnector") + , NewOnTop(true) { Add(_T("system"), &System); Add(_T("workdir"), &WorkDir); @@ -96,8 +98,9 @@ namespace Plugin { Add(_T("connector"), &Connector); Add(_T("bufferconnector"), &BufferConnector); Add(_T("displayconnector"), &DisplayConnector); + Add(_T("newontop"), &NewOnTop); } - ~Config() = default; + ~Config() override = default; public: Core::JSON::String System; @@ -106,11 +109,14 @@ namespace Plugin { Core::JSON::String Connector; Core::JSON::String BufferConnector; Core::JSON::String DisplayConnector; + Core::JSON::Boolean NewOnTop; }; class Data : public Core::JSON::Container { public: + Data(Data&&) = delete; Data(const Data&) = delete; + Data& operator=(Data&&) = delete; Data& operator=(const Data&) = delete; Data() @@ -137,7 +143,9 @@ namespace Plugin { }; public: + Compositor(Compositor&&) = delete; Compositor(const Compositor&) = delete; + Compositor& operator=(Compositor&&) = delete; Compositor& operator=(const Compositor&) = delete; Compositor(); @@ -222,6 +230,7 @@ namespace Plugin { Exchange::IBrightness* _brightness; PluginHost::IShell* _service; uint32_t _connectionId; + bool _newOnTop; Clients _clients; Exchange::IInputSwitch* _inputSwitch; string _inputSwitchCallsign; diff --git a/WebServer/WebServer.cpp b/WebServer/WebServer.cpp index 636c37ace..5e444df14 100644 --- a/WebServer/WebServer.cpp +++ b/WebServer/WebServer.cpp @@ -35,7 +35,7 @@ namespace Plugin { // Version 1, 0, 0, // Preconditions - { subsystem::NETWORK }, + {}, // Terminations {}, // Controls