mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-26 18:58:48 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into referentials
This commit is contained in:
commit
00e4e20bcb
7 changed files with 89 additions and 45 deletions
|
@ -945,6 +945,39 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if this is a request for a scripted assignment (with a temp unique UUID)
|
||||||
|
const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING);
|
||||||
|
QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING);
|
||||||
|
|
||||||
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
||||||
|
&& assignmentRegex.indexIn(url.path()) != -1) {
|
||||||
|
QUuid matchingUUID = QUuid(assignmentRegex.cap(1));
|
||||||
|
|
||||||
|
SharedAssignmentPointer matchingAssignment = _allAssignments.value(matchingUUID);
|
||||||
|
if (!matchingAssignment) {
|
||||||
|
// check if we have a pending assignment that matches this temp UUID, and it is a scripted assignment
|
||||||
|
PendingAssignedNodeData* pendingData = _pendingAssignedNodes.value(matchingUUID);
|
||||||
|
if (pendingData) {
|
||||||
|
matchingAssignment = _allAssignments.value(pendingData->getAssignmentUUID());
|
||||||
|
|
||||||
|
if (matchingAssignment && matchingAssignment->getType() == Assignment::AgentType) {
|
||||||
|
// we have a matching assignment and it is for the right type, have the HTTP manager handle it
|
||||||
|
// via correct URL for the script so the client can download
|
||||||
|
|
||||||
|
QUrl scriptURL = url;
|
||||||
|
scriptURL.setPath(URI_ASSIGNMENT + "/"
|
||||||
|
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
|
||||||
|
|
||||||
|
// have the HTTPManager serve the appropriate script file
|
||||||
|
return _httpManager.handleHTTPRequest(connection, scriptURL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// request not handled
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// all requests below require a cookie to prove authentication so check that first
|
// all requests below require a cookie to prove authentication so check that first
|
||||||
if (!isAuthenticatedRequest(connection, url)) {
|
if (!isAuthenticatedRequest(connection, url)) {
|
||||||
// this is not an authenticated request
|
// this is not an authenticated request
|
||||||
|
@ -1068,38 +1101,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this is a request for a scripted assignment (with a temp unique UUID)
|
|
||||||
const QString ASSIGNMENT_REGEX_STRING = QString("\\%1\\/(%2)\\/?$").arg(URI_ASSIGNMENT).arg(UUID_REGEX_STRING);
|
|
||||||
QRegExp assignmentRegex(ASSIGNMENT_REGEX_STRING);
|
|
||||||
|
|
||||||
if (assignmentRegex.indexIn(url.path()) != -1) {
|
|
||||||
QUuid matchingUUID = QUuid(assignmentRegex.cap(1));
|
|
||||||
|
|
||||||
SharedAssignmentPointer matchingAssignment = _allAssignments.value(matchingUUID);
|
|
||||||
if (!matchingAssignment) {
|
|
||||||
// check if we have a pending assignment that matches this temp UUID, and it is a scripted assignment
|
|
||||||
PendingAssignedNodeData* pendingData = _pendingAssignedNodes.value(matchingUUID);
|
|
||||||
if (pendingData) {
|
|
||||||
matchingAssignment = _allAssignments.value(pendingData->getAssignmentUUID());
|
|
||||||
|
|
||||||
if (matchingAssignment && matchingAssignment->getType() == Assignment::AgentType) {
|
|
||||||
// we have a matching assignment and it is for the right type, have the HTTP manager handle it
|
|
||||||
// via correct URL for the script so the client can download
|
|
||||||
|
|
||||||
QUrl scriptURL = url;
|
|
||||||
scriptURL.setPath(URI_ASSIGNMENT + "/"
|
|
||||||
+ uuidStringWithoutCurlyBraces(pendingData->getAssignmentUUID()));
|
|
||||||
|
|
||||||
// have the HTTPManager serve the appropriate script file
|
|
||||||
return _httpManager.handleHTTPRequest(connection, scriptURL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// request not handled
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (connection->requestOperation() == QNetworkAccessManager::PostOperation) {
|
} else if (connection->requestOperation() == QNetworkAccessManager::PostOperation) {
|
||||||
if (url.path() == URI_ASSIGNMENT) {
|
if (url.path() == URI_ASSIGNMENT) {
|
||||||
|
|
|
@ -49,6 +49,7 @@ static const float AUDIO_CALLBACK_MSECS = (float) NETWORK_BUFFER_LENGTH_SAMPLES_
|
||||||
static const int NUMBER_OF_NOISE_SAMPLE_FRAMES = 300;
|
static const int NUMBER_OF_NOISE_SAMPLE_FRAMES = 300;
|
||||||
|
|
||||||
static const int FRAMES_AVAILABLE_STATS_WINDOW_SECONDS = 10;
|
static const int FRAMES_AVAILABLE_STATS_WINDOW_SECONDS = 10;
|
||||||
|
static const int APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS = (int)(30.0f * 1000.0f / AUDIO_CALLBACK_MSECS);
|
||||||
|
|
||||||
// Mute icon configration
|
// Mute icon configration
|
||||||
static const int MUTE_ICON_SIZE = 24;
|
static const int MUTE_ICON_SIZE = 24;
|
||||||
|
@ -112,7 +113,10 @@ Audio::Audio(QObject* parent) :
|
||||||
_outgoingAvatarAudioSequenceNumber(0),
|
_outgoingAvatarAudioSequenceNumber(0),
|
||||||
_audioInputMsecsReadStats(MSECS_PER_SECOND / (float)AUDIO_CALLBACK_MSECS * CALLBACK_ACCELERATOR_RATIO, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
_audioInputMsecsReadStats(MSECS_PER_SECOND / (float)AUDIO_CALLBACK_MSECS * CALLBACK_ACCELERATOR_RATIO, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
||||||
_inputRingBufferMsecsAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
_inputRingBufferMsecsAvailableStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
||||||
_audioOutputMsecsUnplayedStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS)
|
_audioOutputMsecsUnplayedStats(1, FRAMES_AVAILABLE_STATS_WINDOW_SECONDS),
|
||||||
|
_lastSentAudioPacket(0),
|
||||||
|
_packetSentTimeGaps(1, APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS)
|
||||||
|
|
||||||
{
|
{
|
||||||
// clear the array of locally injected samples
|
// clear the array of locally injected samples
|
||||||
memset(_localProceduralSamples, 0, NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL);
|
memset(_localProceduralSamples, 0, NETWORK_BUFFER_LENGTH_BYTES_PER_CHANNEL);
|
||||||
|
@ -128,7 +132,6 @@ void Audio::init(QGLWidget *parent) {
|
||||||
|
|
||||||
void Audio::reset() {
|
void Audio::reset() {
|
||||||
_receivedAudioStream.reset();
|
_receivedAudioStream.reset();
|
||||||
|
|
||||||
resetStats();
|
resetStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,6 +145,7 @@ void Audio::resetStats() {
|
||||||
_inputRingBufferMsecsAvailableStats.reset();
|
_inputRingBufferMsecsAvailableStats.reset();
|
||||||
|
|
||||||
_audioOutputMsecsUnplayedStats.reset();
|
_audioOutputMsecsUnplayedStats.reset();
|
||||||
|
_packetSentTimeGaps.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::audioMixerKilled() {
|
void Audio::audioMixerKilled() {
|
||||||
|
@ -699,6 +703,17 @@ void Audio::handleAudioInput() {
|
||||||
// memcpy our orientation
|
// memcpy our orientation
|
||||||
memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation));
|
memcpy(currentPacketPtr, &headOrientation, sizeof(headOrientation));
|
||||||
currentPacketPtr += sizeof(headOrientation);
|
currentPacketPtr += sizeof(headOrientation);
|
||||||
|
|
||||||
|
// first time this is 0
|
||||||
|
if (_lastSentAudioPacket == 0) {
|
||||||
|
_lastSentAudioPacket = usecTimestampNow();
|
||||||
|
} else {
|
||||||
|
quint64 now = usecTimestampNow();
|
||||||
|
quint64 gap = now - _lastSentAudioPacket;
|
||||||
|
_packetSentTimeGaps.update(gap);
|
||||||
|
|
||||||
|
_lastSentAudioPacket = now;
|
||||||
|
}
|
||||||
|
|
||||||
nodeList->writeDatagram(audioDataPacket, numAudioBytes + leadingBytes, audioMixer);
|
nodeList->writeDatagram(audioDataPacket, numAudioBytes + leadingBytes, audioMixer);
|
||||||
_outgoingAvatarAudioSequenceNumber++;
|
_outgoingAvatarAudioSequenceNumber++;
|
||||||
|
@ -1307,10 +1322,10 @@ void Audio::renderStats(const float* color, int width, int height) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int linesWhenCentered = _statsShowInjectedStreams ? 30 : 23;
|
const int linesWhenCentered = _statsShowInjectedStreams ? 34 : 27;
|
||||||
const int CENTERED_BACKGROUND_HEIGHT = STATS_HEIGHT_PER_LINE * linesWhenCentered;
|
const int CENTERED_BACKGROUND_HEIGHT = STATS_HEIGHT_PER_LINE * linesWhenCentered;
|
||||||
|
|
||||||
int lines = _statsShowInjectedStreams ? _audioMixerInjectedStreamAudioStatsMap.size() * 7 + 23 : 23;
|
int lines = _statsShowInjectedStreams ? _audioMixerInjectedStreamAudioStatsMap.size() * 7 + 27 : 27;
|
||||||
int statsHeight = STATS_HEIGHT_PER_LINE * lines;
|
int statsHeight = STATS_HEIGHT_PER_LINE * lines;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1384,7 +1399,28 @@ void Audio::renderStats(const float* color, int width, int height) {
|
||||||
|
|
||||||
verticalOffset += STATS_HEIGHT_PER_LINE; // blank line
|
verticalOffset += STATS_HEIGHT_PER_LINE; // blank line
|
||||||
|
|
||||||
char upstreamMicLabelString[] = "Upstream mic audio stats:";
|
char clientUpstreamMicLabelString[] = "Upstream Mic Audio Packets Sent Gaps (by client):";
|
||||||
|
verticalOffset += STATS_HEIGHT_PER_LINE;
|
||||||
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, clientUpstreamMicLabelString, color);
|
||||||
|
|
||||||
|
char stringBuffer[512];
|
||||||
|
sprintf(stringBuffer, " Inter-packet timegaps (overall) | min: %9s, max: %9s, avg: %9s",
|
||||||
|
formatUsecTime(_packetSentTimeGaps.getMin()).toLatin1().data(),
|
||||||
|
formatUsecTime(_packetSentTimeGaps.getMax()).toLatin1().data(),
|
||||||
|
formatUsecTime(_packetSentTimeGaps.getAverage()).toLatin1().data());
|
||||||
|
verticalOffset += STATS_HEIGHT_PER_LINE;
|
||||||
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, stringBuffer, color);
|
||||||
|
|
||||||
|
sprintf(stringBuffer, " Inter-packet timegaps (last 30s) | min: %9s, max: %9s, avg: %9s",
|
||||||
|
formatUsecTime(_packetSentTimeGaps.getWindowMin()).toLatin1().data(),
|
||||||
|
formatUsecTime(_packetSentTimeGaps.getWindowMax()).toLatin1().data(),
|
||||||
|
formatUsecTime(_packetSentTimeGaps.getWindowAverage()).toLatin1().data());
|
||||||
|
verticalOffset += STATS_HEIGHT_PER_LINE;
|
||||||
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, stringBuffer, color);
|
||||||
|
|
||||||
|
verticalOffset += STATS_HEIGHT_PER_LINE; // blank line
|
||||||
|
|
||||||
|
char upstreamMicLabelString[] = "Upstream mic audio stats (received and reported by audio-mixer):";
|
||||||
verticalOffset += STATS_HEIGHT_PER_LINE;
|
verticalOffset += STATS_HEIGHT_PER_LINE;
|
||||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamMicLabelString, color);
|
drawText(horizontalOffset, verticalOffset, scale, rotation, font, upstreamMicLabelString, color);
|
||||||
|
|
||||||
|
|
|
@ -279,6 +279,9 @@ private:
|
||||||
MovingMinMaxAvg<float> _inputRingBufferMsecsAvailableStats;
|
MovingMinMaxAvg<float> _inputRingBufferMsecsAvailableStats;
|
||||||
|
|
||||||
MovingMinMaxAvg<float> _audioOutputMsecsUnplayedStats;
|
MovingMinMaxAvg<float> _audioOutputMsecsUnplayedStats;
|
||||||
|
|
||||||
|
quint64 _lastSentAudioPacket;
|
||||||
|
MovingMinMaxAvg<quint64> _packetSentTimeGaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,13 @@ void DomainHandler::clearSettings() {
|
||||||
_failedSettingsRequests = 0;
|
_failedSettingsRequests = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::reset() {
|
void DomainHandler::softReset() {
|
||||||
clearConnectionInfo();
|
clearConnectionInfo();
|
||||||
clearSettings();
|
clearSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DomainHandler::hardReset() {
|
||||||
|
softReset();
|
||||||
_hostname = QString();
|
_hostname = QString();
|
||||||
_sockAddr.setAddress(QHostAddress::Null);
|
_sockAddr.setAddress(QHostAddress::Null);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +63,7 @@ void DomainHandler::reset() {
|
||||||
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
|
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
|
||||||
if (_sockAddr != sockAddr) {
|
if (_sockAddr != sockAddr) {
|
||||||
// we should reset on a sockAddr change
|
// we should reset on a sockAddr change
|
||||||
reset();
|
hardReset();
|
||||||
// change the sockAddr
|
// change the sockAddr
|
||||||
_sockAddr = sockAddr;
|
_sockAddr = sockAddr;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +76,7 @@ void DomainHandler::setHostname(const QString& hostname) {
|
||||||
|
|
||||||
if (hostname != _hostname) {
|
if (hostname != _hostname) {
|
||||||
// re-set the domain info so that auth information is reloaded
|
// re-set the domain info so that auth information is reloaded
|
||||||
reset();
|
hardReset();
|
||||||
|
|
||||||
int colonIndex = hostname.indexOf(':');
|
int colonIndex = hostname.indexOf(':');
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ public:
|
||||||
|
|
||||||
void parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket);
|
void parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket);
|
||||||
|
|
||||||
|
void softReset();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void completedHostnameLookup(const QHostInfo& hostInfo);
|
void completedHostnameLookup(const QHostInfo& hostInfo);
|
||||||
void settingsRequestFinished();
|
void settingsRequestFinished();
|
||||||
|
@ -73,7 +75,7 @@ signals:
|
||||||
void settingsReceiveFail();
|
void settingsReceiveFail();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reset();
|
void hardReset();
|
||||||
|
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
QString _hostname;
|
QString _hostname;
|
||||||
|
|
|
@ -178,7 +178,7 @@ void NodeList::reset() {
|
||||||
setSessionUUID(QUuid());
|
setSessionUUID(QUuid());
|
||||||
|
|
||||||
// clear the domain connection information
|
// clear the domain connection information
|
||||||
_domainHandler.clearConnectionInfo();
|
_domainHandler.softReset();
|
||||||
|
|
||||||
// if we setup the DTLS socket, also disconnect from the DTLS socket readyRead() so it can handle handshaking
|
// if we setup the DTLS socket, also disconnect from the DTLS socket readyRead() so it can handle handshaking
|
||||||
if (_dtlsSocket) {
|
if (_dtlsSocket) {
|
||||||
|
|
|
@ -143,9 +143,7 @@ void VoxelEditPacketSender::queueVoxelEditMessages(PacketType type, int numberOf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 VoxelEditPacketSender::satoshiCostForMessage(const VoxelDetail& details) {
|
qint64 VoxelEditPacketSender::satoshiCostForMessage(const VoxelDetail& details) {
|
||||||
const DomainHandler& domainHandler = NodeList::getInstance()->getDomainHandler();
|
|
||||||
|
|
||||||
if (_satoshisPerVoxel == 0 && _satoshisPerMeterCubed == 0) {
|
if (_satoshisPerVoxel == 0 && _satoshisPerMeterCubed == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue