mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into billboard-update
Conflicts: interface/src/ui/overlays/BillboardOverlay.cpp
This commit is contained in:
commit
42bab84990
43 changed files with 361 additions and 470 deletions
|
@ -169,7 +169,9 @@ void Agent::run() {
|
|||
}
|
||||
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply *reply = networkAccessManager.get(QNetworkRequest(scriptURL));
|
||||
QNetworkRequest networkRequest = QNetworkRequest(scriptURL);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||
|
||||
QNetworkDiskCache* cache = new QNetworkDiskCache();
|
||||
QString cachePath = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
|
|
|
@ -1713,6 +1713,7 @@ bool DomainServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl &u
|
|||
.arg(authorizationCode, oauthRedirectURL().toString(), _oauthClientID, _oauthClientSecret);
|
||||
|
||||
QNetworkRequest tokenRequest(tokenRequestUrl);
|
||||
tokenRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
tokenRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
|
||||
QNetworkReply* tokenReply = NetworkAccessManager::getInstance().post(tokenRequest, tokenPostBody.toLocal8Bit());
|
||||
|
@ -1902,7 +1903,9 @@ QNetworkReply* DomainServer::profileRequestGivenTokenReply(QNetworkReply* tokenR
|
|||
profileURL.setPath("/api/v1/user/profile");
|
||||
profileURL.setQuery(QString("%1=%2").arg(OAUTH_JSON_ACCESS_TOKEN_KEY, accessToken));
|
||||
|
||||
return NetworkAccessManager::getInstance().get(QNetworkRequest(profileURL));
|
||||
QNetworkRequest profileRequest(profileURL);
|
||||
profileRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
return NetworkAccessManager::getInstance().get(profileRequest);
|
||||
}
|
||||
|
||||
const QString DS_SETTINGS_SESSIONS_GROUP = "web-sessions";
|
||||
|
|
|
@ -1047,4 +1047,3 @@ PropertiesTool = function(opts) {
|
|||
};
|
||||
|
||||
propertiesTool = PropertiesTool();
|
||||
toolBar.setActive(true);
|
||||
|
|
|
@ -83,12 +83,18 @@ if (APPLE)
|
|||
|
||||
set(MACOSX_BUNDLE_BUNDLE_NAME Interface)
|
||||
set(MACOSX_BUNDLE_GUI_IDENTIFIER io.highfidelity.Interface)
|
||||
|
||||
|
||||
if (${CMAKE_BUILD_TYPE} MATCHES "RELEASE")
|
||||
set(ICON_FILENAME "interface.icns")
|
||||
else ()
|
||||
set(ICON_FILENAME "interface-beta.icns")
|
||||
endif ()
|
||||
|
||||
# set how the icon shows up in the Info.plist file
|
||||
SET(MACOSX_BUNDLE_ICON_FILE interface.icns)
|
||||
SET(MACOSX_BUNDLE_ICON_FILE "${ICON_FILENAME}")
|
||||
|
||||
# set where in the bundle to put the resources file
|
||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/interface.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/icon/${ICON_FILENAME} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||
|
||||
# grab the directories in resources and put them in the right spot in Resources
|
||||
file(GLOB RESOURCE_SUBDIRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/resources" "${CMAKE_CURRENT_SOURCE_DIR}/resources/*")
|
||||
|
@ -101,7 +107,7 @@ if (APPLE)
|
|||
endif()
|
||||
endforeach()
|
||||
|
||||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} "${CMAKE_CURRENT_SOURCE_DIR}/interface.icns")
|
||||
SET(INTERFACE_SRCS ${INTERFACE_SRCS} "${CMAKE_CURRENT_SOURCE_DIR}/icon/${ICON_FILENAME}")
|
||||
endif()
|
||||
|
||||
# create the executable, make it a bundle on OS X
|
||||
|
|
BIN
interface/icon/interface-beta.icns
Normal file
BIN
interface/icon/interface-beta.icns
Normal file
Binary file not shown.
BIN
interface/icon/interface-beta.ico
Normal file
BIN
interface/icon/interface-beta.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
BIN
interface/icon/interface.icns
Normal file
BIN
interface/icon/interface.icns
Normal file
Binary file not shown.
BIN
interface/icon/interface.ico
Normal file
BIN
interface/icon/interface.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
Binary file not shown.
|
@ -241,8 +241,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_mousePressed(false),
|
||||
_enableProcessOctreeThread(true),
|
||||
_octreeProcessor(),
|
||||
_packetsPerSecond(0),
|
||||
_bytesPerSecond(0),
|
||||
_inPacketsPerSecond(0),
|
||||
_outPacketsPerSecond(0),
|
||||
_inBytesPerSecond(0),
|
||||
_outBytesPerSecond(0),
|
||||
_nodeBoundsDisplay(this),
|
||||
_previousScriptLocation(),
|
||||
_applicationOverlay(),
|
||||
|
@ -774,19 +776,20 @@ void Application::controlledBroadcastToNodes(const QByteArray& packet, const Nod
|
|||
int nReceivingNodes = DependencyManager::get<NodeList>()->broadcastToNodes(packet, NodeSet() << type);
|
||||
|
||||
// Feed number of bytes to corresponding channel of the bandwidth meter, if any (done otherwise)
|
||||
BandwidthMeter::ChannelIndex channel;
|
||||
double bandwidth_amount = nReceivingNodes * packet.size();
|
||||
switch (type) {
|
||||
case NodeType::Agent:
|
||||
case NodeType::AvatarMixer:
|
||||
channel = BandwidthMeter::AVATARS;
|
||||
_bandwidthRecorder.avatarsChannel->output.updateValue(bandwidth_amount);
|
||||
_bandwidthRecorder.totalChannel->input.updateValue(bandwidth_amount);
|
||||
break;
|
||||
case NodeType::EntityServer:
|
||||
channel = BandwidthMeter::OCTREE;
|
||||
_bandwidthRecorder.octreeChannel->output.updateValue(bandwidth_amount);
|
||||
_bandwidthRecorder.totalChannel->output.updateValue(bandwidth_amount);
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
_bandwidthMeter.outputStream(channel).updateValue(nReceivingNodes * packet.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1261,7 +1264,6 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
|||
int horizontalOffset = MIRROR_VIEW_WIDTH;
|
||||
Stats::getInstance()->checkClick(getMouseX(), getMouseY(),
|
||||
getMouseDragStartedX(), getMouseDragStartedY(), horizontalOffset);
|
||||
checkBandwidthMeterClick();
|
||||
}
|
||||
|
||||
// fire an action end event
|
||||
|
@ -1389,8 +1391,10 @@ void Application::timer() {
|
|||
|
||||
_fps = (float)_frameCount / diffTime;
|
||||
|
||||
_packetsPerSecond = (float) _datagramProcessor.getPacketCount() / diffTime;
|
||||
_bytesPerSecond = (float) _datagramProcessor.getByteCount() / diffTime;
|
||||
_inPacketsPerSecond = (float) _datagramProcessor.getInPacketCount() / diffTime;
|
||||
_outPacketsPerSecond = (float) _datagramProcessor.getOutPacketCount() / diffTime;
|
||||
_inBytesPerSecond = (float) _datagramProcessor.getInByteCount() / diffTime;
|
||||
_outBytesPerSecond = (float) _datagramProcessor.getOutByteCount() / diffTime;
|
||||
_frameCount = 0;
|
||||
|
||||
_datagramProcessor.resetCounters();
|
||||
|
@ -1448,23 +1452,6 @@ void Application::idle() {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::checkBandwidthMeterClick() {
|
||||
// ... to be called upon button release
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth) &&
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::UserInterface) &&
|
||||
glm::compMax(glm::abs(glm::ivec2(getMouseX() - getMouseDragStartedX(),
|
||||
getMouseY() - getMouseDragStartedY())))
|
||||
<= BANDWIDTH_METER_CLICK_MAX_DRAG_LENGTH
|
||||
&& _bandwidthMeter.isWithinArea(getMouseX(), getMouseY(), glCanvas->width(), glCanvas->height())) {
|
||||
|
||||
// The bandwidth meter is visible, the click didn't get dragged too far and
|
||||
// we actually hit the bandwidth meter
|
||||
DependencyManager::get<DialogsManager>()->bandwidthDetails();
|
||||
}
|
||||
}
|
||||
|
||||
void Application::setFullscreen(bool fullscreen) {
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Fullscreen) != fullscreen) {
|
||||
Menu::getInstance()->getActionForOption(MenuOption::Fullscreen)->setChecked(fullscreen);
|
||||
|
@ -2398,7 +2385,8 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
nodeList->writeUnverifiedDatagram(reinterpret_cast<const char*>(queryPacket), packetLength, node);
|
||||
|
||||
// Feed number of bytes to corresponding channel of the bandwidth meter
|
||||
_bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(packetLength);
|
||||
_bandwidthRecorder.octreeChannel->output.updateValue(packetLength);
|
||||
_bandwidthRecorder.totalChannel->output.updateValue(packetLength);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3386,7 +3374,8 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin
|
|||
}
|
||||
|
||||
void Application::packetSent(quint64 length) {
|
||||
_bandwidthMeter.outputStream(BandwidthMeter::OCTREE).updateValue(length);
|
||||
_bandwidthRecorder.octreeChannel->output.updateValue(length);
|
||||
_bandwidthRecorder.totalChannel->output.updateValue(length);
|
||||
}
|
||||
|
||||
const QString SETTINGS_KEY = "Settings";
|
||||
|
@ -3796,6 +3785,7 @@ void Application::initAvatarAndViewFrustum() {
|
|||
|
||||
void Application::checkVersion() {
|
||||
QNetworkRequest latestVersionRequest((QUrl(CHECK_VERSION_URL)));
|
||||
latestVersionRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().get(latestVersionRequest);
|
||||
connect(reply, SIGNAL(finished()), SLOT(parseVersionXml()));
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include "devices/SixenseManager.h"
|
||||
#include "scripting/ControllerScriptingInterface.h"
|
||||
#include "ui/BandwidthDialog.h"
|
||||
#include "ui/BandwidthMeter.h"
|
||||
#include "ui/HMDToolsDialog.h"
|
||||
#include "ui/ModelsBrowser.h"
|
||||
#include "ui/NodeBounds.h"
|
||||
|
@ -183,7 +182,6 @@ public:
|
|||
QUndoStack* getUndoStack() { return &_undoStack; }
|
||||
MainWindow* getWindow() { return _window; }
|
||||
OctreeQuery& getOctreeQuery() { return _octreeQuery; }
|
||||
|
||||
EntityTree* getEntityClipboard() { return &_entityClipboard; }
|
||||
EntityTreeRenderer* getEntityClipboardRenderer() { return &_entityClipboardRenderer; }
|
||||
|
||||
|
@ -204,14 +202,16 @@ public:
|
|||
bool getLastMouseMoveWasSimulated() const { return _lastMouseMoveWasSimulated; }
|
||||
|
||||
FaceTracker* getActiveFaceTracker();
|
||||
BandwidthMeter* getBandwidthMeter() { return &_bandwidthMeter; }
|
||||
BandwidthRecorder* getBandwidthRecorder() { return &_bandwidthRecorder; }
|
||||
QSystemTrayIcon* getTrayIcon() { return _trayIcon; }
|
||||
ApplicationOverlay& getApplicationOverlay() { return _applicationOverlay; }
|
||||
Overlays& getOverlays() { return _overlays; }
|
||||
|
||||
float getFps() const { return _fps; }
|
||||
float getPacketsPerSecond() const { return _packetsPerSecond; }
|
||||
float getBytesPerSecond() const { return _bytesPerSecond; }
|
||||
float getInPacketsPerSecond() const { return _inPacketsPerSecond; }
|
||||
float getOutPacketsPerSecond() const { return _outPacketsPerSecond; }
|
||||
float getInBytesPerSecond() const { return _inBytesPerSecond; }
|
||||
float getOutBytesPerSecond() const { return _outBytesPerSecond; }
|
||||
const glm::vec3& getViewMatrixTranslation() const { return _viewMatrixTranslation; }
|
||||
void setViewMatrixTranslation(const glm::vec3& translation) { _viewMatrixTranslation = translation; }
|
||||
|
||||
|
@ -435,7 +435,6 @@ private:
|
|||
|
||||
void updateShadowMap();
|
||||
void renderRearViewMirror(const QRect& region, bool billboard = false);
|
||||
void checkBandwidthMeterClick();
|
||||
void setMenuShortcutsEnabled(bool enabled);
|
||||
|
||||
static void attachNewHeadToNode(Node *newNode);
|
||||
|
@ -448,7 +447,6 @@ private:
|
|||
|
||||
ToolWindow* _toolWindow;
|
||||
|
||||
BandwidthMeter _bandwidthMeter;
|
||||
|
||||
QThread* _nodeThread;
|
||||
DatagramProcessor _datagramProcessor;
|
||||
|
@ -486,6 +484,9 @@ private:
|
|||
|
||||
OctreeQuery _octreeQuery; // NodeData derived class for querying octee cells from octree servers
|
||||
|
||||
BandwidthRecorder _bandwidthRecorder;
|
||||
|
||||
|
||||
AvatarManager _avatarManager;
|
||||
MyAvatar* _myAvatar; // TODO: move this and relevant code to AvatarManager (or MyAvatar as the case may be)
|
||||
|
||||
|
@ -534,8 +535,10 @@ private:
|
|||
OctreePacketProcessor _octreeProcessor;
|
||||
EntityEditPacketSender _entityEditSender;
|
||||
|
||||
int _packetsPerSecond;
|
||||
int _bytesPerSecond;
|
||||
int _inPacketsPerSecond;
|
||||
int _outPacketsPerSecond;
|
||||
int _inBytesPerSecond;
|
||||
int _outBytesPerSecond;
|
||||
|
||||
StDev _idleLoopStdev;
|
||||
float _idleLoopMeasuredJitter;
|
||||
|
|
|
@ -769,8 +769,8 @@ void Audio::handleAudioInput() {
|
|||
nodeList->writeDatagram(audioDataPacket, packetBytes, audioMixer);
|
||||
_outgoingAvatarAudioSequenceNumber++;
|
||||
|
||||
Application::getInstance()->getBandwidthMeter()->outputStream(BandwidthMeter::AUDIO)
|
||||
.updateValue(packetBytes);
|
||||
Application::getInstance()->getBandwidthRecorder()->audioChannel->output.updateValue(packetBytes);
|
||||
Application::getInstance()->getBandwidthRecorder()->totalChannel->output.updateValue(packetBytes);
|
||||
}
|
||||
delete[] inputAudioSamples;
|
||||
}
|
||||
|
@ -829,7 +829,8 @@ void Audio::addReceivedAudioToStream(const QByteArray& audioByteArray) {
|
|||
_receivedAudioStream.parseData(audioByteArray);
|
||||
}
|
||||
|
||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::AUDIO).updateValue(audioByteArray.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->audioChannel->input.updateValue(audioByteArray.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->totalChannel->input.updateValue(audioByteArray.size());
|
||||
}
|
||||
|
||||
void Audio::parseAudioEnvironmentData(const QByteArray &packet) {
|
||||
|
|
64
interface/src/BandwidthRecorder.cpp
Normal file
64
interface/src/BandwidthRecorder.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
//
|
||||
// BandwidthMeter.cpp
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Seth Alves on 2015-1-30
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Based on code by Tobias Schwinger
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <GeometryCache.h>
|
||||
#include "BandwidthRecorder.h"
|
||||
|
||||
|
||||
BandwidthRecorder::Channel::Channel(char const* const caption,
|
||||
char const* unitCaption,
|
||||
double unitScale,
|
||||
unsigned colorRGBA) :
|
||||
caption(caption),
|
||||
unitCaption(unitCaption),
|
||||
unitScale(unitScale),
|
||||
colorRGBA(colorRGBA)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
BandwidthRecorder::BandwidthRecorder() {
|
||||
}
|
||||
|
||||
|
||||
BandwidthRecorder::~BandwidthRecorder() {
|
||||
delete audioChannel;
|
||||
delete avatarsChannel;
|
||||
delete octreeChannel;
|
||||
delete metavoxelsChannel;
|
||||
delete totalChannel;
|
||||
}
|
||||
|
||||
|
||||
BandwidthRecorder::Stream::Stream(float msToAverage) : _value(0.0f), _msToAverage(msToAverage) {
|
||||
_prevTime.start();
|
||||
}
|
||||
|
||||
|
||||
void BandwidthRecorder::Stream::updateValue(double amount) {
|
||||
|
||||
// Determine elapsed time
|
||||
double dt = (double)_prevTime.nsecsElapsed() / 1000000.0; // ns to ms
|
||||
|
||||
// Ignore this value when timer imprecision yields dt = 0
|
||||
if (dt == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_prevTime.start();
|
||||
|
||||
// Compute approximate average
|
||||
_value = glm::mix(_value, amount / dt,
|
||||
glm::clamp(dt / _msToAverage, 0.0, 1.0));
|
||||
}
|
56
interface/src/BandwidthRecorder.h
Normal file
56
interface/src/BandwidthRecorder.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
//
|
||||
// BandwidthRecorder.h
|
||||
//
|
||||
// Created by Seth Alves on 2015-1-30
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Based on code by Tobias Schwinger
|
||||
//
|
||||
// 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_BandwidthRecorder_h
|
||||
#define hifi_BandwidthRecorder_h
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
class BandwidthRecorder {
|
||||
public:
|
||||
BandwidthRecorder();
|
||||
~BandwidthRecorder();
|
||||
|
||||
// keep track of data rate in one direction
|
||||
class Stream {
|
||||
public:
|
||||
Stream(float msToAverage = 3000.0f);
|
||||
void updateValue(double amount);
|
||||
double getValue() const { return _value; }
|
||||
private:
|
||||
double _value; // Current value.
|
||||
double _msToAverage; // Milliseconds to average.
|
||||
QElapsedTimer _prevTime; // Time of last feed.
|
||||
};
|
||||
|
||||
// keep track of data rate in two directions as well as units and style to use during display
|
||||
class Channel {
|
||||
public:
|
||||
Channel(char const* const caption, char const* unitCaption, double unitScale, unsigned colorRGBA);
|
||||
Stream input;
|
||||
Stream output;
|
||||
char const* const caption;
|
||||
char const* unitCaption;
|
||||
double unitScale;
|
||||
unsigned colorRGBA;
|
||||
};
|
||||
|
||||
// create the channels we keep track of
|
||||
Channel* audioChannel = new Channel("Audio", "Kbps", 8000.0 / 1024.0, 0x33cc99ff);
|
||||
Channel* avatarsChannel = new Channel("Avatars", "Kbps", 8000.0 / 1024.0, 0xffef40c0);
|
||||
Channel* octreeChannel = new Channel("Octree", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0);
|
||||
Channel* metavoxelsChannel = new Channel("Metavoxels", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0);
|
||||
Channel* totalChannel = new Channel("Total", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -42,8 +42,8 @@ void DatagramProcessor::processDatagrams() {
|
|||
nodeList->getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(),
|
||||
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||
|
||||
_packetCount++;
|
||||
_byteCount += incomingPacket.size();
|
||||
_inPacketCount++;
|
||||
_inByteCount += incomingPacket.size();
|
||||
|
||||
if (nodeList->packetVersionAndHashMatch(incomingPacket)) {
|
||||
|
||||
|
@ -82,6 +82,8 @@ void DatagramProcessor::processDatagrams() {
|
|||
// this will keep creatorTokenIDs to IDs mapped correctly
|
||||
EntityItemID::handleAddEntityResponse(incomingPacket);
|
||||
application->getEntities()->getTree()->handleAddEntityResponse(incomingPacket);
|
||||
application->_bandwidthRecorder.octreeChannel->input.updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.totalChannel->input.updateValue(incomingPacket.size());
|
||||
break;
|
||||
case PacketTypeEntityData:
|
||||
case PacketTypeEntityErase:
|
||||
|
@ -95,7 +97,8 @@ void DatagramProcessor::processDatagrams() {
|
|||
// add this packet to our list of octree packets and process them on the octree data processing
|
||||
application->_octreeProcessor.queueReceivedPacket(matchedNode, incomingPacket);
|
||||
}
|
||||
|
||||
application->_bandwidthRecorder.octreeChannel->input.updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.totalChannel->input.updateValue(incomingPacket.size());
|
||||
break;
|
||||
}
|
||||
case PacketTypeMetavoxelData:
|
||||
|
@ -117,7 +120,8 @@ void DatagramProcessor::processDatagrams() {
|
|||
Q_ARG(const QWeakPointer<Node>&, avatarMixer));
|
||||
}
|
||||
|
||||
application->_bandwidthMeter.inputStream(BandwidthMeter::AVATARS).updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.avatarsChannel->input.updateValue(incomingPacket.size());
|
||||
application->_bandwidthRecorder.totalChannel->input.updateValue(incomingPacket.size());
|
||||
break;
|
||||
}
|
||||
case PacketTypeDomainConnectionDenied: {
|
||||
|
|
|
@ -19,16 +19,20 @@ class DatagramProcessor : public QObject {
|
|||
public:
|
||||
DatagramProcessor(QObject* parent = 0);
|
||||
|
||||
int getPacketCount() const { return _packetCount; }
|
||||
int getByteCount() const { return _byteCount; }
|
||||
int getInPacketCount() const { return _inPacketCount; }
|
||||
int getOutPacketCount() const { return _outPacketCount; }
|
||||
int getInByteCount() const { return _inByteCount; }
|
||||
int getOutByteCount() const { return _outByteCount; }
|
||||
|
||||
void resetCounters() { _packetCount = 0; _byteCount = 0; }
|
||||
void resetCounters() { _inPacketCount = 0; _outPacketCount = 0; _inByteCount = 0; _outByteCount = 0; }
|
||||
public slots:
|
||||
void processDatagrams();
|
||||
|
||||
private:
|
||||
int _packetCount;
|
||||
int _byteCount;
|
||||
int _inPacketCount;
|
||||
int _outPacketCount;
|
||||
int _inByteCount;
|
||||
int _outByteCount;
|
||||
};
|
||||
|
||||
#endif // hifi_DatagramProcessor_h
|
||||
|
|
|
@ -282,7 +282,6 @@ Menu::Menu() {
|
|||
addDisabledActionAndSeparator(viewMenu, "Stats");
|
||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Stats, Qt::Key_Percent);
|
||||
addActionToQMenuAndActionHash(viewMenu, MenuOption::Log, Qt::CTRL | Qt::Key_L, qApp, SLOT(toggleLogDialog()));
|
||||
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Bandwidth, 0, true);
|
||||
addActionToQMenuAndActionHash(viewMenu, MenuOption::BandwidthDetails, 0,
|
||||
dialogsManager.data(), SLOT(bandwidthDetails()));
|
||||
addActionToQMenuAndActionHash(viewMenu, MenuOption::OctreeStats, 0,
|
||||
|
|
|
@ -120,7 +120,6 @@ namespace MenuOption {
|
|||
const QString AudioSourcePinkNoise = "Pink Noise";
|
||||
const QString AudioSourceSine440 = "Sine 440hz";
|
||||
const QString Avatars = "Avatars";
|
||||
const QString Bandwidth = "Bandwidth Display";
|
||||
const QString BandwidthDetails = "Bandwidth Details";
|
||||
const QString BlueSpeechSphere = "Blue Sphere While Speaking";
|
||||
const QString BookmarkLocation = "Bookmark Location";
|
||||
|
|
|
@ -899,7 +899,8 @@ int MetavoxelSystemClient::parseData(const QByteArray& packet) {
|
|||
} else {
|
||||
QMetaObject::invokeMethod(&_sequencer, "receivedDatagram", Q_ARG(const QByteArray&, packet));
|
||||
}
|
||||
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::METAVOXELS).updateValue(packet.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->metavoxelsChannel->input.updateValue(packet.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->totalChannel->input.updateValue(packet.size());
|
||||
}
|
||||
return packet.size();
|
||||
}
|
||||
|
@ -1015,7 +1016,8 @@ void MetavoxelSystemClient::sendDatagram(const QByteArray& data) {
|
|||
} else {
|
||||
DependencyManager::get<NodeList>()->writeDatagram(data, _node);
|
||||
}
|
||||
Application::getInstance()->getBandwidthMeter()->outputStream(BandwidthMeter::METAVOXELS).updateValue(data.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->metavoxelsChannel->output.updateValue(data.size());
|
||||
Application::getInstance()->getBandwidthRecorder()->totalChannel->output.updateValue(data.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -494,6 +494,7 @@ void ModelUploader::uploadFailed(QNetworkReply& errorReply) {
|
|||
void ModelUploader::checkS3() {
|
||||
qDebug() << "Checking S3 for " << _url;
|
||||
QNetworkRequest request(_url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().head(request);
|
||||
connect(reply, SIGNAL(finished()), SLOT(processCheck()));
|
||||
}
|
||||
|
|
|
@ -166,6 +166,7 @@ void ScriptsModel::requestRemoteFiles(QString marker) {
|
|||
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkRequest request(url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(request);
|
||||
connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||
}
|
||||
|
|
|
@ -907,7 +907,6 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
|||
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
const OctreePacketProcessor& octreePacketProcessor = application->getOctreePacketProcessor();
|
||||
BandwidthMeter* bandwidthMeter = application->getBandwidthMeter();
|
||||
NodeBounds& nodeBoundsDisplay = application->getNodeBoundsDisplay();
|
||||
|
||||
// Display stats and log text onscreen
|
||||
|
@ -920,12 +919,11 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
|||
int voxelPacketsToProcess = octreePacketProcessor.packetsToProcessCount();
|
||||
// Onscreen text about position, servers, etc
|
||||
Stats::getInstance()->display(WHITE_TEXT, horizontalOffset, application->getFps(),
|
||||
application->getPacketsPerSecond(), application->getBytesPerSecond(), voxelPacketsToProcess);
|
||||
// Bandwidth meter
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth)) {
|
||||
Stats::drawBackground(0x33333399, glCanvas->width() - 296, glCanvas->height() - 68, 296, 68);
|
||||
bandwidthMeter->render(glCanvas->width(), glCanvas->height());
|
||||
}
|
||||
application->getInPacketsPerSecond(),
|
||||
application->getOutPacketsPerSecond(),
|
||||
application->getInBytesPerSecond(),
|
||||
application->getOutBytesPerSecond(),
|
||||
voxelPacketsToProcess);
|
||||
}
|
||||
|
||||
// Show on-screen msec timer
|
||||
|
@ -934,8 +932,7 @@ void ApplicationOverlay::renderStatsAndLogs() {
|
|||
quint64 mSecsNow = floor(usecTimestampNow() / 1000.0 + 0.5);
|
||||
sprintf(frameTimer, "%d\n", (int)(mSecsNow % 1000));
|
||||
int timerBottom =
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
|
||||
Menu::getInstance()->isOptionChecked(MenuOption::Bandwidth))
|
||||
(Menu::getInstance()->isOptionChecked(MenuOption::Stats))
|
||||
? 80 : 20;
|
||||
drawText(glCanvas->width() - 100, glCanvas->height() - timerBottom,
|
||||
0.30f, 0.0f, 0, frameTimer, WHITE_TEXT);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
#include "BandwidthRecorder.h"
|
||||
#include "ui/BandwidthDialog.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
|
@ -19,56 +20,73 @@
|
|||
#include <QPalette>
|
||||
#include <QColor>
|
||||
|
||||
BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthMeter* model) :
|
||||
|
||||
BandwidthDialog::ChannelDisplay::ChannelDisplay(BandwidthRecorder::Channel *ch, QFormLayout* form) {
|
||||
this->ch = ch;
|
||||
this->label = setupLabel(form);
|
||||
}
|
||||
|
||||
|
||||
QLabel* BandwidthDialog::ChannelDisplay::setupLabel(QFormLayout* form) {
|
||||
QLabel* label = new QLabel();
|
||||
|
||||
label->setAlignment(Qt::AlignRight);
|
||||
|
||||
QPalette palette = label->palette();
|
||||
unsigned rgb = ch->colorRGBA >> 8;
|
||||
rgb = ((rgb & 0xfefefeu) >> 1) + ((rgb & 0xf8f8f8) >> 3);
|
||||
palette.setColor(QPalette::WindowText, QColor::fromRgb(rgb));
|
||||
label->setPalette(palette);
|
||||
|
||||
form->addRow((std::string(" ") + ch->caption + " Bandwidth In/Out:").c_str(), label);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void BandwidthDialog::ChannelDisplay::setLabelText() {
|
||||
std::string strBuf =
|
||||
std::to_string ((int) (ch->input.getValue() * ch->unitScale)) + "/" +
|
||||
std::to_string ((int) (ch->output.getValue() * ch->unitScale)) + " " + ch->unitCaption;
|
||||
label->setText(strBuf.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
BandwidthDialog::BandwidthDialog(QWidget* parent, BandwidthRecorder* model) :
|
||||
QDialog(parent, Qt::Window | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint),
|
||||
_model(model) {
|
||||
|
||||
char strBuf[64];
|
||||
|
||||
this->setWindowTitle("Bandwidth Details");
|
||||
|
||||
// Create layouter
|
||||
QFormLayout* form = new QFormLayout();
|
||||
this->QDialog::setLayout(form);
|
||||
|
||||
// Setup labels
|
||||
for (size_t i = 0; i < BandwidthMeter::N_STREAMS; ++i) {
|
||||
bool input = i % 2 == 0;
|
||||
BandwidthMeter::ChannelInfo& ch = _model->channelInfo(BandwidthMeter::ChannelIndex(i / 2));
|
||||
QLabel* label = _labels[i] = new QLabel();
|
||||
label->setAlignment(Qt::AlignRight);
|
||||
|
||||
// Set foreground color to 62.5% brightness of the meter (otherwise will be hard to read on the bright background)
|
||||
QPalette palette = label->palette();
|
||||
unsigned rgb = ch.colorRGBA >> 8;
|
||||
rgb = ((rgb & 0xfefefeu) >> 1) + ((rgb & 0xf8f8f8) >> 3);
|
||||
palette.setColor(QPalette::WindowText, QColor::fromRgb(rgb));
|
||||
label->setPalette(palette);
|
||||
|
||||
snprintf(strBuf, sizeof(strBuf), " %s %s Bandwidth:", input ? "Input" : "Output", ch.caption);
|
||||
form->addRow(strBuf, label);
|
||||
}
|
||||
audioChannelDisplay = new ChannelDisplay(_model->audioChannel, form);
|
||||
avatarsChannelDisplay = new ChannelDisplay(_model->avatarsChannel, form);
|
||||
octreeChannelDisplay = new ChannelDisplay(_model->octreeChannel, form);
|
||||
metavoxelsChannelDisplay = new ChannelDisplay(_model->metavoxelsChannel, form);
|
||||
totalChannelDisplay = new ChannelDisplay(_model->totalChannel, form);
|
||||
}
|
||||
|
||||
|
||||
BandwidthDialog::~BandwidthDialog() {
|
||||
for (size_t i = 0; i < BandwidthMeter::N_STREAMS; ++i) {
|
||||
delete _labels[i];
|
||||
}
|
||||
delete audioChannelDisplay;
|
||||
delete avatarsChannelDisplay;
|
||||
delete octreeChannelDisplay;
|
||||
delete metavoxelsChannelDisplay;
|
||||
delete totalChannelDisplay;
|
||||
}
|
||||
|
||||
void BandwidthDialog::paintEvent(QPaintEvent* event) {
|
||||
|
||||
// Update labels
|
||||
char strBuf[64];
|
||||
for (size_t i = 0; i < BandwidthMeter::N_STREAMS; ++i) {
|
||||
BandwidthMeter::ChannelIndex chIdx = BandwidthMeter::ChannelIndex(i / 2);
|
||||
bool input = i % 2 == 0;
|
||||
BandwidthMeter::ChannelInfo& ch = _model->channelInfo(chIdx);
|
||||
BandwidthMeter::Stream& s = input ? _model->inputStream(chIdx) : _model->outputStream(chIdx);
|
||||
QLabel* label = _labels[i];
|
||||
snprintf(strBuf, sizeof(strBuf), "%0.2f %s", s.getValue() * ch.unitScale, ch.unitCaption);
|
||||
label->setText(strBuf);
|
||||
}
|
||||
void BandwidthDialog::paintEvent(QPaintEvent* event) {
|
||||
audioChannelDisplay->setLabelText();
|
||||
avatarsChannelDisplay->setLabelText();
|
||||
octreeChannelDisplay->setLabelText();
|
||||
metavoxelsChannelDisplay->setLabelText();
|
||||
totalChannelDisplay->setLabelText();
|
||||
|
||||
this->QDialog::paintEvent(event);
|
||||
this->setFixedSize(this->width(), this->height());
|
||||
|
|
|
@ -14,17 +14,38 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QFormLayout>
|
||||
|
||||
#include "BandwidthMeter.h"
|
||||
#include "BandwidthRecorder.h"
|
||||
|
||||
|
||||
class BandwidthDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Sets up the UI based on the configuration of the BandwidthMeter
|
||||
BandwidthDialog(QWidget* parent, BandwidthMeter* model);
|
||||
// Sets up the UI based on the configuration of the BandwidthRecorder
|
||||
BandwidthDialog(QWidget* parent, BandwidthRecorder* model);
|
||||
~BandwidthDialog();
|
||||
|
||||
class ChannelDisplay {
|
||||
public:
|
||||
ChannelDisplay(BandwidthRecorder::Channel *ch, QFormLayout* form);
|
||||
QLabel* setupLabel(QFormLayout* form);
|
||||
void setLabelText();
|
||||
|
||||
private:
|
||||
BandwidthRecorder::Channel *ch;
|
||||
|
||||
QLabel* label;
|
||||
};
|
||||
|
||||
ChannelDisplay* audioChannelDisplay;
|
||||
ChannelDisplay* avatarsChannelDisplay;
|
||||
ChannelDisplay* octreeChannelDisplay;
|
||||
ChannelDisplay* metavoxelsChannelDisplay;
|
||||
|
||||
// sums of all the other channels
|
||||
ChannelDisplay* totalChannelDisplay;
|
||||
|
||||
signals:
|
||||
|
||||
void closed();
|
||||
|
@ -34,16 +55,13 @@ public slots:
|
|||
void reject();
|
||||
|
||||
protected:
|
||||
|
||||
// State <- data model held by BandwidthMeter
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
// Emits a 'closed' signal when this dialog is closed.
|
||||
void closeEvent(QCloseEvent*);
|
||||
|
||||
private:
|
||||
BandwidthMeter* _model;
|
||||
QLabel* _labels[BandwidthMeter::N_STREAMS];
|
||||
BandwidthRecorder* _model;
|
||||
};
|
||||
|
||||
#endif // hifi_BandwidthDialog_h
|
||||
|
|
|
@ -1,241 +0,0 @@
|
|||
//
|
||||
// BandwidthMeter.cpp
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Tobias Schwinger on 6/20/13.
|
||||
// Copyright 2013 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 <cstdio>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
|
||||
#include "BandwidthMeter.h"
|
||||
#include "InterfaceConfig.h"
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
namespace { // .cpp-local
|
||||
|
||||
int const AREA_WIDTH = -280; // Width of the area used. Aligned to the right when negative.
|
||||
int const AREA_HEIGHT = -40; // Height of the area used. Aligned to the bottom when negative.
|
||||
int const BORDER_DISTANCE_HORIZ = -10; // Distance to edge of screen (use negative value when width is negative).
|
||||
int const BORDER_DISTANCE_VERT = -15; // Distance to edge of screen (use negative value when height is negative).
|
||||
|
||||
int SPACING_VERT_BARS = 2; // Vertical distance between input and output bar
|
||||
int SPACING_RIGHT_CAPTION_IN_OUT = 4; // IN/OUT <--> |######## : |
|
||||
int SPACING_LEFT_CAPTION_UNIT = 4; // |######## : | <--> UNIT
|
||||
int PADDING_HORIZ_VALUE = 2; // |<-->X.XX<:-># |
|
||||
|
||||
unsigned const COLOR_TEXT = 0xedededff; // ^ ^ ^ ^ ^ ^
|
||||
unsigned const COLOR_FRAME = 0xe0e0e0b0; // | | |
|
||||
unsigned const COLOR_INDICATOR = 0xc0c0c0b0; // |
|
||||
|
||||
char const* CAPTION_IN = "In";
|
||||
char const* CAPTION_OUT = "Out";
|
||||
char const* CAPTION_UNIT = "Mbps";
|
||||
|
||||
double const UNIT_SCALE = 8000.0 / (1024.0 * 1024.0); // Bytes/ms -> Mbps
|
||||
int const INITIAL_SCALE_MAXIMUM_INDEX = 250; // / 9: exponent, % 9: mantissa - 2, 0 o--o 2 * 10^-10
|
||||
int const MIN_METER_SCALE = 10; // 10Mbps
|
||||
int const NUMBER_OF_MARKERS = 10;
|
||||
}
|
||||
|
||||
BandwidthMeter::ChannelInfo BandwidthMeter::_CHANNELS[] = {
|
||||
{ "Audio" , "Kbps", 8000.0 / 1024.0, 0x33cc99ff },
|
||||
{ "Avatars" , "Kbps", 8000.0 / 1024.0, 0xffef40c0 },
|
||||
{ "Octree" , "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0 },
|
||||
{ "Metavoxels", "Kbps", 8000.0 / 1024.0, 0xd0d0d0a0 }
|
||||
};
|
||||
|
||||
BandwidthMeter::BandwidthMeter() :
|
||||
_textRenderer(TextRenderer::getInstance(INCONSOLATA_FONT_FAMILY, -1, INCONSOLATA_FONT_WEIGHT, false)),
|
||||
_scaleMaxIndex(INITIAL_SCALE_MAXIMUM_INDEX) {
|
||||
|
||||
_channels = static_cast<ChannelInfo*>( malloc(sizeof(_CHANNELS)) );
|
||||
memcpy(_channels, _CHANNELS, sizeof(_CHANNELS));
|
||||
}
|
||||
|
||||
BandwidthMeter::~BandwidthMeter() {
|
||||
|
||||
free(_channels);
|
||||
}
|
||||
|
||||
BandwidthMeter::Stream::Stream(float msToAverage) : _value(0.0f), _msToAverage(msToAverage) {
|
||||
_prevTime.start();
|
||||
}
|
||||
|
||||
void BandwidthMeter::Stream::updateValue(double amount) {
|
||||
|
||||
// Determine elapsed time
|
||||
double dt = (double)_prevTime.nsecsElapsed() / 1000000.0; // ns to ms
|
||||
|
||||
// Ignore this value when timer imprecision yields dt = 0
|
||||
if (dt == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
_prevTime.start();
|
||||
|
||||
// Compute approximate average
|
||||
_value = glm::mix(_value, amount / dt,
|
||||
glm::clamp(dt / _msToAverage, 0.0, 1.0));
|
||||
}
|
||||
|
||||
glm::vec4 BandwidthMeter::getColorRGBA(unsigned c) {
|
||||
|
||||
float r = (c >> 24) / 255.0f;
|
||||
float g = ((c >> 16) & 0xff) / 255.0f;
|
||||
float b = ((c >> 8) & 0xff) / 255.0f;
|
||||
float a = (c & 0xff) / 255.0f;
|
||||
return glm::vec4(r,g,b,a);
|
||||
}
|
||||
|
||||
void BandwidthMeter::renderBox(int x, int y, int w, int h, unsigned c) {
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(x, y, w, h, getColorRGBA(c));
|
||||
}
|
||||
|
||||
void BandwidthMeter::renderVerticalLine(int x, int y, int h, unsigned c) {
|
||||
DependencyManager::get<GeometryCache>()->renderLine(glm::vec2(x, y), glm::vec2(x, y + h), getColorRGBA(c));
|
||||
}
|
||||
|
||||
inline int BandwidthMeter::centered(int subject, int object) {
|
||||
return (object - subject) / 2;
|
||||
}
|
||||
|
||||
bool BandwidthMeter::isWithinArea(int x, int y, int screenWidth, int screenHeight) {
|
||||
|
||||
int minX = BORDER_DISTANCE_HORIZ + (AREA_WIDTH >= 0 ? 0 : screenWidth + AREA_WIDTH);
|
||||
int minY = BORDER_DISTANCE_VERT + (AREA_HEIGHT >= 0 ? 0 : screenHeight + AREA_HEIGHT);
|
||||
|
||||
return x >= minX && x < minX + glm::abs(AREA_WIDTH) &&
|
||||
y >= minY && y < minY + glm::abs(AREA_HEIGHT);
|
||||
}
|
||||
|
||||
void BandwidthMeter::render(int screenWidth, int screenHeight) {
|
||||
|
||||
int x = BORDER_DISTANCE_HORIZ + (AREA_WIDTH >= 0 ? 0 : screenWidth + AREA_WIDTH);
|
||||
int y = BORDER_DISTANCE_VERT + (AREA_HEIGHT >= 0 ? 0 : screenHeight + AREA_HEIGHT);
|
||||
int w = glm::abs(AREA_WIDTH), h = glm::abs(AREA_HEIGHT);
|
||||
|
||||
// Determine total
|
||||
float totalIn = 0.0f, totalOut = 0.0f;
|
||||
for (size_t i = 0; i < N_CHANNELS; ++i) {
|
||||
|
||||
totalIn += inputStream(ChannelIndex(i)).getValue();
|
||||
totalOut += outputStream(ChannelIndex(i)).getValue();
|
||||
}
|
||||
totalIn *= UNIT_SCALE;
|
||||
totalOut *= UNIT_SCALE;
|
||||
float totalMax = glm::max(totalIn, totalOut);
|
||||
|
||||
// Get font / caption metrics
|
||||
QFontMetrics const& fontMetrics = _textRenderer->metrics();
|
||||
int fontDescent = fontMetrics.descent();
|
||||
int labelWidthIn = fontMetrics.width(CAPTION_IN);
|
||||
int labelWidthOut = fontMetrics.width(CAPTION_OUT);
|
||||
int labelWidthInOut = glm::max(labelWidthIn, labelWidthOut);
|
||||
int labelHeight = fontMetrics.ascent() + fontDescent;
|
||||
int labelWidthUnit = fontMetrics.width(CAPTION_UNIT);
|
||||
int labelsWidth = labelWidthInOut + SPACING_RIGHT_CAPTION_IN_OUT + SPACING_LEFT_CAPTION_UNIT + labelWidthUnit;
|
||||
|
||||
// Calculate coordinates and dimensions
|
||||
int barX = x + labelWidthInOut + SPACING_RIGHT_CAPTION_IN_OUT;
|
||||
int barWidth = w - labelsWidth;
|
||||
int barHeight = (h - SPACING_VERT_BARS) / 2;
|
||||
int textYcenteredLine = h - centered(labelHeight, h) - fontDescent;
|
||||
int textYupperLine = barHeight - centered(labelHeight, barHeight) - fontDescent;
|
||||
int textYlowerLine = h - centered(labelHeight, barHeight) - fontDescent;
|
||||
|
||||
// Center of coordinate system -> upper left of bar
|
||||
glPushMatrix();
|
||||
glTranslatef((float)barX, (float)y, 0.0f);
|
||||
|
||||
// Render captions
|
||||
glm::vec4 textColor = getColorRGBA(COLOR_TEXT);
|
||||
_textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT, textColor);
|
||||
_textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN, textColor);
|
||||
_textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor);
|
||||
|
||||
// Render vertical lines for the frame
|
||||
// TODO: I think there may be a bug in this newest code and/or the GeometryCache code, because it seems like
|
||||
// sometimes the bandwidth meter doesn't render the vertical lines
|
||||
renderVerticalLine(0, 0, h, COLOR_FRAME);
|
||||
renderVerticalLine(barWidth, 0, h, COLOR_FRAME);
|
||||
|
||||
// Adjust scale
|
||||
int steps;
|
||||
double step, scaleMax;
|
||||
bool commit = false;
|
||||
do {
|
||||
steps = (_scaleMaxIndex % 9) + 2;
|
||||
step = pow(10.0, (_scaleMaxIndex / 9) - 10);
|
||||
scaleMax = step * steps;
|
||||
if (commit) {
|
||||
// printLog("Bandwidth meter scale: %d\n", _scaleMaxIndex);
|
||||
break;
|
||||
}
|
||||
if (totalMax < scaleMax * 0.5) {
|
||||
_scaleMaxIndex = glm::max(0, _scaleMaxIndex - 1);
|
||||
commit = true;
|
||||
} else if (totalMax > scaleMax) {
|
||||
_scaleMaxIndex += 1;
|
||||
commit = true;
|
||||
}
|
||||
} while (commit);
|
||||
|
||||
step = scaleMax / NUMBER_OF_MARKERS;
|
||||
if (scaleMax < MIN_METER_SCALE) {
|
||||
scaleMax = MIN_METER_SCALE;
|
||||
}
|
||||
|
||||
// Render scale indicators
|
||||
for (int j = NUMBER_OF_MARKERS; --j > 0;) {
|
||||
renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h, COLOR_INDICATOR);
|
||||
}
|
||||
|
||||
// Render bars
|
||||
int xIn = 0, xOut = 0;
|
||||
for (size_t i = 0; i < N_CHANNELS; ++i) {
|
||||
|
||||
ChannelIndex chIdx = ChannelIndex(i);
|
||||
int wIn = (int)(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
|
||||
int wOut = (int)(barWidth * outputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
|
||||
|
||||
if (wIn > 0) {
|
||||
renderBox(xIn, 0, wIn, barHeight, channelInfo(chIdx).colorRGBA);
|
||||
}
|
||||
xIn += wIn;
|
||||
|
||||
if (wOut > 0) {
|
||||
renderBox(xOut, h - barHeight, wOut, barHeight, channelInfo(chIdx).colorRGBA);
|
||||
}
|
||||
xOut += wOut;
|
||||
}
|
||||
|
||||
// Render numbers
|
||||
char fmtBuf[8];
|
||||
sprintf(fmtBuf, "%0.1f", totalIn);
|
||||
_textRenderer->draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
|
||||
PADDING_HORIZ_VALUE),
|
||||
textYupperLine, fmtBuf, textColor);
|
||||
sprintf(fmtBuf, "%0.1f", totalOut);
|
||||
_textRenderer->draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
|
||||
PADDING_HORIZ_VALUE),
|
||||
textYlowerLine, fmtBuf, textColor);
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
// After rendering, indicate that no data has been sent/received since the last feed.
|
||||
// This way, the meters fall when not continuously fed.
|
||||
for (size_t i = 0; i < N_CHANNELS; ++i) {
|
||||
inputStream(ChannelIndex(i)).updateValue(0);
|
||||
outputStream(ChannelIndex(i)).updateValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,87 +0,0 @@
|
|||
//
|
||||
// BandwidthMeter.h
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Tobias Schwinger on 6/20/13.
|
||||
// Copyright 2013 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
|
||||
//
|
||||
|
||||
#ifndef hifi_BandwidthMeter_h
|
||||
#define hifi_BandwidthMeter_h
|
||||
|
||||
#include <QElapsedTimer>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <TextRenderer.h>
|
||||
|
||||
|
||||
class BandwidthMeter {
|
||||
|
||||
public:
|
||||
|
||||
BandwidthMeter();
|
||||
~BandwidthMeter();
|
||||
|
||||
void render(int screenWidth, int screenHeight);
|
||||
bool isWithinArea(int x, int y, int screenWidth, int screenHeight);
|
||||
|
||||
// Number of channels / streams.
|
||||
static size_t const N_CHANNELS = 4;
|
||||
static size_t const N_STREAMS = N_CHANNELS * 2;
|
||||
|
||||
// Channel usage.
|
||||
enum ChannelIndex { AUDIO, AVATARS, OCTREE, METAVOXELS };
|
||||
|
||||
// Meta information held for a communication channel (bidirectional).
|
||||
struct ChannelInfo {
|
||||
|
||||
char const* const caption;
|
||||
char const* unitCaption;
|
||||
double unitScale;
|
||||
unsigned colorRGBA;
|
||||
};
|
||||
|
||||
// Representation of a data stream (unidirectional; input or output).
|
||||
class Stream {
|
||||
|
||||
public:
|
||||
|
||||
Stream(float msToAverage = 3000.0f);
|
||||
void updateValue(double amount);
|
||||
double getValue() const { return _value; }
|
||||
|
||||
private:
|
||||
double _value; // Current value.
|
||||
double _msToAverage; // Milliseconds to average.
|
||||
QElapsedTimer _prevTime; // Time of last feed.
|
||||
};
|
||||
|
||||
// Data model accessors
|
||||
Stream& inputStream(ChannelIndex i) { return _streams[i * 2]; }
|
||||
Stream const& inputStream(ChannelIndex i) const { return _streams[i * 2]; }
|
||||
Stream& outputStream(ChannelIndex i) { return _streams[i * 2 + 1]; }
|
||||
Stream const& outputStream(ChannelIndex i) const { return _streams[i * 2 + 1]; }
|
||||
ChannelInfo& channelInfo(ChannelIndex i) { return _channels[i]; }
|
||||
ChannelInfo const& channelInfo(ChannelIndex i) const { return _channels[i]; }
|
||||
|
||||
private:
|
||||
static glm::vec4 getColorRGBA(unsigned c);
|
||||
static void renderBox(int x, int y, int w, int h, unsigned c);
|
||||
static void renderVerticalLine(int x, int y, int h, unsigned c);
|
||||
|
||||
static inline int centered(int subject, int object);
|
||||
|
||||
|
||||
static ChannelInfo _CHANNELS[];
|
||||
|
||||
TextRenderer* _textRenderer;
|
||||
ChannelInfo* _channels;
|
||||
Stream _streams[N_STREAMS];
|
||||
int _scaleMaxIndex;
|
||||
};
|
||||
|
||||
#endif // hifi_BandwidthMeter_h
|
|
@ -102,7 +102,7 @@ void DialogsManager::editAnimations() {
|
|||
|
||||
void DialogsManager::bandwidthDetails() {
|
||||
if (! _bandwidthDialog) {
|
||||
_bandwidthDialog = new BandwidthDialog(qApp->getWindow(), qApp->getBandwidthMeter());
|
||||
_bandwidthDialog = new BandwidthDialog(qApp->getWindow(), qApp->getBandwidthRecorder());
|
||||
connect(_bandwidthDialog, SIGNAL(closed()), _bandwidthDialog, SLOT(deleteLater()));
|
||||
|
||||
if (_hmdToolsDialog) {
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QXmlStreamReader>
|
||||
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "ModelsBrowser.h"
|
||||
|
||||
|
@ -226,6 +227,7 @@ void ModelHandler::update() {
|
|||
QUrl url(_model.item(i,0)->data(Qt::UserRole).toString());
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkRequest request(url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.head(request);
|
||||
connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||
}
|
||||
|
@ -277,6 +279,7 @@ void ModelHandler::queryNewFiles(QString marker) {
|
|||
url.setQuery(query);
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkRequest request(url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(request);
|
||||
connect(reply, SIGNAL(finished()), SLOT(downloadFinished()));
|
||||
|
||||
|
|
|
@ -153,7 +153,9 @@ void ScriptEditorWidget::loadFile(const QString& scriptPath) {
|
|||
}
|
||||
} else {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||
qDebug() << "Downloading included script at" << scriptPath;
|
||||
QEventLoop loop;
|
||||
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include "SnapshotShareDialog.h"
|
||||
#include "AccountManager.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QHttpMultiPart>
|
||||
|
@ -112,6 +113,7 @@ void SnapshotShareDialog::uploadSnapshot() {
|
|||
|
||||
QUrl url(FORUM_UPLOADS_URL);
|
||||
QNetworkRequest request(url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().post(request, multiPart);
|
||||
connect(reply, &QNetworkReply::finished, this, &SnapshotShareDialog::uploadRequestFinished);
|
||||
|
@ -124,6 +126,7 @@ void SnapshotShareDialog::uploadSnapshot() {
|
|||
void SnapshotShareDialog::sendForumPost(QString snapshotPath) {
|
||||
// post to Discourse forum
|
||||
QNetworkRequest request;
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QUrl forumUrl(FORUM_POST_URL);
|
||||
|
||||
QUrlQuery query;
|
||||
|
|
|
@ -35,6 +35,7 @@ using namespace std;
|
|||
const int STATS_PELS_PER_LINE = 20;
|
||||
|
||||
const int STATS_GENERAL_MIN_WIDTH = 165;
|
||||
const int STATS_BANDWIDTH_MIN_WIDTH = 250;
|
||||
const int STATS_PING_MIN_WIDTH = 190;
|
||||
const int STATS_GEO_MIN_WIDTH = 240;
|
||||
const int STATS_OCTREE_MIN_WIDTH = 410;
|
||||
|
@ -49,6 +50,7 @@ Stats::Stats():
|
|||
_recentMaxPackets(0),
|
||||
_resetRecentMaxPacketsSoon(true),
|
||||
_generalStatsWidth(STATS_GENERAL_MIN_WIDTH),
|
||||
_bandwidthStatsWidth(STATS_BANDWIDTH_MIN_WIDTH),
|
||||
_pingStatsWidth(STATS_PING_MIN_WIDTH),
|
||||
_geoStatsWidth(STATS_GEO_MIN_WIDTH),
|
||||
_octreeStatsWidth(STATS_OCTREE_MIN_WIDTH),
|
||||
|
@ -129,6 +131,7 @@ void Stats::resetWidth(int width, int horizontalOffset) {
|
|||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
int extraSpace = glCanvas->width() - horizontalOffset -2
|
||||
- STATS_GENERAL_MIN_WIDTH
|
||||
- STATS_BANDWIDTH_MIN_WIDTH
|
||||
- (Menu::getInstance()->isOptionChecked(MenuOption::TestPing) ? STATS_PING_MIN_WIDTH -1 : 0)
|
||||
- STATS_GEO_MIN_WIDTH
|
||||
- STATS_OCTREE_MIN_WIDTH;
|
||||
|
@ -136,6 +139,7 @@ void Stats::resetWidth(int width, int horizontalOffset) {
|
|||
int panels = 4;
|
||||
|
||||
_generalStatsWidth = STATS_GENERAL_MIN_WIDTH;
|
||||
_bandwidthStatsWidth = STATS_BANDWIDTH_MIN_WIDTH;
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
||||
_pingStatsWidth = STATS_PING_MIN_WIDTH;
|
||||
} else {
|
||||
|
@ -147,11 +151,13 @@ void Stats::resetWidth(int width, int horizontalOffset) {
|
|||
|
||||
if (extraSpace > panels) {
|
||||
_generalStatsWidth += (int) extraSpace / panels;
|
||||
_bandwidthStatsWidth += (int) extraSpace / panels;
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
||||
_pingStatsWidth += (int) extraSpace / panels;
|
||||
}
|
||||
_geoStatsWidth += (int) extraSpace / panels;
|
||||
_octreeStatsWidth += glCanvas->width() - (_generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
|
||||
_octreeStatsWidth += glCanvas->width() -
|
||||
(_generalStatsWidth + _bandwidthStatsWidth + _pingStatsWidth + _geoStatsWidth + 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,8 +199,10 @@ void Stats::display(
|
|||
const float* color,
|
||||
int horizontalOffset,
|
||||
float fps,
|
||||
int packetsPerSecond,
|
||||
int bytesPerSecond,
|
||||
int inPacketsPerSecond,
|
||||
int outPacketsPerSecond,
|
||||
int inBytesPerSecond,
|
||||
int outBytesPerSecond,
|
||||
int voxelPacketsToProcess)
|
||||
{
|
||||
auto glCanvas = DependencyManager::get<GLCanvas>();
|
||||
|
@ -226,7 +234,7 @@ void Stats::display(
|
|||
|
||||
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) {
|
||||
|
||||
columnOneWidth = _generalStatsWidth + _pingStatsWidth + _geoStatsWidth; // make it 3 columns wide...
|
||||
columnOneWidth = _generalStatsWidth + _bandwidthStatsWidth + _pingStatsWidth + _geoStatsWidth; // 4 columns wide...
|
||||
// we will also include room for 1 line per timing record and a header of 4 lines
|
||||
lines += 4;
|
||||
|
||||
|
@ -258,18 +266,6 @@ void Stats::display(
|
|||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, avatarNodes, color);
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, framesPerSecond, color);
|
||||
|
||||
if (_expanded) {
|
||||
char packetsPerSecondString[30];
|
||||
sprintf(packetsPerSecondString, "Pkts/sec: %d", packetsPerSecond);
|
||||
char averageMegabitsPerSecond[30];
|
||||
sprintf(averageMegabitsPerSecond, "Mbps: %3.2f", (float)bytesPerSecond * 8.0f / 1000000.0f);
|
||||
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color);
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond, color);
|
||||
}
|
||||
|
||||
// TODO: the display of these timing details should all be moved to JavaScript
|
||||
if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayTimingDetails)) {
|
||||
|
@ -311,8 +307,27 @@ void Stats::display(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
verticalOffset = 0;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth +1;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + 1;
|
||||
|
||||
char packetsPerSecondString[30];
|
||||
sprintf(packetsPerSecondString, "Packets In/Out: %d/%d", inPacketsPerSecond, outPacketsPerSecond);
|
||||
char averageMegabitsPerSecond[30];
|
||||
sprintf(averageMegabitsPerSecond, "Mbps In/Out: %3.2f/%3.2f",
|
||||
(float)inBytesPerSecond * 8.0f / 1000000.0f,
|
||||
(float)outBytesPerSecond * 8.0f / 1000000.0f);
|
||||
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, packetsPerSecondString, color);
|
||||
verticalOffset += STATS_PELS_PER_LINE;
|
||||
drawText(horizontalOffset, verticalOffset, scale, rotation, font, averageMegabitsPerSecond, color);
|
||||
|
||||
|
||||
|
||||
verticalOffset = 0;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _bandwidthStatsWidth +1;
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::TestPing)) {
|
||||
int pingAudio = -1, pingAvatar = -1, pingVoxel = -1, pingOctreeMax = -1;
|
||||
|
@ -393,7 +408,7 @@ void Stats::display(
|
|||
}
|
||||
|
||||
verticalOffset = 0;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _pingStatsWidth + 2;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _bandwidthStatsWidth + _pingStatsWidth + 2;
|
||||
}
|
||||
|
||||
MyAvatar* myAvatar = Application::getInstance()->getAvatar();
|
||||
|
@ -471,7 +486,7 @@ void Stats::display(
|
|||
}
|
||||
|
||||
verticalOffset = 0;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _pingStatsWidth + _geoStatsWidth + 3;
|
||||
horizontalOffset = _lastHorizontalOffset + _generalStatsWidth + _bandwidthStatsWidth + _pingStatsWidth + _geoStatsWidth + 3;
|
||||
|
||||
lines = _expanded ? 14 : 3;
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ public:
|
|||
void toggleExpanded();
|
||||
void checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset);
|
||||
void resetWidth(int width, int horizontalOffset);
|
||||
void display(const float* color, int horizontalOffset, float fps, int packetsPerSecond, int bytesPerSecond, int voxelPacketsToProcess);
|
||||
void display(const float* color, int horizontalOffset, float fps, int inPacketsPerSecond, int outPacketsPerSecond,
|
||||
int inBytesPerSecond, int outBytesPerSecond, int voxelPacketsToProcess);
|
||||
bool includeTimingRecord(const QString& name);
|
||||
|
||||
Q_INVOKABLE void setMetavoxelStats(int internal, int leaves, int sendProgress,
|
||||
|
@ -44,6 +45,7 @@ private:
|
|||
bool _resetRecentMaxPacketsSoon;
|
||||
|
||||
int _generalStatsWidth;
|
||||
int _bandwidthStatsWidth;
|
||||
int _pingStatsWidth;
|
||||
int _geoStatsWidth;
|
||||
int _octreeStatsWidth;
|
||||
|
|
|
@ -1021,6 +1021,7 @@ void AvatarData::setBillboardFromURL(const QString &billboardURL) {
|
|||
qDebug() << "Changing billboard for avatar to PNG at" << qPrintable(billboardURL);
|
||||
|
||||
QNetworkRequest billboardRequest;
|
||||
billboardRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
billboardRequest.setUrl(QUrl(billboardURL));
|
||||
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
|
@ -1089,7 +1090,9 @@ void AvatarData::updateJointMappings() {
|
|||
|
||||
if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* networkReply = networkAccessManager.get(QNetworkRequest(_skeletonModelURL));
|
||||
QNetworkRequest networkRequest = QNetworkRequest(_skeletonModelURL);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* networkReply = networkAccessManager.get(networkRequest);
|
||||
connect(networkReply, SIGNAL(finished()), this, SLOT(setJointMappingsFromNetworkReply()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,7 +370,9 @@ RecordingPointer readRecordingFromFile(RecordingPointer recording, const QString
|
|||
// Download file if necessary
|
||||
qDebug() << "Downloading recording at" << url;
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||
QEventLoop loop;
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
loop.exec(); // wait for file
|
||||
|
|
|
@ -135,7 +135,9 @@ QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorTe
|
|||
}
|
||||
} else {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||
qDebug() << "Downloading script at" << url;
|
||||
QEventLoop loop;
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "RSAKeypairGenerator.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
#include "AccountManager.h"
|
||||
|
||||
|
@ -197,7 +198,8 @@ void AccountManager::invokedRequest(const QString& path,
|
|||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
|
||||
QNetworkRequest networkRequest;
|
||||
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
|
||||
QUrl requestURL = _authURL;
|
||||
|
||||
if (path.startsWith("/")) {
|
||||
|
@ -386,6 +388,7 @@ void AccountManager::requestAccessToken(const QString& login, const QString& pas
|
|||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
|
||||
QUrl grantURL = _authURL;
|
||||
grantURL.setPath("/oauth/token");
|
||||
|
@ -455,6 +458,7 @@ void AccountManager::requestProfile() {
|
|||
profileURL.setPath("/api/v1/user/profile");
|
||||
|
||||
QNetworkRequest profileRequest(profileURL);
|
||||
profileRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
profileRequest.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER, _accountInfo.getAccessToken().authorizationHeaderValue());
|
||||
|
||||
QNetworkReply* profileReply = networkAccessManager.get(profileRequest);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "HifiSockAddr.h"
|
||||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "UserActivityLogger.h"
|
||||
|
||||
#include "DomainHandler.h"
|
||||
|
@ -203,7 +204,9 @@ void DomainHandler::requestDomainSettings() {
|
|||
|
||||
qDebug() << "Requesting domain-server settings at" << settingsJSONURL.toString();
|
||||
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().get(QNetworkRequest(settingsJSONURL));
|
||||
QNetworkRequest settingsRequest(settingsJSONURL);
|
||||
settingsRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().get(settingsRequest);
|
||||
connect(reply, &QNetworkReply::finished, this, &DomainHandler::settingsRequestFinished);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QThreadStorage>
|
||||
|
||||
#include "AccountManager.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
#include "OAuthNetworkAccessManager.h"
|
||||
|
||||
|
@ -33,6 +34,7 @@ QNetworkReply* OAuthNetworkAccessManager::createRequest(QNetworkAccessManager::O
|
|||
|
||||
if (accountManager.hasValidAccessToken()) {
|
||||
QNetworkRequest authenticatedRequest(req);
|
||||
authenticatedRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
authenticatedRequest.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER,
|
||||
accountManager.getAccountInfo().getAccessToken().authorizationHeaderValue());
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
#include <QTimer>
|
||||
#include <QtDebug>
|
||||
|
||||
#include "NetworkAccessManager.h"
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "NetworkAccessManager.h"
|
||||
#include "ResourceCache.h"
|
||||
|
||||
#define clamp(x, min, max) (((x) < (min)) ? (min) :\
|
||||
|
@ -158,6 +159,7 @@ Resource::Resource(const QUrl& url, bool delayLoad) :
|
|||
|
||||
init();
|
||||
|
||||
_request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
_request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
|
||||
|
||||
// start loading immediately unless instructed otherwise
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QFile>
|
||||
#include "BatchLoader.h"
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
BatchLoader::BatchLoader(const QList<QUrl>& urls)
|
||||
: QObject(),
|
||||
|
@ -33,7 +34,9 @@ void BatchLoader::start() {
|
|||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
for (QUrl url : _urls) {
|
||||
if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "ftp") {
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
QNetworkRequest request = QNetworkRequest(url);
|
||||
request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(request);
|
||||
|
||||
qDebug() << "Downloading file at" << url;
|
||||
|
||||
|
|
|
@ -179,7 +179,9 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) {
|
|||
}
|
||||
} else {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||
connect(reply, &QNetworkReply::finished, this, &ScriptEngine::handleScriptDownload);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,6 +107,7 @@ void XMLHttpRequestClass::abort() {
|
|||
}
|
||||
|
||||
void XMLHttpRequestClass::setRequestHeader(const QString& name, const QString& value) {
|
||||
_request.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
_request.setRawHeader(QByteArray(name.toLatin1()), QByteArray(value.toLatin1()));
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,10 @@ static const quint64 USECS_PER_MSEC = 1000;
|
|||
static const quint64 MSECS_PER_SECOND = 1000;
|
||||
static const quint64 USECS_PER_SECOND = USECS_PER_MSEC * MSECS_PER_SECOND;
|
||||
|
||||
const int BITS_IN_BYTE = 8;
|
||||
const int BITS_IN_BYTE = 8;
|
||||
|
||||
// Use a custom User-Agent to avoid ModSecurity filtering, e.g. by hosting providers.
|
||||
const QByteArray HIGH_FIDELITY_USER_AGENT = "Mozilla/5.0 (HighFidelity)";
|
||||
|
||||
quint64 usecTimestampNow(bool wantDebug = false);
|
||||
void usecTimestampNowForceClockSkew(int clockSkew);
|
||||
|
|
Loading…
Reference in a new issue