Skip to content

Commit

Permalink
Development/compositor (#862)
Browse files Browse the repository at this point in the history
* [COMPOSITOR] Make sure the Cobalt planes are put in the right order (Video under graphics)

* [COBALT] Configure the Video plane and the Graphics plane independently!

* [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..

* Update Compositor.cpp

* [COBALT] Make the usaga options in the conig conigurable from the outside
[WIFI] Make it buildabale and from an interface perspective testable on windows.

* [OOPS] A bit too much was commited :-)

---------

Co-authored-by: MFransen69 <[email protected]>
  • Loading branch information
pwielders and MFransen69 authored Dec 27, 2024
1 parent fecbdd2 commit 3c43aaf
Show file tree
Hide file tree
Showing 11 changed files with 305 additions and 22 deletions.
22 changes: 22 additions & 0 deletions Cobalt/Cobalt.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ video = JSON()
video.add("height", "@PLUGIN_COBALT_HEIGHT@")
video.add("width", "@PLUGIN_COBALT_WIDTH@")

if "@PLUGIN_COBALT_URL@":
configuration.add("url", "@PLUGIN_COBALT_URL@")
if "@PLUGIN_COBALT_AUDIO_BUFFER_BUDGET@":
configuration.add("audiobufferbudget", "@PLUGIN_COBALT_AUDIO_BUFFER_BUDGET@")

if "@PLUGIN_COBALT_VIDEO_BUFFER_BUDGET@":
configuration.add("videobufferbudget", "@PLUGIN_COBALT_VIDEO_BUFFER_BUDGET@")

if "@PLUGIN_COBALT_PROGRESSIVE_BUFFER_BUDGET@":
configuration.add("progressivebufferbudget", "@PLUGIN_COBALT_PROGRESSIVE_BUFFER_BUDGET@")

if "@PLUGIN_COBALT_MEDIA_GARBAGE_COLLECT@":
configuration.add("mediagarbagecollect", "@PLUGIN_COBALT_MEDIA_GARBAGE_COLLECT@")

graphics = JSON()
graphics.add("height", "@PLUGIN_COBALT_HEIGHT@")
graphics.add("width", "@PLUGIN_COBALT_WIDTH@")

video = JSON()
video.add("height", "@PLUGIN_COBALT_HEIGHT@")
video.add("width", "@PLUGIN_COBALT_WIDTH@")

graphics = JSON()
graphics.add("height", "@PLUGIN_COBALT_HEIGHT@")
graphics.add("width", "@PLUGIN_COBALT_WIDTH@")
Expand Down
8 changes: 8 additions & 0 deletions Cobalt/CobaltImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class CobaltImplementation:
, Language()
, Connection(CABLE)
, PlaybackRates(true)
, FrameRate(30)
, AudioBufferBudget(5)
, VideoBufferBudget(300)
, ProgressiveBufferBudget(12)
Expand All @@ -116,6 +117,7 @@ class CobaltImplementation:
Add(_T("language"), &Language);
Add(_T("connection"), &Connection);
Add(_T("playbackrates"), &PlaybackRates);
Add(_T("framerate"), &FrameRate);
Add(_T("audiobufferbudget"), &AudioBufferBudget);
Add(_T("videobufferbudget"), &VideoBufferBudget);
Add(_T("progressivebufferbudget"), &ProgressiveBufferBudget);
Expand All @@ -138,6 +140,7 @@ class CobaltImplementation:
Core::JSON::String Language;
Core::JSON::EnumType<connection> Connection;
Core::JSON::Boolean PlaybackRates;
Core::JSON::DecUInt8 FrameRate;
Core::JSON::DecUInt16 AudioBufferBudget;
Core::JSON::DecUInt16 VideoBufferBudget;
Core::JSON::DecUInt16 ProgressiveBufferBudget;
Expand Down Expand Up @@ -245,6 +248,11 @@ class CobaltImplementation:
Core::SystemInfo::SetEnvironment(_T("GST_VIRTUAL_DISP_HEIGHT"), videoHeight);
}

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

if (config.RepeatStart.IsSet() == true) {
string repeatStart(Core::NumberType<uint32_t>(config.RepeatStart.Value()).Text());
Core::SystemInfo::SetEnvironment(_T("COBALT_KEY_REPEAT_START"), repeatStart);
Expand Down
10 changes: 5 additions & 5 deletions WifiControl/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace WPASupplicant {
if ((_requests.size() > 0) && (_requests.front()->Message().empty() == false)) {
string& data = _requests.front()->Message();
TRACE(Communication, (_T("Send: [%s]"), data.c_str()));
result = (data.length() > maxSendSize ? maxSendSize : data.length());
result = (static_cast<uint16_t>(data.length()) > maxSendSize ? maxSendSize : static_cast<uint16_t>(data.length()));
memcpy(dataFrame, data.c_str(), result);
data = data.substr(result);
}
Expand All @@ -209,7 +209,7 @@ namespace WPASupplicant {
uint16_t index = 1;

// See if there are only digit between this and the closing bracket.
while ((index < response.length()) && (isdigit(response[index]) == true)) {
while ((index < response.length()) && (isdigit(response[index]) != 0)) {
number += (number * 10) + (response[index] - '0');
++index;
}
Expand All @@ -233,7 +233,7 @@ namespace WPASupplicant {

ASSERT(position != string::npos);

Core::TextFragment infoLine(message, position, message.length() - position);
Core::TextFragment infoLine(message, static_cast<uint32_t>(position), static_cast<uint32_t>(message.length() - position));

// Skip white space
uint16_t begin = infoLine.ForwardSkip(_T(" \t"), 0);
Expand Down Expand Up @@ -287,7 +287,7 @@ namespace WPASupplicant {
} else if(event == WPS_EVENT_CRED_RECEIVED) {

ASSERT(position != string::npos);
Core::TextFragment infoLine(message, position, message.length() - position);
Core::TextFragment infoLine(message, static_cast<uint32_t>(position), static_cast<uint32_t>(message.length() - position));

// Skip white space
infoLine.TrimBegin(_T(" "));
Expand All @@ -297,7 +297,7 @@ namespace WPASupplicant {

ASSERT(position != string::npos);

Core::TextFragment infoLine(message, position, message.length() - position);
Core::TextFragment infoLine(message, static_cast<uint32_t>(position), static_cast<uint32_t>(message.length() - position));

// extract the Network ID from the list
uint16_t index = infoLine.ForwardSkip(_T(" \t"), 0);
Expand Down
16 changes: 8 additions & 8 deletions WifiControl/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ namespace WPASupplicant {
void Completed(const string& response, const bool abort) override
{
if (abort == false) {
Core::TextFragment data(response.c_str(), response.length());
Core::TextFragment data(response.c_str(), static_cast<uint32_t>(response.length()));
uint32_t marker = data.ForwardFind('\n');
uint32_t markerEnd = data.ForwardFind('\n', marker + 1);

Expand Down Expand Up @@ -557,7 +557,7 @@ namespace WPASupplicant {
void Completed(const string& response, const bool abort) override
{
if (abort == false) {
Core::TextFragment data(response.c_str(), response.length());
Core::TextFragment data(response.c_str(), static_cast<uint32_t>(response.length()));

uint32_t marker = 0;
uint32_t markerEnd = data.ForwardFind('\n', marker);
Expand Down Expand Up @@ -710,7 +710,7 @@ namespace WPASupplicant {
void Completed(const string& response, const bool abort) override
{
if (abort == false) {
Core::TextFragment data(response.c_str(), response.length());
Core::TextFragment data(response.c_str(), static_cast<uint32_t>(response.length()));
uint32_t marker = data.ForwardFind('\n');
uint32_t markerEnd = data.ForwardFind('\n', marker + 1);

Expand Down Expand Up @@ -1313,7 +1313,7 @@ namespace WPASupplicant {
if (Core::File(remoteName).Exists() == true) {

string data(
Core::Directory::Normalize(supplicantBase) + _T("wpa_ctrl_") + interfaceName + '_' + Core::NumberType<uint32_t>(::getpid()).Text());
Core::Directory::Normalize(supplicantBase) + _T("wpa_ctrl_") + interfaceName + '_' + Core::NumberType<uint32_t>(Core::ProcessInfo().Id()).Text());

LocalNode(Core::NodeId(data.c_str()));

Expand Down Expand Up @@ -1690,7 +1690,7 @@ namespace WPASupplicant {
if ((exchange.Wait(MaxConnectionTime) == true) && (exchange.Response() != _T("FAIL"))) {

const string& idtext = exchange.Response();
id = Core::NumberType<uint32_t>(idtext.c_str(), idtext.length());
id = Core::NumberType<uint32_t>(idtext.c_str(), static_cast<uint32_t>(idtext.length()));
}

Revoke(&exchange);
Expand Down Expand Up @@ -1807,7 +1807,7 @@ namespace WPASupplicant {
_adminLock.Unlock();

if (GetKey(id, Config::MODE, value) == Core::ERROR_NONE) {
uint32_t mode(Core::NumberType<uint32_t>(Core::TextFragment(value.c_str(), value.length())));
uint32_t mode(Core::NumberType<uint32_t>(Core::TextFragment(value.c_str(), static_cast<uint32_t>(value.length()))));

// Its an access point, we are done. BSSID == 0
AP = (mode == 2);
Expand Down Expand Up @@ -2230,8 +2230,8 @@ namespace WPASupplicant {
void Update(const uint64_t& bssid, const uint32_t id, const uint32_t throughput);
void Update(const string& ssid, const uint32_t id, const bool succeeded);
void Reevaluate();
virtual uint16_t SendData(uint8_t* dataFrame, const uint16_t maxSendSize) override;
virtual uint16_t ReceiveData(uint8_t* dataFrame, const uint16_t receivedSize) override;
uint16_t SendData(uint8_t* dataFrame, const uint16_t maxSendSize) override;
uint16_t ReceiveData(uint8_t* dataFrame, const uint16_t receivedSize) override;

void Revoke(const Request* id) const
{
Expand Down
1 change: 1 addition & 0 deletions WifiControl/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <core/core.h>
#include <plugins/plugins.h>
#include <messaging/messaging.h>
#include <definitions/definitions.h>

#undef EXTERNAL
#define EXTERNAL
8 changes: 4 additions & 4 deletions WifiControl/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,31 @@ namespace WPASupplicant {
bool Config::Unsecure()
{
string hexSSID;
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), _ssid.length(), hexSSID);
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), static_cast<uint32_t>(_ssid.length()), hexSSID);

return ((SetKey(KEY, _T("NONE"))) && (SetKey(SSIDKEY, hexSSID)));
}

bool Config::Hash(const string& hash)
{
string hexSSID;
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), _ssid.length(), hexSSID);
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), static_cast<uint32_t>(_ssid.length()), hexSSID);

return ((SetKey(KEY, _T("WPA-PSK"))) && (SetKey(PAIR, _T("CCMP TKIP"))) && (SetKey(AUTH, _T("OPEN"))) && (SetKey(SSIDKEY, hexSSID)) && (SetKey(PSK, hash)));
}

bool Config::PresharedKey(const string& presharedKey)
{
string hexSSID;
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), _ssid.length(), hexSSID);
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), static_cast<uint32_t>(_ssid.length()), hexSSID);

return ((SetKey(KEY, _T("WPA-PSK"))) && (SetKey(PAIR, _T("CCMP TKIP"))) && (SetKey(AUTH, _T("OPEN"))) && (SetKey(SSIDKEY, hexSSID)) && (SetKey(PSK, ('\"' + presharedKey + '\"'))));
}

bool Config::Enterprise(const string& identity, const string& password)
{
string hexSSID;
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), _ssid.length(), hexSSID);
Core::ToHexString(reinterpret_cast<const uint8_t*>(_ssid.c_str()), static_cast<uint32_t>(_ssid.length()), hexSSID);

return ((SetKey(KEY, _T("IEEE8021X"))) && (SetKey(SSIDKEY, hexSSID)) && (SetKey(IDENTITY, identity)) && (SetKey(PASSWORD, password)) && (SetKey(_T("eap"), _T("PEAP"))) && (SetKey(_T("phase2"), _T("auth=MSCHAPV2"))));
}
Expand Down
2 changes: 1 addition & 1 deletion WifiControl/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ namespace WPASupplicant {
inline uint8_t Mode() const
{
string result;
return (GetKey(MODE, result) ? Core::NumberType<uint8_t>(result.c_str(), result.length()).Value() : 0);
return (GetKey(MODE, result) ? Core::NumberType<uint8_t>(result.c_str(), static_cast<uint32_t>(result.length())).Value() : 0);
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion WifiControl/WifiControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace Plugin
ASSERT(_skipURL <= request.Path.length());

Core::ProxyType<Web::Response> result;
Core::TextSegmentIterator index(Core::TextFragment(request.Path, _skipURL, request.Path.length() - _skipURL), false, '/');
Core::TextSegmentIterator index(Core::TextFragment(request.Path, _skipURL, static_cast<uint32_t>(request.Path.length()) - _skipURL), false, '/');
// By default, we are in front of any element, jump onto the first element, which is if, there is something an empty slot.
index.Next();
if (request.Verb == Web::Request::HTTP_GET) {
Expand Down
Loading

0 comments on commit 3c43aaf

Please sign in to comment.