Skip to content

Commit

Permalink
[COMPOSITOR] Prepare for a better Cobalt mapping (assume it is a digi…
Browse files Browse the repository at this point in the history
…t [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..
  • Loading branch information
pwielders committed Dec 9, 2024
1 parent b9df65c commit 5f375f3
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 8 deletions.
1 change: 1 addition & 0 deletions BluetoothControl/BluetoothControl.conf.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
startmode = "@PLUGIN_BLUETOOTH_STARTMODE@"
startuporder = "999"

configuration = JSON()

Expand Down
6 changes: 5 additions & 1 deletion Cobalt/Cobalt.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@")
Expand All @@ -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@")
Expand Down
37 changes: 37 additions & 0 deletions Cobalt/CobaltImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -130,6 +138,10 @@ class CobaltImplementation:
Core::JSON::String Language;
Core::JSON::EnumType<connection> 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 {
Expand Down Expand Up @@ -203,6 +215,7 @@ class CobaltImplementation:

uint32_t Configure(PluginHost::IShell* service)
{
bool bufferSet = false;
uint32_t result = Core::ERROR_NONE;

Config config;
Expand Down Expand Up @@ -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<uint16_t>(config.AudioBufferBudget.Value()).Text());
}

if (config.VideoBufferBudget.IsSet() == true) {
bufferSet = true;
Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_VIDEO_BUFFER_BUDGET"), Core::NumberType<uint16_t>(config.VideoBufferBudget.Value()).Text());
}

if (config.MediaGarbageCollect.IsSet() == true) {
Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_GARBAGE_COLLECT"), Core::NumberType<uint16_t>(config.MediaGarbageCollect.Value()).Text());
}

if (config.ProgressiveBufferBudget.IsSet() == true) {
bufferSet = true;
Core::SystemInfo::SetEnvironment(_T("COBALT_MEDIA_PROGRESSIVE_BUFFER_BUDGET"), Core::NumberType<uint16_t>(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<uint16_t>(value));
}

if (config.Language.IsSet() == true) {
Language(config.Language.Value());
}
Expand Down
2 changes: 2 additions & 0 deletions Compositor/Compositor.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@")

Expand Down
21 changes: 17 additions & 4 deletions Compositor/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ namespace Plugin {
, _brightness(nullptr)
, _service(nullptr)
, _connectionId()
, _newOnTop(true)
, _inputSwitch(nullptr)
, _inputSwitchCallsign()

Expand Down Expand Up @@ -215,6 +216,7 @@ namespace Plugin {

_inputSwitch = _composition->QueryInterface<Exchange::IInputSwitch>();
_inputSwitchCallsign = config.InputSwitch.Value();
_newOnTop = config.NewOnTop.Value();

_brightness = _composition->QueryInterface<Exchange::IBrightness>();
}
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
13 changes: 11 additions & 2 deletions Compositor/Compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -89,15 +90,17 @@ namespace Plugin {
, Connector("connector")
, BufferConnector(_T("bufferconnector"))
, DisplayConnector("displayconnector")
, NewOnTop(true)
{
Add(_T("system"), &System);
Add(_T("workdir"), &WorkDir);
Add(_T("inputswitch"), &InputSwitch);
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;
Expand All @@ -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()
Expand All @@ -137,7 +143,9 @@ namespace Plugin {
};

public:
Compositor(Compositor&&) = delete;
Compositor(const Compositor&) = delete;
Compositor& operator=(Compositor&&) = delete;
Compositor& operator=(const Compositor&) = delete;

Compositor();
Expand Down Expand Up @@ -222,6 +230,7 @@ namespace Plugin {
Exchange::IBrightness* _brightness;
PluginHost::IShell* _service;
uint32_t _connectionId;
bool _newOnTop;
Clients _clients;
Exchange::IInputSwitch* _inputSwitch;
string _inputSwitchCallsign;
Expand Down
2 changes: 1 addition & 1 deletion WebServer/WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace Plugin {
// Version
1, 0, 0,
// Preconditions
{ subsystem::NETWORK },
{},
// Terminations
{},
// Controls
Expand Down

0 comments on commit 5f375f3

Please sign in to comment.