mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 02:19:58 +02:00
Merge pull request #8665 from zzmp/feat/audio-stats
move audio stats to QML/JS, with graphs
This commit is contained in:
commit
b63eb6ba9f
24 changed files with 625 additions and 535 deletions
|
@ -49,7 +49,7 @@ AudioMixerClientData::~AudioMixerClientData() {
|
||||||
|
|
||||||
AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
|
AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() {
|
||||||
QReadLocker readLocker { &_streamsLock };
|
QReadLocker readLocker { &_streamsLock };
|
||||||
|
|
||||||
auto it = _audioStreams.find(QUuid());
|
auto it = _audioStreams.find(QUuid());
|
||||||
if (it != _audioStreams.end()) {
|
if (it != _audioStreams.end()) {
|
||||||
return dynamic_cast<AvatarAudioStream*>(it->second.get());
|
return dynamic_cast<AvatarAudioStream*>(it->second.get());
|
||||||
|
@ -75,7 +75,7 @@ void AudioMixerClientData::removeHRTFForStream(const QUuid& nodeID, const QUuid&
|
||||||
|
|
||||||
int AudioMixerClientData::parseData(ReceivedMessage& message) {
|
int AudioMixerClientData::parseData(ReceivedMessage& message) {
|
||||||
PacketType packetType = message.getType();
|
PacketType packetType = message.getType();
|
||||||
|
|
||||||
if (packetType == PacketType::AudioStreamStats) {
|
if (packetType == PacketType::AudioStreamStats) {
|
||||||
|
|
||||||
// skip over header, appendFlag, and num stats packed
|
// skip over header, appendFlag, and num stats packed
|
||||||
|
@ -218,11 +218,10 @@ void AudioMixerClientData::sendAudioStreamStatsPackets(const SharedNodePointer&
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
// The append flag is a boolean value that will be packed right after the header. The first packet sent
|
// The append flag is a boolean value that will be packed right after the header.
|
||||||
// inside this method will have 0 for this flag, while every subsequent packet will have 1 for this flag.
|
// This flag allows the client to know when it has received all stats packets, so it can group any downstream effects,
|
||||||
// The sole purpose of this flag is so the client can clear its map of injected audio stream stats when
|
// and clear its cache of injector stream stats; it helps to prevent buildup of dead audio stream stats in the client.
|
||||||
// it receives a packet with an appendFlag of 0. This prevents the buildup of dead audio stream stats in the client.
|
quint8 appendFlag = AudioStreamStats::START;
|
||||||
quint8 appendFlag = 0;
|
|
||||||
|
|
||||||
auto streamsCopy = getAudioStreams();
|
auto streamsCopy = getAudioStreams();
|
||||||
|
|
||||||
|
@ -233,14 +232,21 @@ void AudioMixerClientData::sendAudioStreamStatsPackets(const SharedNodePointer&
|
||||||
while (numStreamStatsRemaining > 0) {
|
while (numStreamStatsRemaining > 0) {
|
||||||
auto statsPacket = NLPacket::create(PacketType::AudioStreamStats);
|
auto statsPacket = NLPacket::create(PacketType::AudioStreamStats);
|
||||||
|
|
||||||
// pack the append flag in this packet
|
|
||||||
statsPacket->writePrimitive(appendFlag);
|
|
||||||
appendFlag = 1;
|
|
||||||
|
|
||||||
int numStreamStatsRoomFor = (int)(statsPacket->size() - sizeof(quint8) - sizeof(quint16)) / sizeof(AudioStreamStats);
|
int numStreamStatsRoomFor = (int)(statsPacket->size() - sizeof(quint8) - sizeof(quint16)) / sizeof(AudioStreamStats);
|
||||||
|
|
||||||
// calculate and pack the number of stream stats to follow
|
// calculate the number of stream stats to follow
|
||||||
quint16 numStreamStatsToPack = std::min(numStreamStatsRemaining, numStreamStatsRoomFor);
|
quint16 numStreamStatsToPack = std::min(numStreamStatsRemaining, numStreamStatsRoomFor);
|
||||||
|
|
||||||
|
// is this the terminal packet?
|
||||||
|
if (numStreamStatsRemaining <= numStreamStatsToPack) {
|
||||||
|
appendFlag |= AudioStreamStats::END;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pack the append flag in this packet
|
||||||
|
statsPacket->writePrimitive(appendFlag);
|
||||||
|
appendFlag = 0;
|
||||||
|
|
||||||
|
// pack the number of stream stats to follow
|
||||||
statsPacket->writePrimitive(numStreamStatsToPack);
|
statsPacket->writePrimitive(numStreamStatsToPack);
|
||||||
|
|
||||||
// pack the calculated number of stream stats
|
// pack the calculated number of stream stats
|
||||||
|
|
|
@ -1729,6 +1729,7 @@ void Application::initializeUi() {
|
||||||
// though I can't find it. Hence, "ApplicationInterface"
|
// though I can't find it. Hence, "ApplicationInterface"
|
||||||
rootContext->setContextProperty("ApplicationInterface", this);
|
rootContext->setContextProperty("ApplicationInterface", this);
|
||||||
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
rootContext->setContextProperty("Audio", &AudioScriptingInterface::getInstance());
|
||||||
|
rootContext->setContextProperty("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
|
||||||
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
rootContext->setContextProperty("Controller", DependencyManager::get<controller::ScriptingInterface>().data());
|
||||||
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
rootContext->setContextProperty("Entities", DependencyManager::get<EntityScriptingInterface>().data());
|
||||||
FileScriptingInterface* fileDownload = new FileScriptingInterface(engine);
|
FileScriptingInterface* fileDownload = new FileScriptingInterface(engine);
|
||||||
|
@ -3759,12 +3760,6 @@ void Application::updateDialogs(float deltaTime) const {
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
|
PerformanceWarning warn(showWarnings, "Application::updateDialogs()");
|
||||||
auto dialogsManager = DependencyManager::get<DialogsManager>();
|
auto dialogsManager = DependencyManager::get<DialogsManager>();
|
||||||
|
|
||||||
// Update audio stats dialog, if any
|
|
||||||
AudioStatsDialog* audioStatsDialog = dialogsManager->getAudioStatsDialog();
|
|
||||||
if(audioStatsDialog) {
|
|
||||||
audioStatsDialog->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update bandwidth dialog, if any
|
// Update bandwidth dialog, if any
|
||||||
BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
|
BandwidthDialog* bandwidthDialog = dialogsManager->getBandwidthDialog();
|
||||||
if (bandwidthDialog) {
|
if (bandwidthDialog) {
|
||||||
|
@ -5013,6 +5008,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
||||||
scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
|
scriptEngine->registerGlobalObject("Stats", Stats::getInstance());
|
||||||
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("Settings", SettingsScriptingInterface::getInstance());
|
||||||
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
scriptEngine->registerGlobalObject("AudioDevice", AudioDeviceScriptingInterface::getInstance());
|
||||||
|
scriptEngine->registerGlobalObject("AudioStats", DependencyManager::get<AudioClient>()->getStats().data());
|
||||||
|
|
||||||
// Caches
|
// Caches
|
||||||
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data());
|
||||||
|
|
|
@ -59,7 +59,6 @@
|
||||||
#include "scripting/ControllerScriptingInterface.h"
|
#include "scripting/ControllerScriptingInterface.h"
|
||||||
#include "scripting/DialogsManagerScriptingInterface.h"
|
#include "scripting/DialogsManagerScriptingInterface.h"
|
||||||
#include "ui/ApplicationOverlay.h"
|
#include "ui/ApplicationOverlay.h"
|
||||||
#include "ui/AudioStatsDialog.h"
|
|
||||||
#include "ui/BandwidthDialog.h"
|
#include "ui/BandwidthDialog.h"
|
||||||
#include "ui/LodToolsDialog.h"
|
#include "ui/LodToolsDialog.h"
|
||||||
#include "ui/LogDialog.h"
|
#include "ui/LogDialog.h"
|
||||||
|
|
|
@ -654,10 +654,6 @@ Menu::Menu() {
|
||||||
audioScopeFramesGroup->addAction(fiftyFrames);
|
audioScopeFramesGroup->addAction(fiftyFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Developer > Audio > Audio Network Stats...
|
|
||||||
addActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNetworkStats, 0,
|
|
||||||
dialogsManager.data(), SLOT(audioStatsDetails()));
|
|
||||||
|
|
||||||
// Developer > Physics >>>
|
// Developer > Physics >>>
|
||||||
MenuWrapper* physicsOptionsMenu = developerMenu->addMenu("Physics");
|
MenuWrapper* physicsOptionsMenu = developerMenu->addMenu("Physics");
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,6 @@ namespace MenuOption {
|
||||||
const QString AssetMigration = "ATP Asset Migration";
|
const QString AssetMigration = "ATP Asset Migration";
|
||||||
const QString AssetServer = "Asset Browser";
|
const QString AssetServer = "Asset Browser";
|
||||||
const QString Attachments = "Attachments...";
|
const QString Attachments = "Attachments...";
|
||||||
const QString AudioNetworkStats = "Audio Network Stats";
|
|
||||||
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
const QString AudioNoiseReduction = "Audio Noise Reduction";
|
||||||
const QString AudioScope = "Show Scope";
|
const QString AudioScope = "Show Scope";
|
||||||
const QString AudioScopeFiftyFrames = "Fifty";
|
const QString AudioScopeFiftyFrames = "Fifty";
|
||||||
|
|
|
@ -1,296 +0,0 @@
|
||||||
//
|
|
||||||
// AudioStatsDialog.cpp
|
|
||||||
// interface/src/ui
|
|
||||||
//
|
|
||||||
// Created by Bridget Went on 7/9/15.
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "AudioStatsDialog.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
#include <AudioClient.h>
|
|
||||||
#include <AudioConstants.h>
|
|
||||||
#include <AudioIOStats.h>
|
|
||||||
#include <DependencyManager.h>
|
|
||||||
#include <GeometryCache.h>
|
|
||||||
#include <NodeList.h>
|
|
||||||
#include <Util.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const unsigned COLOR0 = 0x33cc99ff;
|
|
||||||
const unsigned COLOR1 = 0xffef40c0;
|
|
||||||
const unsigned COLOR2 = 0xd0d0d0a0;
|
|
||||||
const unsigned COLOR3 = 0x01DD7880;
|
|
||||||
|
|
||||||
|
|
||||||
AudioStatsDisplay::AudioStatsDisplay(QFormLayout* form,
|
|
||||||
QString text, unsigned colorRGBA) :
|
|
||||||
_text(text),
|
|
||||||
_colorRGBA(colorRGBA)
|
|
||||||
{
|
|
||||||
_label = new QLabel();
|
|
||||||
_label->setAlignment(Qt::AlignCenter);
|
|
||||||
|
|
||||||
QPalette palette = _label->palette();
|
|
||||||
unsigned rgb = colorRGBA >> 8;
|
|
||||||
rgb = ((rgb & 0xfefefeu) >> 1) + ((rgb & 0xf8f8f8) >> 3);
|
|
||||||
palette.setColor(QPalette::WindowText, QColor::fromRgb(rgb));
|
|
||||||
_label->setPalette(palette);
|
|
||||||
|
|
||||||
form->addRow(_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDisplay::paint() {
|
|
||||||
_label->setText(_strBuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDisplay::updatedDisplay(QString str) {
|
|
||||||
_strBuf = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AudioStatsDialog::AudioStatsDialog(QWidget* parent) :
|
|
||||||
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint) {
|
|
||||||
|
|
||||||
setWindowTitle("Audio Network Statistics");
|
|
||||||
|
|
||||||
// Get statistics from the Audio Client
|
|
||||||
_stats = &DependencyManager::get<AudioClient>()->getStats();
|
|
||||||
|
|
||||||
// Create layout
|
|
||||||
_form = new QFormLayout();
|
|
||||||
_form->setSizeConstraint(QLayout::SetFixedSize);
|
|
||||||
|
|
||||||
// Initialize channels' content (needed to correctly size channels)
|
|
||||||
updateStats();
|
|
||||||
|
|
||||||
// Create channels
|
|
||||||
_audioDisplayChannels = QVector<QVector<AudioStatsDisplay*>>(1);
|
|
||||||
|
|
||||||
_audioMixerID = addChannel(_form, _audioMixerStats, COLOR0);
|
|
||||||
_upstreamClientID = addChannel(_form, _upstreamClientStats, COLOR1);
|
|
||||||
_upstreamMixerID = addChannel(_form, _upstreamMixerStats, COLOR2);
|
|
||||||
_downstreamID = addChannel(_form, _downstreamStats, COLOR3);
|
|
||||||
_upstreamInjectedID = addChannel(_form, _upstreamInjectedStats, COLOR0);
|
|
||||||
|
|
||||||
// Initialize channels
|
|
||||||
updateChannels();
|
|
||||||
|
|
||||||
// Future renders
|
|
||||||
connect(averageUpdateTimer, SIGNAL(timeout()), this, SLOT(renderStats()));
|
|
||||||
averageUpdateTimer->start(200);
|
|
||||||
|
|
||||||
// Initial render
|
|
||||||
QDialog::setLayout(_form);
|
|
||||||
}
|
|
||||||
|
|
||||||
int AudioStatsDialog::addChannel(QFormLayout* form, QVector<QString>& stats, const unsigned color) {
|
|
||||||
|
|
||||||
int channelID = _audioDisplayChannels.size() - 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < stats.size(); i++)
|
|
||||||
// Create new display label
|
|
||||||
_audioDisplayChannels[channelID].push_back(new AudioStatsDisplay(form, stats.at(i), color));
|
|
||||||
|
|
||||||
// Expand vector to fit next channel
|
|
||||||
_audioDisplayChannels.resize(_audioDisplayChannels.size() + 1);
|
|
||||||
|
|
||||||
return channelID;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::renderStats() {
|
|
||||||
updateStats();
|
|
||||||
updateChannels();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::updateChannels() {
|
|
||||||
updateChannel(_audioMixerStats, _audioMixerID);
|
|
||||||
updateChannel(_upstreamClientStats, _upstreamClientID);
|
|
||||||
updateChannel(_upstreamMixerStats, _upstreamMixerID);
|
|
||||||
updateChannel(_downstreamStats, _downstreamID);
|
|
||||||
updateChannel(_upstreamInjectedStats, _upstreamInjectedID);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::updateChannel(QVector<QString>& stats, int channelID) {
|
|
||||||
// Update all stat displays at specified channel
|
|
||||||
for (int i = 0; i < stats.size(); i++)
|
|
||||||
_audioDisplayChannels[channelID].at(i)->updatedDisplay(stats.at(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::updateStats() {
|
|
||||||
|
|
||||||
// Clear current stats from all vectors
|
|
||||||
clearAllChannels();
|
|
||||||
|
|
||||||
double audioInputBufferLatency{ 0.0 };
|
|
||||||
double inputRingBufferLatency{ 0.0 };
|
|
||||||
double networkRoundtripLatency{ 0.0 };
|
|
||||||
double mixerRingBufferLatency{ 0.0 };
|
|
||||||
double outputRingBufferLatency{ 0.0 };
|
|
||||||
double audioOutputBufferLatency{ 0.0 };
|
|
||||||
|
|
||||||
if (SharedNodePointer audioMixerNodePointer = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::AudioMixer)) {
|
|
||||||
audioInputBufferLatency = (double)_stats->getInputMsRead().getWindowMax();
|
|
||||||
inputRingBufferLatency = (double)_stats->getInputMsUnplayed().getWindowMax();
|
|
||||||
networkRoundtripLatency = (double)audioMixerNodePointer->getPingMs();
|
|
||||||
mixerRingBufferLatency = (double)_stats->getMixerAvatarStreamStats()._unplayedMs;
|
|
||||||
outputRingBufferLatency = (double)_stats->getMixerDownstreamStats()._unplayedMs;
|
|
||||||
audioOutputBufferLatency = (double)_stats->getOutputMsUnplayed().getWindowMax();
|
|
||||||
}
|
|
||||||
|
|
||||||
double totalLatency = audioInputBufferLatency + inputRingBufferLatency + mixerRingBufferLatency
|
|
||||||
+ outputRingBufferLatency + audioOutputBufferLatency + networkRoundtripLatency;
|
|
||||||
|
|
||||||
QString stats;
|
|
||||||
_audioMixerStats.push_back("PIPELINE (averaged over the past 10s)");
|
|
||||||
stats = "Input Read:\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(audioInputBufferLatency, 'f', 0)));
|
|
||||||
stats = "Input Ring:\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(inputRingBufferLatency, 'f', 0)));
|
|
||||||
stats = "Network (client->mixer):\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(networkRoundtripLatency / 2, 'f', 0)));
|
|
||||||
stats = "Mixer Ring:\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(mixerRingBufferLatency, 'f', 0)));
|
|
||||||
stats = "Network (mixer->client):\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(networkRoundtripLatency / 2, 'f', 0)));
|
|
||||||
stats = "Output Ring:\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(outputRingBufferLatency, 'f', 0)));
|
|
||||||
stats = "Output Read:\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(audioOutputBufferLatency, 'f', 0)));
|
|
||||||
stats = "TOTAL:\t%1 ms";
|
|
||||||
_audioMixerStats.push_back(stats.arg(QString::number(totalLatency, 'f', 0)));
|
|
||||||
|
|
||||||
const MovingMinMaxAvg<quint64>& packetSentTimeGaps = _stats->getPacketTimegaps();
|
|
||||||
|
|
||||||
_upstreamClientStats.push_back("\nUpstream Mic Audio Packets Sent Gaps (by client):");
|
|
||||||
|
|
||||||
stats = "Inter-packet timegaps";
|
|
||||||
_upstreamClientStats.push_back(stats);
|
|
||||||
stats = "overall min:\t%1, max:\t%2, avg:\t%3";
|
|
||||||
stats = stats.arg(formatUsecTime(packetSentTimeGaps.getMin()),
|
|
||||||
formatUsecTime(packetSentTimeGaps.getMax()),
|
|
||||||
formatUsecTime(packetSentTimeGaps.getAverage()));
|
|
||||||
_upstreamClientStats.push_back(stats);
|
|
||||||
|
|
||||||
stats = "last window min:\t%1, max:\t%2, avg:\t%3";
|
|
||||||
stats = stats.arg(formatUsecTime(packetSentTimeGaps.getWindowMin()),
|
|
||||||
formatUsecTime(packetSentTimeGaps.getWindowMax()),
|
|
||||||
formatUsecTime(packetSentTimeGaps.getWindowAverage()));
|
|
||||||
_upstreamClientStats.push_back(stats);
|
|
||||||
|
|
||||||
_upstreamMixerStats.push_back("\nMIXER STREAM");
|
|
||||||
_upstreamMixerStats.push_back("(this client's remote mixer stream performance)");
|
|
||||||
|
|
||||||
renderAudioStreamStats(&_stats->getMixerAvatarStreamStats(), &_upstreamMixerStats);
|
|
||||||
|
|
||||||
_downstreamStats.push_back("\nCLIENT STREAM");
|
|
||||||
|
|
||||||
AudioStreamStats downstreamStats = _stats->getMixerDownstreamStats();
|
|
||||||
|
|
||||||
renderAudioStreamStats(&downstreamStats, &_downstreamStats);
|
|
||||||
|
|
||||||
|
|
||||||
if (_shouldShowInjectedStreams) {
|
|
||||||
|
|
||||||
foreach(const AudioStreamStats& injectedStreamAudioStats, _stats->getMixerInjectedStreamStatsMap()) {
|
|
||||||
stats = "\nINJECTED STREAM (ID: %1)";
|
|
||||||
stats = stats.arg(injectedStreamAudioStats._streamIdentifier.toString());
|
|
||||||
_upstreamInjectedStats.push_back(stats);
|
|
||||||
|
|
||||||
renderAudioStreamStats(&injectedStreamAudioStats, &_upstreamInjectedStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AudioStatsDialog::renderAudioStreamStats(const AudioStreamStats* streamStats, QVector<QString>* audioStreamStats) {
|
|
||||||
|
|
||||||
QString stats = "Packet Loss";
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
stats = "overall:\t%1%\t(%2 lost), window:\t%3%\t(%4 lost)";
|
|
||||||
stats = stats.arg(QString::number((int)(streamStats->_packetStreamStats.getLostRate() * 100.0f)),
|
|
||||||
QString::number((int)(streamStats->_packetStreamStats._lost)),
|
|
||||||
QString::number((int)(streamStats->_packetStreamWindowStats.getLostRate() * 100.0f)),
|
|
||||||
QString::number((int)(streamStats->_packetStreamWindowStats._lost)));
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
|
|
||||||
stats = "Ringbuffer";
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
stats = "available frames (avg):\t%1\t(%2), desired:\t%3";
|
|
||||||
stats = stats.arg(QString::number(streamStats->_framesAvailable),
|
|
||||||
QString::number(streamStats->_framesAvailableAverage),
|
|
||||||
QString::number(streamStats->_desiredJitterBufferFrames));
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
stats = "starves:\t%1, last starve duration:\t%2, drops:\t%3, overflows:\t%4";
|
|
||||||
stats = stats.arg(QString::number(streamStats->_starveCount),
|
|
||||||
QString::number(streamStats->_consecutiveNotMixedCount),
|
|
||||||
QString::number(streamStats->_framesDropped),
|
|
||||||
QString::number(streamStats->_overflowCount));
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
|
|
||||||
stats = "Inter-packet timegaps";
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
|
|
||||||
stats = "overall min:\t%1, max:\t%2, avg:\t%3";
|
|
||||||
stats = stats.arg(formatUsecTime(streamStats->_timeGapMin),
|
|
||||||
formatUsecTime(streamStats->_timeGapMax),
|
|
||||||
formatUsecTime(streamStats->_timeGapAverage));
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
|
|
||||||
|
|
||||||
stats = "last window min:\t%1, max:\t%2, avg:\t%3";
|
|
||||||
stats = stats.arg(formatUsecTime(streamStats->_timeGapWindowMin),
|
|
||||||
formatUsecTime(streamStats->_timeGapWindowMax),
|
|
||||||
formatUsecTime(streamStats->_timeGapWindowAverage));
|
|
||||||
audioStreamStats->push_back(stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::clearAllChannels() {
|
|
||||||
_audioMixerStats.clear();
|
|
||||||
_upstreamClientStats.clear();
|
|
||||||
_upstreamMixerStats.clear();
|
|
||||||
_downstreamStats.clear();
|
|
||||||
_upstreamInjectedStats.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::paintEvent(QPaintEvent* event) {
|
|
||||||
|
|
||||||
// Repaint each stat in each channel
|
|
||||||
for (int i = 0; i < _audioDisplayChannels.size(); i++) {
|
|
||||||
for(int j = 0; j < _audioDisplayChannels[i].size(); j++) {
|
|
||||||
_audioDisplayChannels[i].at(j)->paint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QDialog::paintEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::reject() {
|
|
||||||
// Just regularly close upon ESC
|
|
||||||
QDialog::close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioStatsDialog::closeEvent(QCloseEvent* event) {
|
|
||||||
QDialog::closeEvent(event);
|
|
||||||
emit closed();
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioStatsDialog::~AudioStatsDialog() {
|
|
||||||
clearAllChannels();
|
|
||||||
for (int i = 0; i < _audioDisplayChannels.size(); i++) {
|
|
||||||
_audioDisplayChannels[i].clear();
|
|
||||||
for(int j = 0; j < _audioDisplayChannels[i].size(); j++) {
|
|
||||||
delete _audioDisplayChannels[i].at(j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
//
|
|
||||||
// AudioStatsDialog.h
|
|
||||||
// hifi
|
|
||||||
//
|
|
||||||
// Created by Bridget Went on 7/9/15.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __hifi__AudioStatsDialog__
|
|
||||||
#define __hifi__AudioStatsDialog__
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QLabel>
|
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QVector>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
|
||||||
|
|
||||||
class AudioIOStats;
|
|
||||||
class AudioStreamStats;
|
|
||||||
|
|
||||||
//display
|
|
||||||
class AudioStatsDisplay : public QObject, public Dependency {
|
|
||||||
Q_OBJECT
|
|
||||||
SINGLETON_DEPENDENCY
|
|
||||||
public:
|
|
||||||
AudioStatsDisplay(QFormLayout* form, QString text, unsigned colorRGBA);
|
|
||||||
void updatedDisplay(QString str);
|
|
||||||
void paint();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QString _strBuf;
|
|
||||||
QLabel* _label;
|
|
||||||
QString _text;
|
|
||||||
unsigned _colorRGBA;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//dialog
|
|
||||||
class AudioStatsDialog : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
AudioStatsDialog(QWidget* parent);
|
|
||||||
~AudioStatsDialog();
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent*) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// audio stats methods for rendering
|
|
||||||
QVector<QString> _audioMixerStats;
|
|
||||||
QVector<QString> _upstreamClientStats;
|
|
||||||
QVector<QString> _upstreamMixerStats;
|
|
||||||
QVector<QString> _downstreamStats;
|
|
||||||
QVector<QString> _upstreamInjectedStats;
|
|
||||||
|
|
||||||
int _audioMixerID;
|
|
||||||
int _upstreamClientID;
|
|
||||||
int _upstreamMixerID;
|
|
||||||
int _downstreamID;
|
|
||||||
int _upstreamInjectedID;
|
|
||||||
|
|
||||||
QVector<QVector<AudioStatsDisplay*>> _audioDisplayChannels;
|
|
||||||
|
|
||||||
void updateStats();
|
|
||||||
int addChannel(QFormLayout* form, QVector<QString>& stats, const unsigned color);
|
|
||||||
void updateChannel(QVector<QString>& stats, const int channelID);
|
|
||||||
void updateChannels();
|
|
||||||
void clearAllChannels();
|
|
||||||
void renderAudioStreamStats(const AudioStreamStats* streamStats, QVector<QString>* audioStreamstats);
|
|
||||||
|
|
||||||
|
|
||||||
const AudioIOStats* _stats;
|
|
||||||
QFormLayout* _form;
|
|
||||||
|
|
||||||
bool _shouldShowInjectedStreams{ false };
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
|
|
||||||
void closed();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
|
|
||||||
void reject() override;
|
|
||||||
void renderStats();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// Emits a 'closed' signal when this dialog is closed.
|
|
||||||
void closeEvent(QCloseEvent*) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTimer* averageUpdateTimer = new QTimer(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* defined(__hifi__AudioStatsDialog__) */
|
|
||||||
|
|
|
@ -103,20 +103,6 @@ void DialogsManager::cachesSizeDialog() {
|
||||||
_cachesSizeDialog->raise();
|
_cachesSizeDialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsManager::audioStatsDetails() {
|
|
||||||
if (! _audioStatsDialog) {
|
|
||||||
_audioStatsDialog = new AudioStatsDialog(qApp->getWindow());
|
|
||||||
connect(_audioStatsDialog, SIGNAL(closed()), _audioStatsDialog, SLOT(deleteLater()));
|
|
||||||
|
|
||||||
if (_hmdToolsDialog) {
|
|
||||||
_hmdToolsDialog->watchWindow(_audioStatsDialog->windowHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
_audioStatsDialog->show();
|
|
||||||
}
|
|
||||||
_audioStatsDialog->raise();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DialogsManager::bandwidthDetails() {
|
void DialogsManager::bandwidthDetails() {
|
||||||
if (! _bandwidthDialog) {
|
if (! _bandwidthDialog) {
|
||||||
_bandwidthDialog = new BandwidthDialog(qApp->getWindow());
|
_bandwidthDialog = new BandwidthDialog(qApp->getWindow());
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
class AnimationsDialog;
|
class AnimationsDialog;
|
||||||
class AttachmentsDialog;
|
class AttachmentsDialog;
|
||||||
class AudioStatsDialog;
|
|
||||||
class BandwidthDialog;
|
class BandwidthDialog;
|
||||||
class CachesSizeDialog;
|
class CachesSizeDialog;
|
||||||
class DiskCacheEditor;
|
class DiskCacheEditor;
|
||||||
|
@ -35,7 +34,6 @@ class DialogsManager : public QObject, public Dependency {
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QPointer<AudioStatsDialog> getAudioStatsDialog() const { return _audioStatsDialog; }
|
|
||||||
QPointer<BandwidthDialog> getBandwidthDialog() const { return _bandwidthDialog; }
|
QPointer<BandwidthDialog> getBandwidthDialog() const { return _bandwidthDialog; }
|
||||||
QPointer<HMDToolsDialog> getHMDToolsDialog() const { return _hmdToolsDialog; }
|
QPointer<HMDToolsDialog> getHMDToolsDialog() const { return _hmdToolsDialog; }
|
||||||
QPointer<LodToolsDialog> getLodToolsDialog() const { return _lodToolsDialog; }
|
QPointer<LodToolsDialog> getLodToolsDialog() const { return _lodToolsDialog; }
|
||||||
|
@ -52,7 +50,6 @@ public slots:
|
||||||
void showLoginDialog();
|
void showLoginDialog();
|
||||||
void octreeStatsDetails();
|
void octreeStatsDetails();
|
||||||
void cachesSizeDialog();
|
void cachesSizeDialog();
|
||||||
void audioStatsDetails();
|
|
||||||
void bandwidthDetails();
|
void bandwidthDetails();
|
||||||
void lodTools();
|
void lodTools();
|
||||||
void hmdTools(bool showTools);
|
void hmdTools(bool showTools);
|
||||||
|
@ -78,7 +75,6 @@ private:
|
||||||
|
|
||||||
QPointer<AnimationsDialog> _animationsDialog;
|
QPointer<AnimationsDialog> _animationsDialog;
|
||||||
QPointer<AttachmentsDialog> _attachmentsDialog;
|
QPointer<AttachmentsDialog> _attachmentsDialog;
|
||||||
QPointer<AudioStatsDialog> _audioStatsDialog;
|
|
||||||
QPointer<BandwidthDialog> _bandwidthDialog;
|
QPointer<BandwidthDialog> _bandwidthDialog;
|
||||||
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
QPointer<CachesSizeDialog> _cachesSizeDialog;
|
||||||
QPointer<DiskCacheEditor> _diskCacheEditor;
|
QPointer<DiskCacheEditor> _diskCacheEditor;
|
||||||
|
|
|
@ -28,8 +28,6 @@ class Stats : public QQuickItem {
|
||||||
Q_PROPERTY(bool expanded READ isExpanded WRITE setExpanded NOTIFY expandedChanged)
|
Q_PROPERTY(bool expanded READ isExpanded WRITE setExpanded NOTIFY expandedChanged)
|
||||||
Q_PROPERTY(bool timingExpanded READ isTimingExpanded NOTIFY timingExpandedChanged)
|
Q_PROPERTY(bool timingExpanded READ isTimingExpanded NOTIFY timingExpandedChanged)
|
||||||
Q_PROPERTY(QString monospaceFont READ monospaceFont CONSTANT)
|
Q_PROPERTY(QString monospaceFont READ monospaceFont CONSTANT)
|
||||||
Q_PROPERTY(float audioPacketlossUpstream READ getAudioPacketLossUpstream)
|
|
||||||
Q_PROPERTY(float audioPacketlossDownstream READ getAudioPacketLossDownstream)
|
|
||||||
|
|
||||||
STATS_PROPERTY(int, serverCount, 0)
|
STATS_PROPERTY(int, serverCount, 0)
|
||||||
// How often the app is creating new gpu::Frames
|
// How often the app is creating new gpu::Frames
|
||||||
|
@ -102,9 +100,6 @@ public:
|
||||||
return _monospaceFont;
|
return _monospaceFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getAudioPacketLossUpstream() { return _audioStats->getMixerAvatarStreamStats()._packetStreamStats.getLostRate(); }
|
|
||||||
float getAudioPacketLossDownstream() { return _audioStats->getMixerDownstreamStats()._packetStreamStats.getLostRate(); }
|
|
||||||
|
|
||||||
void updateStats(bool force = false);
|
void updateStats(bool force = false);
|
||||||
|
|
||||||
bool isExpanded() { return _expanded; }
|
bool isExpanded() { return _expanded; }
|
||||||
|
|
|
@ -148,7 +148,7 @@ public slots:
|
||||||
void handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message);
|
void handleSelectedAudioFormat(QSharedPointer<ReceivedMessage> message);
|
||||||
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
|
void handleMismatchAudioFormat(SharedNodePointer node, const QString& currentCodec, const QString& recievedCodec);
|
||||||
|
|
||||||
void sendDownstreamAudioStatsPacket() { _stats.sendDownstreamAudioStatsPacket(); }
|
void sendDownstreamAudioStatsPacket() { _stats.publish(); }
|
||||||
void handleAudioInput();
|
void handleAudioInput();
|
||||||
void handleRecordedAudioInput(const QByteArray& audio);
|
void handleRecordedAudioInput(const QByteArray& audio);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
|
@ -18,22 +18,24 @@
|
||||||
|
|
||||||
#include "AudioIOStats.h"
|
#include "AudioIOStats.h"
|
||||||
|
|
||||||
// This is called 5x/sec (see AudioStatsDialog), and we want it to log the last 5s
|
// This is called 1x/sec (see AudioClient) and we want it to log the last 5s
|
||||||
static const int INPUT_READS_WINDOW = 25;
|
static const int INPUT_READS_WINDOW = 5;
|
||||||
static const int INPUT_UNPLAYED_WINDOW = 25;
|
static const int INPUT_UNPLAYED_WINDOW = 5;
|
||||||
static const int OUTPUT_UNPLAYED_WINDOW = 25;
|
static const int OUTPUT_UNPLAYED_WINDOW = 5;
|
||||||
|
|
||||||
static const int APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS = (int)(30.0f * 1000.0f / AudioConstants::NETWORK_FRAME_MSECS);
|
static const int APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS = (int)(30.0f * 1000.0f / AudioConstants::NETWORK_FRAME_MSECS);
|
||||||
|
|
||||||
|
|
||||||
AudioIOStats::AudioIOStats(MixedProcessedAudioStream* receivedAudioStream) :
|
AudioIOStats::AudioIOStats(MixedProcessedAudioStream* receivedAudioStream) :
|
||||||
_receivedAudioStream(receivedAudioStream),
|
_interface(new AudioStatsInterface(this)),
|
||||||
_inputMsRead(0, INPUT_READS_WINDOW),
|
_inputMsRead(1, INPUT_READS_WINDOW),
|
||||||
_inputMsUnplayed(0, INPUT_UNPLAYED_WINDOW),
|
_inputMsUnplayed(1, INPUT_UNPLAYED_WINDOW),
|
||||||
_outputMsUnplayed(0, OUTPUT_UNPLAYED_WINDOW),
|
_outputMsUnplayed(1, OUTPUT_UNPLAYED_WINDOW),
|
||||||
_lastSentPacketTime(0),
|
_lastSentPacketTime(0),
|
||||||
_packetTimegaps(0, APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS)
|
_packetTimegaps(1, APPROXIMATELY_30_SECONDS_OF_AUDIO_PACKETS),
|
||||||
|
_receivedAudioStream(receivedAudioStream)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioIOStats::reset() {
|
void AudioIOStats::reset() {
|
||||||
|
@ -44,11 +46,13 @@ void AudioIOStats::reset() {
|
||||||
_outputMsUnplayed.reset();
|
_outputMsUnplayed.reset();
|
||||||
_packetTimegaps.reset();
|
_packetTimegaps.reset();
|
||||||
|
|
||||||
_mixerAvatarStreamStats = AudioStreamStats();
|
_interface->updateLocalBuffers(_inputMsRead, _inputMsUnplayed, _outputMsUnplayed, _packetTimegaps);
|
||||||
_mixerInjectedStreamStatsMap.clear();
|
_interface->updateMixerStream(AudioStreamStats());
|
||||||
|
_interface->updateClientStream(AudioStreamStats());
|
||||||
|
_interface->updateInjectorStreams(QHash<QUuid, AudioStreamStats>());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioIOStats::sentPacket() {
|
void AudioIOStats::sentPacket() const {
|
||||||
// first time this is 0
|
// first time this is 0
|
||||||
if (_lastSentPacketTime == 0) {
|
if (_lastSentPacketTime == 0) {
|
||||||
_lastSentPacketTime = usecTimestampNow();
|
_lastSentPacketTime = usecTimestampNow();
|
||||||
|
@ -60,37 +64,13 @@ void AudioIOStats::sentPacket() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const MovingMinMaxAvg<float>& AudioIOStats::getInputMsRead() const {
|
|
||||||
_inputMsRead.currentIntervalComplete();
|
|
||||||
return _inputMsRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MovingMinMaxAvg<float>& AudioIOStats::getInputMsUnplayed() const {
|
|
||||||
_inputMsUnplayed.currentIntervalComplete();
|
|
||||||
return _inputMsUnplayed;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MovingMinMaxAvg<float>& AudioIOStats::getOutputMsUnplayed() const {
|
|
||||||
_outputMsUnplayed.currentIntervalComplete();
|
|
||||||
return _outputMsUnplayed;
|
|
||||||
}
|
|
||||||
|
|
||||||
const MovingMinMaxAvg<quint64>& AudioIOStats::getPacketTimegaps() const {
|
|
||||||
_packetTimegaps.currentIntervalComplete();
|
|
||||||
return _packetTimegaps;
|
|
||||||
}
|
|
||||||
|
|
||||||
const AudioStreamStats AudioIOStats::getMixerDownstreamStats() const {
|
|
||||||
return _receivedAudioStream->getAudioStreamStats();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioIOStats::processStreamStatsPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
void AudioIOStats::processStreamStatsPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
|
||||||
// parse the appendFlag, clear injected audio stream stats if 0
|
// parse the appendFlag, clear injected audio stream stats if 0
|
||||||
quint8 appendFlag;
|
quint8 appendFlag;
|
||||||
message->readPrimitive(&appendFlag);
|
message->readPrimitive(&appendFlag);
|
||||||
|
|
||||||
if (!appendFlag) {
|
if (appendFlag & AudioStreamStats::START) {
|
||||||
_mixerInjectedStreamStatsMap.clear();
|
_injectorStreams.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the number of stream stats structs to follow
|
// parse the number of stream stats structs to follow
|
||||||
|
@ -103,14 +83,18 @@ void AudioIOStats::processStreamStatsPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
message->readPrimitive(&streamStats);
|
message->readPrimitive(&streamStats);
|
||||||
|
|
||||||
if (streamStats._streamType == PositionalAudioStream::Microphone) {
|
if (streamStats._streamType == PositionalAudioStream::Microphone) {
|
||||||
_mixerAvatarStreamStats = streamStats;
|
_interface->updateMixerStream(streamStats);
|
||||||
} else {
|
} else {
|
||||||
_mixerInjectedStreamStatsMap[streamStats._streamIdentifier] = streamStats;
|
_injectorStreams[streamStats._streamIdentifier] = streamStats;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (appendFlag & AudioStreamStats::END) {
|
||||||
|
_interface->updateInjectorStreams(_injectorStreams);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioIOStats::sendDownstreamAudioStatsPacket() {
|
void AudioIOStats::publish() {
|
||||||
auto audioIO = DependencyManager::get<AudioClient>();
|
auto audioIO = DependencyManager::get<AudioClient>();
|
||||||
|
|
||||||
// call _receivedAudioStream's per-second callback
|
// call _receivedAudioStream's per-second callback
|
||||||
|
@ -122,10 +106,15 @@ void AudioIOStats::sendDownstreamAudioStatsPacket() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint8 appendFlag = 0;
|
quint8 appendFlag = AudioStreamStats::START | AudioStreamStats::END;
|
||||||
quint16 numStreamStatsToPack = 1;
|
quint16 numStreamStatsToPack = 1;
|
||||||
AudioStreamStats stats = _receivedAudioStream->getAudioStreamStats();
|
AudioStreamStats stats = _receivedAudioStream->getAudioStreamStats();
|
||||||
|
|
||||||
|
// update the interface
|
||||||
|
_interface->updateLocalBuffers(_inputMsRead, _inputMsUnplayed, _outputMsUnplayed, _packetTimegaps);
|
||||||
|
_interface->updateClientStream(stats);
|
||||||
|
|
||||||
|
// prepare a packet to the mixer
|
||||||
int statsPacketSize = sizeof(appendFlag) + sizeof(numStreamStatsToPack) + sizeof(stats);
|
int statsPacketSize = sizeof(appendFlag) + sizeof(numStreamStatsToPack) + sizeof(stats);
|
||||||
auto statsPacket = NLPacket::create(PacketType::AudioStreamStats, statsPacketSize);
|
auto statsPacket = NLPacket::create(PacketType::AudioStreamStats, statsPacketSize);
|
||||||
|
|
||||||
|
@ -137,7 +126,88 @@ void AudioIOStats::sendDownstreamAudioStatsPacket() {
|
||||||
|
|
||||||
// pack downstream audio stream stats
|
// pack downstream audio stream stats
|
||||||
statsPacket->writePrimitive(stats);
|
statsPacket->writePrimitive(stats);
|
||||||
|
|
||||||
// send packet
|
// send packet
|
||||||
nodeList->sendPacket(std::move(statsPacket), *audioMixer);
|
nodeList->sendPacket(std::move(statsPacket), *audioMixer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioStreamStatsInterface::AudioStreamStatsInterface(QObject* parent) :
|
||||||
|
QObject(parent) {}
|
||||||
|
|
||||||
|
void AudioStreamStatsInterface::updateStream(const AudioStreamStats& stats) {
|
||||||
|
lossRate(stats._packetStreamStats.getLostRate());
|
||||||
|
lossCount(stats._packetStreamStats._lost);
|
||||||
|
lossRateWindow(stats._packetStreamWindowStats.getLostRate());
|
||||||
|
lossCountWindow(stats._packetStreamWindowStats._lost);
|
||||||
|
|
||||||
|
framesDesired(stats._desiredJitterBufferFrames);
|
||||||
|
framesAvailable(stats._framesAvailable);
|
||||||
|
framesAvailableAvg(stats._framesAvailableAverage);
|
||||||
|
|
||||||
|
unplayedMsMax(stats._unplayedMs);
|
||||||
|
|
||||||
|
starveCount(stats._starveCount);
|
||||||
|
lastStarveDurationCount(stats._consecutiveNotMixedCount);
|
||||||
|
dropCount(stats._framesDropped);
|
||||||
|
overflowCount(stats._overflowCount);
|
||||||
|
|
||||||
|
timegapMsMax(stats._timeGapMax / USECS_PER_MSEC);
|
||||||
|
timegapMsAvg(stats._timeGapAverage / USECS_PER_MSEC);
|
||||||
|
timegapMsMaxWindow(stats._timeGapWindowMax / USECS_PER_MSEC);
|
||||||
|
timegapMsAvgWindow(stats._timeGapWindowAverage / USECS_PER_MSEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioStatsInterface::AudioStatsInterface(QObject* parent) :
|
||||||
|
QObject(parent),
|
||||||
|
_client(new AudioStreamStatsInterface(this)),
|
||||||
|
_mixer(new AudioStreamStatsInterface(this)),
|
||||||
|
_injectors(new QObject(this)) {}
|
||||||
|
|
||||||
|
|
||||||
|
void AudioStatsInterface::updateLocalBuffers(const MovingMinMaxAvg<float>& inputMsRead,
|
||||||
|
const MovingMinMaxAvg<float>& inputMsUnplayed,
|
||||||
|
const MovingMinMaxAvg<float>& outputMsUnplayed,
|
||||||
|
const MovingMinMaxAvg<quint64>& timegaps) {
|
||||||
|
if (SharedNodePointer audioNode = DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::AudioMixer)) {
|
||||||
|
pingMs(audioNode->getPingMs());
|
||||||
|
}
|
||||||
|
|
||||||
|
inputReadMsMax(inputMsRead.getWindowMax());
|
||||||
|
inputUnplayedMsMax(inputMsUnplayed.getWindowMax());
|
||||||
|
outputUnplayedMsMax(outputMsUnplayed.getWindowMax());
|
||||||
|
|
||||||
|
sentTimegapMsMax(timegaps.getMax() / USECS_PER_MSEC);
|
||||||
|
sentTimegapMsAvg(timegaps.getAverage() / USECS_PER_MSEC);
|
||||||
|
sentTimegapMsMaxWindow(timegaps.getWindowMax() / USECS_PER_MSEC);
|
||||||
|
sentTimegapMsAvgWindow(timegaps.getWindowAverage() / USECS_PER_MSEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioStatsInterface::updateInjectorStreams(const QHash<QUuid, AudioStreamStats>& stats) {
|
||||||
|
// Get existing injectors
|
||||||
|
auto injectorIds = _injectors->dynamicPropertyNames();
|
||||||
|
|
||||||
|
// Go over reported injectors
|
||||||
|
QHash<QUuid, AudioStreamStats>::const_iterator injector = stats.constBegin();
|
||||||
|
while (injector != stats.constEnd()) {
|
||||||
|
const auto id = injector.key().toByteArray();
|
||||||
|
// Mark existing injector (those left will be removed)
|
||||||
|
injectorIds.removeOne(id);
|
||||||
|
auto injectorProperty = _injectors->property(id);
|
||||||
|
// Add new injector
|
||||||
|
if (!injectorProperty.isValid()) {
|
||||||
|
injectorProperty = QVariant::fromValue(new AudioStreamStatsInterface(this));
|
||||||
|
_injectors->setProperty(id, injectorProperty);
|
||||||
|
}
|
||||||
|
// Update property with reported injector
|
||||||
|
injectorProperty.value<AudioStreamStatsInterface*>()->updateStream(injector.value());
|
||||||
|
++injector;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove unreported injectors
|
||||||
|
for (auto& id : injectorIds) {
|
||||||
|
_injectors->property(id).value<AudioStreamStatsInterface*>()->deleteLater();
|
||||||
|
_injectors->setProperty(id, QVariant());
|
||||||
|
}
|
||||||
|
|
||||||
|
emit injectorStreamsChanged();
|
||||||
|
}
|
||||||
|
|
|
@ -22,44 +22,124 @@
|
||||||
|
|
||||||
class MixedProcessedAudioStream;
|
class MixedProcessedAudioStream;
|
||||||
|
|
||||||
|
#define AUDIO_PROPERTY(TYPE, NAME) \
|
||||||
|
Q_PROPERTY(TYPE NAME READ NAME NOTIFY NAME##Changed) \
|
||||||
|
public: \
|
||||||
|
TYPE NAME() const { return _##NAME; } \
|
||||||
|
void NAME(TYPE value) { \
|
||||||
|
if (_##NAME != value) { \
|
||||||
|
_##NAME = value; \
|
||||||
|
emit NAME##Changed(value); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
Q_SIGNAL void NAME##Changed(TYPE value); \
|
||||||
|
private: \
|
||||||
|
TYPE _##NAME{ (TYPE)0 };
|
||||||
|
|
||||||
|
class AudioStreamStatsInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
AUDIO_PROPERTY(float, lossRate)
|
||||||
|
AUDIO_PROPERTY(float, lossCount)
|
||||||
|
AUDIO_PROPERTY(float, lossRateWindow)
|
||||||
|
AUDIO_PROPERTY(float, lossCountWindow)
|
||||||
|
|
||||||
|
AUDIO_PROPERTY(int, framesDesired)
|
||||||
|
AUDIO_PROPERTY(int, framesAvailable)
|
||||||
|
AUDIO_PROPERTY(int, framesAvailableAvg)
|
||||||
|
AUDIO_PROPERTY(float, unplayedMsMax)
|
||||||
|
|
||||||
|
AUDIO_PROPERTY(int, starveCount)
|
||||||
|
AUDIO_PROPERTY(int, lastStarveDurationCount)
|
||||||
|
AUDIO_PROPERTY(int, dropCount)
|
||||||
|
AUDIO_PROPERTY(int, overflowCount)
|
||||||
|
|
||||||
|
AUDIO_PROPERTY(quint64, timegapMsMax)
|
||||||
|
AUDIO_PROPERTY(quint64, timegapMsAvg)
|
||||||
|
AUDIO_PROPERTY(quint64, timegapMsMaxWindow)
|
||||||
|
AUDIO_PROPERTY(quint64, timegapMsAvgWindow)
|
||||||
|
|
||||||
|
public:
|
||||||
|
void updateStream(const AudioStreamStats& stats);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class AudioStatsInterface;
|
||||||
|
AudioStreamStatsInterface(QObject* parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
class AudioStatsInterface : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
AUDIO_PROPERTY(float, pingMs);
|
||||||
|
|
||||||
|
AUDIO_PROPERTY(float, inputReadMsMax);
|
||||||
|
AUDIO_PROPERTY(float, inputUnplayedMsMax);
|
||||||
|
AUDIO_PROPERTY(float, outputUnplayedMsMax);
|
||||||
|
|
||||||
|
AUDIO_PROPERTY(quint64, sentTimegapMsMax);
|
||||||
|
AUDIO_PROPERTY(quint64, sentTimegapMsAvg);
|
||||||
|
AUDIO_PROPERTY(quint64, sentTimegapMsMaxWindow);
|
||||||
|
AUDIO_PROPERTY(quint64, sentTimegapMsAvgWindow);
|
||||||
|
|
||||||
|
Q_PROPERTY(AudioStreamStatsInterface* mixerStream READ getMixerStream NOTIFY mixerStreamChanged);
|
||||||
|
Q_PROPERTY(AudioStreamStatsInterface* clientStream READ getClientStream NOTIFY clientStreamChanged);
|
||||||
|
Q_PROPERTY(QObject* injectorStreams READ getInjectorStreams NOTIFY injectorStreamsChanged);
|
||||||
|
|
||||||
|
public:
|
||||||
|
AudioStreamStatsInterface* getMixerStream() const { return _mixer; }
|
||||||
|
AudioStreamStatsInterface* getClientStream() const { return _client; }
|
||||||
|
QObject* getInjectorStreams() const { return _injectors; }
|
||||||
|
|
||||||
|
void updateLocalBuffers(const MovingMinMaxAvg<float>& inputMsRead,
|
||||||
|
const MovingMinMaxAvg<float>& inputMsUnplayed,
|
||||||
|
const MovingMinMaxAvg<float>& outputMsUnplayed,
|
||||||
|
const MovingMinMaxAvg<quint64>& timegaps);
|
||||||
|
void updateMixerStream(const AudioStreamStats& stats) { _mixer->updateStream(stats); emit mixerStreamChanged(); }
|
||||||
|
void updateClientStream(const AudioStreamStats& stats) { _client->updateStream(stats); emit clientStreamChanged(); }
|
||||||
|
void updateInjectorStreams(const QHash<QUuid, AudioStreamStats>& stats);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void mixerStreamChanged();
|
||||||
|
void clientStreamChanged();
|
||||||
|
void injectorStreamsChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class AudioIOStats;
|
||||||
|
AudioStatsInterface(QObject* parent);
|
||||||
|
AudioStreamStatsInterface* _client;
|
||||||
|
AudioStreamStatsInterface* _mixer;
|
||||||
|
QObject* _injectors;
|
||||||
|
};
|
||||||
|
|
||||||
class AudioIOStats : public QObject {
|
class AudioIOStats : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AudioIOStats(MixedProcessedAudioStream* receivedAudioStream);
|
AudioIOStats(MixedProcessedAudioStream* receivedAudioStream);
|
||||||
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
void updateInputMsRead(float ms) { _inputMsRead.update(ms); }
|
|
||||||
void updateInputMsUnplayed(float ms) { _inputMsUnplayed.update(ms); }
|
|
||||||
void updateOutputMsUnplayed(float ms) { _outputMsUnplayed.update(ms); }
|
|
||||||
void sentPacket();
|
|
||||||
|
|
||||||
const MovingMinMaxAvg<float>& getInputMsRead() const;
|
|
||||||
const MovingMinMaxAvg<float>& getInputMsUnplayed() const;
|
|
||||||
const MovingMinMaxAvg<float>& getOutputMsUnplayed() const;
|
|
||||||
const MovingMinMaxAvg<quint64>& getPacketTimegaps() const;
|
|
||||||
|
|
||||||
const AudioStreamStats getMixerDownstreamStats() const;
|
void reset();
|
||||||
const AudioStreamStats& getMixerAvatarStreamStats() const { return _mixerAvatarStreamStats; }
|
|
||||||
const QHash<QUuid, AudioStreamStats>& getMixerInjectedStreamStatsMap() const { return _mixerInjectedStreamStatsMap; }
|
AudioStatsInterface* data() const { return _interface; }
|
||||||
|
|
||||||
void sendDownstreamAudioStatsPacket();
|
void updateInputMsRead(float ms) const { _inputMsRead.update(ms); }
|
||||||
|
void updateInputMsUnplayed(float ms) const { _inputMsUnplayed.update(ms); }
|
||||||
|
void updateOutputMsUnplayed(float ms) const { _outputMsUnplayed.update(ms); }
|
||||||
|
void sentPacket() const;
|
||||||
|
|
||||||
|
void publish();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void processStreamStatsPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);
|
void processStreamStatsPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MixedProcessedAudioStream* _receivedAudioStream;
|
AudioStatsInterface* _interface;
|
||||||
|
|
||||||
mutable MovingMinMaxAvg<float> _inputMsRead;
|
mutable MovingMinMaxAvg<float> _inputMsRead;
|
||||||
mutable MovingMinMaxAvg<float> _inputMsUnplayed;
|
mutable MovingMinMaxAvg<float> _inputMsUnplayed;
|
||||||
mutable MovingMinMaxAvg<float> _outputMsUnplayed;
|
mutable MovingMinMaxAvg<float> _outputMsUnplayed;
|
||||||
|
|
||||||
quint64 _lastSentPacketTime;
|
mutable quint64 _lastSentPacketTime;
|
||||||
mutable MovingMinMaxAvg<quint64> _packetTimegaps;
|
mutable MovingMinMaxAvg<quint64> _packetTimegaps;
|
||||||
|
|
||||||
AudioStreamStats _mixerAvatarStreamStats;
|
MixedProcessedAudioStream* _receivedAudioStream;
|
||||||
QHash<QUuid, AudioStreamStats> _mixerInjectedStreamStatsMap;
|
QHash<QUuid, AudioStreamStats> _injectorStreams;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AudioIOStats_h
|
#endif // hifi_AudioIOStats_h
|
||||||
|
|
|
@ -16,6 +16,13 @@
|
||||||
|
|
||||||
class AudioStreamStats {
|
class AudioStreamStats {
|
||||||
public:
|
public:
|
||||||
|
// Intermediate packets should have no flag set
|
||||||
|
// Unique packets should have both flags set
|
||||||
|
enum AppendFlag : quint8 {
|
||||||
|
START = 1,
|
||||||
|
END = 2
|
||||||
|
};
|
||||||
|
|
||||||
AudioStreamStats()
|
AudioStreamStats()
|
||||||
: _streamType(-1),
|
: _streamType(-1),
|
||||||
_streamIdentifier(),
|
_streamIdentifier(),
|
||||||
|
|
|
@ -76,7 +76,8 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::InjectAudio:
|
case PacketType::InjectAudio:
|
||||||
case PacketType::MicrophoneAudioNoEcho:
|
case PacketType::MicrophoneAudioNoEcho:
|
||||||
case PacketType::MicrophoneAudioWithEcho:
|
case PacketType::MicrophoneAudioWithEcho:
|
||||||
return static_cast<PacketVersion>(AudioVersion::Exactly10msAudioPackets);
|
case PacketType::AudioStreamStats:
|
||||||
|
return static_cast<PacketVersion>(AudioVersion::TerminatingStreamStats);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return 17;
|
return 17;
|
||||||
|
|
|
@ -227,7 +227,8 @@ enum class DomainListVersion : PacketVersion {
|
||||||
enum class AudioVersion : PacketVersion {
|
enum class AudioVersion : PacketVersion {
|
||||||
HasCompressedAudio = 17,
|
HasCompressedAudio = 17,
|
||||||
CodecNameInAudioPackets,
|
CodecNameInAudioPackets,
|
||||||
Exactly10msAudioPackets
|
Exactly10msAudioPackets,
|
||||||
|
TerminatingStreamStats,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_PacketHeaders_h
|
#endif // hifi_PacketHeaders_h
|
||||||
|
|
32
scripts/developer/utilities/audio/Jitter.qml
Normal file
32
scripts/developer/utilities/audio/Jitter.qml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
//
|
||||||
|
// Jitter.qml
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 9/22/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: jitter
|
||||||
|
property var max
|
||||||
|
property var avg
|
||||||
|
property bool showGraphs: false
|
||||||
|
|
||||||
|
MovingValue {
|
||||||
|
label: "Jitter"
|
||||||
|
color: "red"
|
||||||
|
source: max - avg
|
||||||
|
showGraphs: jitter.showGraphs
|
||||||
|
}
|
||||||
|
Value {
|
||||||
|
label: "Average"
|
||||||
|
source: avg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
51
scripts/developer/utilities/audio/MovingValue.qml
Normal file
51
scripts/developer/utilities/audio/MovingValue.qml
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
//
|
||||||
|
// MovingValue.qml
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 9/22/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import "../lib/plotperf"
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: value
|
||||||
|
property string label
|
||||||
|
property var source
|
||||||
|
property string unit: "ms"
|
||||||
|
property bool showGraphs: false
|
||||||
|
property color color: "darkslategrey"
|
||||||
|
property int decimals: 0
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.preferredWidth: 100
|
||||||
|
color: value.color
|
||||||
|
text: value.label
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
visible: !value.showGraphs
|
||||||
|
Layout.preferredWidth: 50
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
color: value.color
|
||||||
|
text: value.source.toFixed(decimals) + ' ' + unit
|
||||||
|
}
|
||||||
|
PlotPerf {
|
||||||
|
visible: value.showGraphs
|
||||||
|
Layout.fillWidth: true
|
||||||
|
height: 70
|
||||||
|
|
||||||
|
valueUnit: value.unit
|
||||||
|
valueNumDigits: 0
|
||||||
|
backgroundOpacity: 0.2
|
||||||
|
|
||||||
|
plots: [{ binding: "source", color: value.color }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
56
scripts/developer/utilities/audio/Section.qml
Normal file
56
scripts/developer/utilities/audio/Section.qml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
//
|
||||||
|
// Section.qml
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 9/22/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: section
|
||||||
|
property string label: "Section"
|
||||||
|
property string description: "Description"
|
||||||
|
property alias control : loader.sourceComponent
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
height: content.height + border.width * 2 + content.spacing * 2
|
||||||
|
border.color: "black"
|
||||||
|
border.width: 5
|
||||||
|
radius: border.width * 2
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: content
|
||||||
|
x: section.radius; y: section.radius
|
||||||
|
spacing: section.border.width
|
||||||
|
width: section.width - 2 * x
|
||||||
|
|
||||||
|
// label
|
||||||
|
Label {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: hoverArea.containsMouse ? section.description : section.label
|
||||||
|
font.bold: true
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: hoverArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// spacer
|
||||||
|
Item { }
|
||||||
|
|
||||||
|
// control
|
||||||
|
Loader {
|
||||||
|
id: loader
|
||||||
|
Layout.preferredWidth: parent.width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
69
scripts/developer/utilities/audio/Stream.qml
Normal file
69
scripts/developer/utilities/audio/Stream.qml
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
//
|
||||||
|
// Stream.qml
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 9/22/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: root
|
||||||
|
property var stream
|
||||||
|
property bool showGraphs: false
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: "Ring Buffer"
|
||||||
|
font.italic: true
|
||||||
|
}
|
||||||
|
MovingValue {
|
||||||
|
label: "Minimum Depth"
|
||||||
|
color: "limegreen"
|
||||||
|
source: stream.framesDesired
|
||||||
|
unit: "frames"
|
||||||
|
showGraphs: root.showGraphs
|
||||||
|
}
|
||||||
|
MovingValue {
|
||||||
|
label: "Buffer Depth"
|
||||||
|
color: "darkblue"
|
||||||
|
source: stream.unplayedMsMax
|
||||||
|
showGraphs: root.showGraphs
|
||||||
|
}
|
||||||
|
Value {
|
||||||
|
label: "Available (avg)"
|
||||||
|
source: stream.framesAvailable + " (" + stream.framesAvailableAvg + ") frames"
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: "Jitter"
|
||||||
|
font.italic: true
|
||||||
|
}
|
||||||
|
Jitter {
|
||||||
|
max: stream.timegapMsMaxWindow
|
||||||
|
avg: stream.timegapMsAvgWindow
|
||||||
|
showGraphs: root.showGraphs
|
||||||
|
}
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
text: "Packet Loss"
|
||||||
|
font.italic: true
|
||||||
|
}
|
||||||
|
Value {
|
||||||
|
label: "Window"
|
||||||
|
source: stream.lossRateWindow.toFixed(2) + "% (" + stream.lossCountWindow + " lost)"
|
||||||
|
}
|
||||||
|
Value {
|
||||||
|
label: "Overall"
|
||||||
|
color: "dimgrey"
|
||||||
|
source: stream.lossRate.toFixed(2) + "% (" + stream.lossCount + " lost)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
36
scripts/developer/utilities/audio/Value.qml
Normal file
36
scripts/developer/utilities/audio/Value.qml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
//
|
||||||
|
// Value.qml
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 9/22/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: value
|
||||||
|
property string label
|
||||||
|
property var source
|
||||||
|
property color color: "darkslategrey"
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
property int dataPixelWidth: 150
|
||||||
|
|
||||||
|
Label {
|
||||||
|
Layout.preferredWidth: dataPixelWidth
|
||||||
|
color: value.color
|
||||||
|
text: value.label
|
||||||
|
}
|
||||||
|
Label {
|
||||||
|
Layout.preferredWidth: 0
|
||||||
|
horizontalAlignment: Text.AlignRight
|
||||||
|
color: value.color
|
||||||
|
text: value.source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
25
scripts/developer/utilities/audio/stats.js
Normal file
25
scripts/developer/utilities/audio/stats.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// stats.js
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Zach Pomerantz, created on 9/22/2016.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
var INITIAL_WIDTH = 400;
|
||||||
|
var INITIAL_OFFSET = 50;
|
||||||
|
|
||||||
|
// Set up the qml ui
|
||||||
|
var qml = Script.resolvePath('stats.qml');
|
||||||
|
var window = new OverlayWindow({
|
||||||
|
title: 'Audio Interface Statistics',
|
||||||
|
source: qml,
|
||||||
|
width: 500, height: 520 // stats.qml may be too large for some screens
|
||||||
|
});
|
||||||
|
window.setPosition(INITIAL_OFFSET, INITIAL_OFFSET);
|
||||||
|
|
||||||
|
window.closed.connect(function() { Script.stop(); });
|
||||||
|
|
95
scripts/developer/utilities/audio/stats.qml
Normal file
95
scripts/developer/utilities/audio/stats.qml
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
//
|
||||||
|
// stats.qml
|
||||||
|
// scripts/developer/utilities/audio
|
||||||
|
//
|
||||||
|
// Created by Zach Pomerantz on 9/22/2016
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtQuick.Controls 1.4
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: stats
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
property bool showGraphs: toggleGraphs.checked
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
height: 30
|
||||||
|
|
||||||
|
Button {
|
||||||
|
id: toggleGraphs
|
||||||
|
property bool checked: false
|
||||||
|
|
||||||
|
Layout.alignment: Qt.AlignCenter
|
||||||
|
|
||||||
|
text: checked ? "Hide graphs" : "Show graphs"
|
||||||
|
onClicked: function() { checked = !checked; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid {
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height - 30
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width / 2
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
Section {
|
||||||
|
label: "Latency"
|
||||||
|
description: "Audio pipeline latency, broken out and summed"
|
||||||
|
control: ColumnLayout {
|
||||||
|
MovingValue { label: "Input Read"; source: AudioStats.inputReadMsMax; showGraphs: stats.showGraphs }
|
||||||
|
MovingValue { label: "Input Ring"; source: AudioStats.inputUnplayedMsMax; showGraphs: stats.showGraphs }
|
||||||
|
MovingValue { label: "Network (up)"; source: AudioStats.pingMs / 2; showGraphs: stats.showGraphs; decimals: 1 }
|
||||||
|
MovingValue { label: "Mixer Ring"; source: AudioStats.mixerStream.unplayedMsMax; showGraphs: stats.showGraphs }
|
||||||
|
MovingValue { label: "Network (down)"; source: AudioStats.pingMs / 2; showGraphs: stats.showGraphs; decimals: 1 }
|
||||||
|
MovingValue { label: "Output Ring"; source: AudioStats.clientStream.unplayedMsMax; showGraphs: stats.showGraphs }
|
||||||
|
MovingValue { label: "Output Read"; source: AudioStats.outputUnplayedMsMax; showGraphs: stats.showGraphs }
|
||||||
|
MovingValue { label: "TOTAL"; color: "black"; showGraphs: stats.showGraphs
|
||||||
|
source: AudioStats.inputReadMsMax +
|
||||||
|
AudioStats.inputUnplayedMsMax +
|
||||||
|
AudioStats.outputUnplayedMsMax +
|
||||||
|
AudioStats.mixerStream.unplayedMsMax +
|
||||||
|
AudioStats.clientStream.unplayedMsMax +
|
||||||
|
AudioStats.pingMs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
label: "Upstream Jitter"
|
||||||
|
description: "Timegaps in packets sent to the mixer"
|
||||||
|
control: Jitter {
|
||||||
|
max: AudioStats.sentTimegapMsMaxWindow
|
||||||
|
avg: AudioStats.sentTimegapMsAvgWindow
|
||||||
|
showGraphs: stats.showGraphs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Column {
|
||||||
|
width: parent.width / 2
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
Section {
|
||||||
|
label: "Mixer (upstream)"
|
||||||
|
description: "This client's remote audio stream, as seen by the server's mixer"
|
||||||
|
control: Stream { stream: AudioStats.mixerStream; showGraphs: stats.showGraphs }
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
label: "Client (downstream)"
|
||||||
|
description: "This client's received audio stream, between the network and the OS"
|
||||||
|
control: Stream { stream: AudioStats.clientStream; showGraphs: stats.showGraphs }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -16,14 +16,14 @@ Item {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: 100
|
height: 100
|
||||||
|
|
||||||
property int hitboxExtension : 20
|
|
||||||
|
|
||||||
// The title of the graph
|
// The title of the graph
|
||||||
property string title
|
property string title
|
||||||
|
|
||||||
// The object used as the default source object for the prop plots
|
// The object used as the default source object for the prop plots
|
||||||
property var object
|
property var object
|
||||||
|
|
||||||
|
property var backgroundOpacity: 0.6
|
||||||
|
|
||||||
// Plots is an array of plot descriptor
|
// Plots is an array of plot descriptor
|
||||||
// a default plot descriptor expects the following object:
|
// a default plot descriptor expects the following object:
|
||||||
// prop: [ {
|
// prop: [ {
|
||||||
|
@ -55,9 +55,17 @@ Item {
|
||||||
function createValues() {
|
function createValues() {
|
||||||
for (var i =0; i < plots.length; i++) {
|
for (var i =0; i < plots.length; i++) {
|
||||||
var plot = plots[i];
|
var plot = plots[i];
|
||||||
|
var object = plot["object"] || root.object;
|
||||||
|
var value = plot["prop"];
|
||||||
|
var isBinding = plot["binding"];
|
||||||
|
if (isBinding) {
|
||||||
|
object = root.parent;
|
||||||
|
value = isBinding;
|
||||||
|
}
|
||||||
_values.push( {
|
_values.push( {
|
||||||
object: (plot["object"] !== undefined ? plot["object"] : root.object),
|
object: object,
|
||||||
value: plot["prop"],
|
value: value,
|
||||||
|
fromBinding: isBinding,
|
||||||
valueMax: 1,
|
valueMax: 1,
|
||||||
numSamplesConstantMax: 0,
|
numSamplesConstantMax: 0,
|
||||||
valueHistory: new Array(),
|
valueHistory: new Array(),
|
||||||
|
@ -179,7 +187,7 @@ Item {
|
||||||
ctx.fillText(text, 0, lineHeight);
|
ctx.fillText(text, 0, lineHeight);
|
||||||
}
|
}
|
||||||
function displayBackground(ctx) {
|
function displayBackground(ctx) {
|
||||||
ctx.fillStyle = Qt.rgba(0, 0, 0, 0.6);
|
ctx.fillStyle = Qt.rgba(0, 0, 0, root.backgroundOpacity);
|
||||||
ctx.fillRect(0, 0, width, height);
|
ctx.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
ctx.strokeStyle= "grey";
|
ctx.strokeStyle= "grey";
|
||||||
|
@ -210,15 +218,9 @@ Item {
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: hitbox
|
id: hitbox
|
||||||
anchors.fill:mycanvas
|
anchors.fill: mycanvas
|
||||||
|
|
||||||
anchors.topMargin: -hitboxExtension
|
|
||||||
anchors.bottomMargin: -hitboxExtension
|
|
||||||
anchors.leftMargin: -hitboxExtension
|
|
||||||
anchors.rightMargin: -hitboxExtension
|
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
print("PerfPlot clicked!")
|
|
||||||
resetMax();
|
resetMax();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue