mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:02:55 +02:00
switch audio-mixer to pull settings from domain-server via JSON request
This commit is contained in:
parent
3f70402e63
commit
3ae46bc60d
2 changed files with 38 additions and 32 deletions
|
@ -488,7 +488,7 @@ void AudioMixer::run() {
|
||||||
settingsJSONURL.setScheme("http");
|
settingsJSONURL.setScheme("http");
|
||||||
settingsJSONURL.setHost(nodeList->getDomainHandler().getHostname());
|
settingsJSONURL.setHost(nodeList->getDomainHandler().getHostname());
|
||||||
settingsJSONURL.setPort(DOMAIN_SERVER_HTTP_PORT);
|
settingsJSONURL.setPort(DOMAIN_SERVER_HTTP_PORT);
|
||||||
settingsJSONURL.setPath("/settings.json/");
|
settingsJSONURL.setPath("/settings.json");
|
||||||
settingsJSONURL.setQuery(QString("type=%1").arg(_type));
|
settingsJSONURL.setQuery(QString("type=%1").arg(_type));
|
||||||
|
|
||||||
QNetworkReply *reply = NULL;
|
QNetworkReply *reply = NULL;
|
||||||
|
@ -505,6 +505,7 @@ void AudioMixer::run() {
|
||||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||||
|
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
++failedAttempts;
|
++failedAttempts;
|
||||||
|
|
||||||
if (failedAttempts == MAX_SETTINGS_REQUEST_FAILED_ATTEMPTS) {
|
if (failedAttempts == MAX_SETTINGS_REQUEST_FAILED_ATTEMPTS) {
|
||||||
|
@ -514,14 +515,18 @@ void AudioMixer::run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonDocument settingsJSON = QJsonDocument::fromJson(reply->readAll());
|
QJsonObject settingsObject = QJsonDocument::fromJson(reply->readAll()).object();
|
||||||
|
|
||||||
// check the payload to see if we have any unattenuated zones
|
// check the settings object to see if we have anything we can parse out
|
||||||
const QString UNATTENUATED_ZONE_REGEX_STRING = "--unattenuated-zone ([\\d.,-]+)";
|
const QString AUDIO_GROUP_KEY = "audio";
|
||||||
QRegExp unattenuatedZoneMatch(UNATTENUATED_ZONE_REGEX_STRING);
|
|
||||||
|
|
||||||
if (unattenuatedZoneMatch.indexIn(_payload) != -1) {
|
if (settingsObject.contains(AUDIO_GROUP_KEY)) {
|
||||||
QString unattenuatedZoneString = unattenuatedZoneMatch.cap(1);
|
QJsonObject audioGroupObject = settingsObject[AUDIO_GROUP_KEY].toObject();
|
||||||
|
|
||||||
|
const QString UNATTENUATED_ZONE_KEY = "unattenuated-zone";
|
||||||
|
|
||||||
|
QString unattenuatedZoneString = audioGroupObject[UNATTENUATED_ZONE_KEY].toString();
|
||||||
|
if (!unattenuatedZoneString.isEmpty()) {
|
||||||
QStringList zoneStringList = unattenuatedZoneString.split(',');
|
QStringList zoneStringList = unattenuatedZoneString.split(',');
|
||||||
|
|
||||||
glm::vec3 sourceCorner(zoneStringList[0].toFloat(), zoneStringList[1].toFloat(), zoneStringList[2].toFloat());
|
glm::vec3 sourceCorner(zoneStringList[0].toFloat(), zoneStringList[1].toFloat(), zoneStringList[2].toFloat());
|
||||||
|
@ -543,14 +548,15 @@ void AudioMixer::run() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the payload to see if we have asked for dynamicJitterBuffer support
|
// check the payload to see if we have asked for dynamicJitterBuffer support
|
||||||
const QString DYNAMIC_JITTER_BUFFER_REGEX_STRING = "--dynamicJitterBuffer";
|
const QString DYNAMIC_JITTER_BUFFER_JSON_KEY = "dynamic-jitter-buffer";
|
||||||
QRegExp dynamicJitterBufferMatch(DYNAMIC_JITTER_BUFFER_REGEX_STRING);
|
bool shouldUseDynamicJitterBuffers = audioGroupObject[DYNAMIC_JITTER_BUFFER_JSON_KEY].toBool();
|
||||||
if (dynamicJitterBufferMatch.indexIn(_payload) != -1) {
|
if (shouldUseDynamicJitterBuffers) {
|
||||||
qDebug() << "Enable dynamic jitter buffers.";
|
qDebug() << "Enable dynamic jitter buffers.";
|
||||||
_useDynamicJitterBuffers = true;
|
_useDynamicJitterBuffers = true;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Dynamic jitter buffers disabled, using old behavior.";
|
qDebug() << "Dynamic jitter buffers disabled, using old behavior.";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int nextFrame = 0;
|
int nextFrame = 0;
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
|
|
|
@ -61,7 +61,7 @@ bool DomainServerSettingsManager::handleHTTPRequest(HTTPConnection* connection,
|
||||||
connection->respond(HTTPConnection::StatusCode200, jsonSuccess.toUtf8(), "application/json");
|
connection->respond(HTTPConnection::StatusCode200, jsonSuccess.toUtf8(), "application/json");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else if (connection->requestOperation() == QNetworkAccessManager::GetOperation && url.path() == "/settingz.json") {
|
} else if (connection->requestOperation() == QNetworkAccessManager::GetOperation && url.path() == "/settings.json") {
|
||||||
// this is a GET operation for our settings
|
// this is a GET operation for our settings
|
||||||
|
|
||||||
// check if there is a query parameter for settings affecting a particular type of assignment
|
// check if there is a query parameter for settings affecting a particular type of assignment
|
||||||
|
|
Loading…
Reference in a new issue