mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Merge branch 'protocol' of https://github.com/Atlante45/hifi into atp
This commit is contained in:
commit
c154e6cc74
72 changed files with 500 additions and 272 deletions
|
@ -19,7 +19,7 @@
|
|||
#include <AvatarHashMap.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <ResourceCache.h>
|
||||
#include <SoundCache.h>
|
||||
#include <UUID.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <LogUtils.h>
|
||||
#include <LimitedNodeList.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <ShutdownEventListener.h>
|
||||
#include <SoundCache.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "AssignmentClientMonitor.h"
|
||||
#include "AssignmentClientApp.h"
|
||||
#include "AssignmentClientChildData.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
|
||||
|
@ -197,7 +197,7 @@ void AssignmentClientMonitor::checkSpares() {
|
|||
childNode->activateLocalSocket();
|
||||
|
||||
auto diePacket = NLPacket::create(PacketType::StopNode, 0);
|
||||
nodeList->sendPacket(std::move(diePacket), childNode);
|
||||
nodeList->sendPacket(std::move(diePacket), *childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "Agent.h"
|
||||
#include "AssignmentFactory.h"
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include <NodeList.h>
|
||||
#include <Node.h>
|
||||
#include <OctreeConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <StDev.h>
|
||||
#include <UUID.h>
|
||||
|
@ -540,7 +540,7 @@ void AudioMixer::sendAudioEnvironmentPacket(SharedNodePointer node) {
|
|||
envPacket->writePrimitive(reverbTime);
|
||||
envPacket->writePrimitive(wetLevel);
|
||||
}
|
||||
nodeList->sendPacket(std::move(envPacket), node);
|
||||
nodeList->sendPacket(std::move(envPacket), *node);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -559,7 +559,7 @@ void AudioMixer::handleMuteEnvironmentPacket(QSharedPointer<NLPacket> packet, Sh
|
|||
nodeList->eachNode([&](const SharedNodePointer& node){
|
||||
if (node->getType() == NodeType::Agent && node->getActiveSocket() &&
|
||||
node->getLinkedData() && node != sendingNode) {
|
||||
nodeList->sendPacket(std::move(newPacket), node);
|
||||
nodeList->sendPacket(std::move(newPacket), *node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ void AudioMixer::run() {
|
|||
if (nodeData->getAvatarAudioStream()
|
||||
&& shouldMute(nodeData->getAvatarAudioStream()->getQuietestFrameLoudness())) {
|
||||
auto mutePacket = NLPacket::create(PacketType::NoisyMute, 0);
|
||||
nodeList->sendPacket(std::move(mutePacket), node);
|
||||
nodeList->sendPacket(std::move(mutePacket), *node);
|
||||
}
|
||||
|
||||
if (node->getType() == NodeType::Agent && node->getActiveSocket()
|
||||
|
@ -804,7 +804,7 @@ void AudioMixer::run() {
|
|||
sendAudioEnvironmentPacket(node);
|
||||
|
||||
// send mixed audio packet
|
||||
nodeList->sendPacket(std::move(mixPacket), node);
|
||||
nodeList->sendPacket(std::move(mixPacket), *node);
|
||||
nodeData->incrementOutgoingMixedAudioSequenceNumber();
|
||||
|
||||
// send an audio stream stats packet if it's time
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QJsonArray>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <UUID.h>
|
||||
|
||||
#include "InjectedAudioStream.h"
|
||||
|
@ -164,10 +164,7 @@ void AudioMixerClientData::sendAudioStreamStatsPackets(const SharedNodePointer&
|
|||
int numStreamStatsRemaining = _audioStreams.size();
|
||||
QHash<QUuid, PositionalAudioStream*>::ConstIterator audioStreamsIterator = _audioStreams.constBegin();
|
||||
|
||||
NLPacketList statsPacketList(PacketType::AudioStreamStats);
|
||||
|
||||
while (numStreamStatsRemaining > 0) {
|
||||
|
||||
auto statsPacket = NLPacket::create(PacketType::AudioStreamStats);
|
||||
|
||||
// pack the append flag in this packet
|
||||
|
@ -195,7 +192,7 @@ void AudioMixerClientData::sendAudioStreamStatsPackets(const SharedNodePointer&
|
|||
numStreamStatsRemaining -= numStreamStatsToPack;
|
||||
|
||||
// send the current packet
|
||||
nodeList->sendPacket(std::move(statsPacket), destinationNode);
|
||||
nodeList->sendPacket(std::move(statsPacket), *destinationNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "AvatarAudioStream.h"
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include <LogHandler.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
#include <TryLocker.h>
|
||||
|
@ -318,7 +318,7 @@ void AvatarMixer::broadcastAvatarData() {
|
|||
billboardPacket->write(rfcUUID);
|
||||
billboardPacket->write(billboard);
|
||||
|
||||
nodeList->sendPacket(std::move(billboardPacket), node);
|
||||
nodeList->sendPacket(std::move(billboardPacket), *node);
|
||||
|
||||
++_sumBillboardPackets;
|
||||
}
|
||||
|
@ -336,14 +336,14 @@ void AvatarMixer::broadcastAvatarData() {
|
|||
|
||||
identityPacket->write(individualData);
|
||||
|
||||
nodeList->sendPacket(std::move(identityPacket), node);
|
||||
nodeList->sendPacket(std::move(identityPacket), *node);
|
||||
|
||||
++_sumIdentityPackets;
|
||||
}
|
||||
});
|
||||
|
||||
// send the avatar data PacketList
|
||||
nodeList->sendPacketList(avatarPacketList, node);
|
||||
nodeList->sendPacketList(avatarPacketList, *node);
|
||||
|
||||
// record the bytes sent for other avatar data in the AvatarMixerClientData
|
||||
nodeData->recordSentAvatarData(numAvatarDataBytes);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "AvatarMixerClientData.h"
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#include <AvatarData.h>
|
||||
#include <NodeData.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SimpleMovingAverage.h>
|
||||
#include <UUIDHasher.h>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef hifi_EntityNodeData_h
|
||||
#define hifi_EntityNodeData_h
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "../octree/OctreeQueryNode.h"
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ int EntityServer::sendSpecialPackets(const SharedNodePointer& node, OctreeQueryN
|
|||
totalBytes += specialPacket->getSizeWithHeader();
|
||||
packetsSent++;
|
||||
|
||||
DependencyManager::get<NodeList>()->sendPacket(std::move(specialPacket), node);
|
||||
DependencyManager::get<NodeList>()->sendPacket(std::move(specialPacket), *node);
|
||||
}
|
||||
|
||||
nodeData->setLastDeletedEntitiesSentAt(deletePacketSentAt);
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <limits>
|
||||
|
||||
#include <NumericalConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "OctreeServer.h"
|
||||
|
@ -287,7 +287,7 @@ int OctreeInboundPacketProcessor::sendNackPackets() {
|
|||
packetsSent += nackPacketList.getNumPackets();
|
||||
|
||||
// send the list of nack packets
|
||||
nodeList->sendPacketList(nackPacketList, destinationNode);
|
||||
nodeList->sendPacketList(nackPacketList, *destinationNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <NodeList.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "OctreeSendThread.h"
|
||||
|
@ -179,12 +179,12 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
|||
|
||||
// actually send it
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(statsPacket, _node);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(statsPacket, *_node);
|
||||
packetSent = true;
|
||||
} else {
|
||||
// not enough room in the packet, send two packets
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(statsPacket, _node);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(statsPacket, *_node);
|
||||
|
||||
// since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since
|
||||
// there was nothing else to send.
|
||||
|
@ -215,7 +215,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
|||
packetsSent++;
|
||||
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), _node);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), *_node);
|
||||
packetSent = true;
|
||||
|
||||
int packetSizeWithHeader = nodeData->getPacket().getSizeWithHeader();
|
||||
|
@ -247,7 +247,7 @@ int OctreeSendThread::handlePacketSend(OctreeQueryNode* nodeData, int& trueBytes
|
|||
if (nodeData->isPacketWaiting() && !nodeData->isShuttingDown()) {
|
||||
// just send the octree packet
|
||||
OctreeServer::didCallWriteDatagram(this);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), _node);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(nodeData->getPacket(), *_node);
|
||||
packetSent = true;
|
||||
|
||||
int packetSizeWithHeader = nodeData->getPacket().getSizeWithHeader();
|
||||
|
@ -592,7 +592,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
|||
while (nodeData->hasNextNackedPacket() && packetsSentThisInterval < maxPacketsPerInterval) {
|
||||
const NLPacket* packet = nodeData->getNextNackedPacket();
|
||||
if (packet) {
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(*packet, _node);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(*packet, *_node);
|
||||
truePacketsSent++;
|
||||
packetsSentThisInterval++;
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
//
|
||||
// OctreeServerDatagramProcessor.cpp
|
||||
// assignment-client/src
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 2014-09-05
|
||||
// Copyright 2014 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 <QDebug>
|
||||
|
||||
#include <HifiSockAddr.h>
|
||||
#include <NodeList.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "OctreeServerDatagramProcessor.h"
|
||||
|
||||
OctreeServerDatagramProcessor::OctreeServerDatagramProcessor(QUdpSocket& nodeSocket, QThread* previousNodeSocketThread) :
|
||||
_nodeSocket(nodeSocket),
|
||||
_previousNodeSocketThread(previousNodeSocketThread)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
OctreeServerDatagramProcessor::~OctreeServerDatagramProcessor() {
|
||||
// return the node socket to its previous thread
|
||||
_nodeSocket.moveToThread(_previousNodeSocketThread);
|
||||
}
|
||||
|
||||
void OctreeServerDatagramProcessor::readPendingDatagrams() {
|
||||
|
||||
HifiSockAddr senderSockAddr;
|
||||
static QByteArray incomingPacket;
|
||||
|
||||
// read everything that is available
|
||||
while (_nodeSocket.hasPendingDatagrams()) {
|
||||
incomingPacket.resize(_nodeSocket.pendingDatagramSize());
|
||||
|
||||
// just get this packet off the stack
|
||||
_nodeSocket.readDatagram(incomingPacket.data(), incomingPacket.size(),
|
||||
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||
|
||||
PacketType::Value packetType = packetTypeForPacket(incomingPacket);
|
||||
if (packetType == PacketType::Ping) {
|
||||
DependencyManager::get<NodeList>()->processNodeData(senderSockAddr, incomingPacket);
|
||||
return; // don't emit
|
||||
}
|
||||
|
||||
// emit the signal to tell AudioMixer it needs to process a packet
|
||||
emit packetRequiresProcessing(incomingPacket, senderSockAddr);
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@
|
|||
#include <JSONBreakableMarshal.h>
|
||||
#include <LogUtils.h>
|
||||
#include <NetworkingConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <ShutdownEventListener.h>
|
||||
|
@ -1005,7 +1005,7 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
}
|
||||
|
||||
// write the PacketList to this node
|
||||
limitedNodeList->sendPacketList(domainListPackets, node);
|
||||
limitedNodeList->sendPacketList(domainListPackets, *node);
|
||||
}
|
||||
|
||||
QUuid DomainServer::connectionSecretForNodes(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB) {
|
||||
|
@ -1061,7 +1061,7 @@ void DomainServer::broadcastNewNode(const SharedNodePointer& addedNode) {
|
|||
addNodePacket->write(rfcConnectionSecret);
|
||||
|
||||
// send off this packet to the node
|
||||
limitedNodeList->sendUnreliablePacket(*addNodePacket, node);
|
||||
limitedNodeList->sendUnreliablePacket(*addNodePacket, *node);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <QtCore/QVariant>
|
||||
|
||||
#include <JSONBreakableMarshal.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "DomainServerNodeData.h"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include <LimitedNodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "IceServer.h"
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
#include <ObjectMotionState.h>
|
||||
#include <OctalCode.h>
|
||||
#include <OctreeSceneStats.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PathUtils.h>
|
||||
#include <PerfStat.h>
|
||||
#include <PhysicsEngine.h>
|
||||
|
@ -1783,7 +1783,7 @@ void Application::sendPingPackets() {
|
|||
return false;
|
||||
}
|
||||
}, [nodeList](const SharedNodePointer& node) {
|
||||
nodeList->sendPacket(std::move(nodeList->constructPingPacket()), node);
|
||||
nodeList->sendPacket(std::move(nodeList->constructPingPacket()), *node);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -2721,7 +2721,7 @@ int Application::sendNackPackets() {
|
|||
packetsSent += nackPacketList.getNumPackets();
|
||||
|
||||
// send the packet list
|
||||
nodeList->sendPacketList(nackPacketList, node);
|
||||
nodeList->sendPacketList(nackPacketList, *node);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2902,7 +2902,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType::Value packetTyp
|
|||
queryPacket->setSizeUsed(packetSize);
|
||||
|
||||
// make sure we still have an active socket
|
||||
nodeList->sendUnreliablePacket(*queryPacket, node);
|
||||
nodeList->sendUnreliablePacket(*queryPacket, *node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <NodeList.h>
|
||||
#include <OctreeQuery.h>
|
||||
#include <OffscreenUi.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PacketListener.h>
|
||||
#include <PhysicalEntitySimulation.h>
|
||||
#include <PhysicsEngine.h>
|
||||
|
@ -48,7 +48,6 @@
|
|||
#include "FileLogger.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "Menu.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "Physics.h"
|
||||
#include "Stars.h"
|
||||
#include "avatar/Avatar.h"
|
||||
|
@ -56,6 +55,7 @@
|
|||
#include "devices/SixenseManager.h"
|
||||
#include "scripting/ControllerScriptingInterface.h"
|
||||
#include "scripting/WebWindowClass.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "ui/BandwidthDialog.h"
|
||||
#include "ui/HMDToolsDialog.h"
|
||||
#include "ui/ModelsBrowser.h"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <LODManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PathUtils.h>
|
||||
#include <PerfStat.h>
|
||||
#include <SharedUtil.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <GeometryUtil.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PathUtils.h>
|
||||
#include <PerfStat.h>
|
||||
#include <ShapeCollider.h>
|
||||
|
|
|
@ -50,7 +50,7 @@ extern "C" {
|
|||
#include <soxr.h>
|
||||
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PositionalAudioStream.h>
|
||||
#include <SettingHandle.h>
|
||||
#include <SharedUtil.h>
|
||||
|
@ -944,7 +944,7 @@ void AudioClient::handleAudioInput() {
|
|||
|
||||
nodeList->flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendAudioPacket);
|
||||
|
||||
nodeList->sendUnreliablePacket(*_audioPacket, audioMixer);
|
||||
nodeList->sendUnreliablePacket(*_audioPacket, *audioMixer);
|
||||
|
||||
_outgoingAvatarAudioSequenceNumber++;
|
||||
}
|
||||
|
@ -986,7 +986,7 @@ void AudioClient::sendMuteEnvironmentPacket() {
|
|||
|
||||
if (audioMixer) {
|
||||
// send off this mute packet
|
||||
nodeList->sendPacket(std::move(mutePacket), audioMixer);
|
||||
nodeList->sendPacket(std::move(mutePacket), *audioMixer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,5 +121,5 @@ void AudioIOStats::sendDownstreamAudioStatsPacket() {
|
|||
|
||||
// send packet
|
||||
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
||||
nodeList->sendPacket(std::move(statsPacket), audioMixer);
|
||||
nodeList->sendPacket(std::move(statsPacket), *audioMixer);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <QtCore/QDataStream>
|
||||
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <UUID.h>
|
||||
#include <soxr.h>
|
||||
|
@ -238,7 +238,7 @@ void AudioInjector::injectToMixer() {
|
|||
SharedNodePointer audioMixer = nodeList->soloNodeOfType(NodeType::AudioMixer);
|
||||
|
||||
// send off this audio packet
|
||||
nodeList->sendUnreliablePacket(*audioPacket, audioMixer);
|
||||
nodeList->sendUnreliablePacket(*audioPacket, *audioMixer);
|
||||
outgoingInjectedAudioSequenceNumber++;
|
||||
|
||||
_currentSendPosition += bytesToCopy;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "AudioLogging.h"
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include <Node.h>
|
||||
|
||||
#include "InboundAudioStream.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
|
||||
const int STARVE_HISTORY_CAPACITY = 50;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
#include <NodeData.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <StDev.h>
|
||||
|
||||
#include "AudioRingBuffer.h"
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <QtCore/QDataStream>
|
||||
#include <QtCore/qdebug.h>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <UUID.h>
|
||||
|
||||
#include "InjectedAudioStream.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define hifi_MixedAudioStream_h
|
||||
|
||||
#include "InboundAudioStream.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
|
||||
class MixedAudioStream : public InboundAudioStream {
|
||||
public:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include <QtCore/QDataStream>
|
||||
|
||||
#include <Node.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <UUID.h>
|
||||
|
||||
PositionalAudioStream::PositionalAudioStream(PositionalAudioStream::Type type, bool isStereo, const InboundAudioStream::Settings& settings) :
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <StreamUtils.h>
|
||||
#include <UUID.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "AvatarLogging.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <assert.h>
|
||||
#include <PerfStat.h>
|
||||
#include <OctalCode.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include "EntityEditPacketSender.h"
|
||||
#include "EntitiesLogging.h"
|
||||
#include "EntityItem.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <QtCore/QObject>
|
||||
#include <QDebug>
|
||||
#include <BufferParser.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "RegisteredMetaTypes.h"
|
||||
#include "EntityItemID.h"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef hifi_EntityTreeHeadlessViewer_h
|
||||
#define hifi_EntityTreeHeadlessViewer_h
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <Octree.h>
|
||||
#include <OctreePacketData.h>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <cstring>
|
||||
|
||||
#include "EnvironmentData.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
|
||||
// initial values from Sean O'Neil's GPU Gems entry (http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter16.html),
|
||||
// GameEngine.cpp
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <SettingHandle.h>
|
||||
|
||||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "RSAKeypairGenerator.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "UUID.h"
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "Assignment.h"
|
||||
#include "HifiSockAddr.h"
|
||||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "UserActivityLogger.h"
|
||||
#include "NetworkLogging.h"
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include "UUID.h"
|
||||
#include "NetworkLogging.h"
|
||||
|
||||
#include "udt/udt.h"
|
||||
|
||||
const char SOLO_NODE_TYPES[2] = {
|
||||
NodeType::AvatarMixer,
|
||||
NodeType::AudioMixer
|
||||
|
@ -206,6 +208,10 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod
|
|||
return false;
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr) {
|
||||
return writeDatagram({packet.getData(), static_cast<int>(packet.getSizeWithHeader())}, destinationSockAddr);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
|
||||
// XXX can BandwidthRecorder be used for this?
|
||||
// stat collection for packets
|
||||
|
@ -222,6 +228,59 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSock
|
|||
return bytesWritten;
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode) {
|
||||
if (!destinationNode.getActiveSocket()) {
|
||||
// we don't have a socket to send to, return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// use the node's active socket as the destination socket
|
||||
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket());
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) {
|
||||
return writeDatagram(packet, sockAddr);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode) {
|
||||
if (!destinationNode.getActiveSocket()) {
|
||||
// we don't have a socket to send to, return 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
// use the node's active socket as the destination socket
|
||||
return sendPacket(std::move(packet), *destinationNode.getActiveSocket());
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr) {
|
||||
return writeDatagram(*packet, sockAddr);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) {
|
||||
if (!destinationNode.getActiveSocket()) {
|
||||
// we don't have a socket to send to, return 0
|
||||
return 0;
|
||||
}
|
||||
return sendPacketList(packetList, *destinationNode.getActiveSocket());
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) {
|
||||
qint64 bytesSent{ 0 };
|
||||
while (!packetList._packets.empty()) {
|
||||
bytesSent += sendPacket(std::move(packetList.takeFront<NLPacket>()), sockAddr);
|
||||
}
|
||||
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr) {
|
||||
// use the node's active socket as the destination socket if there is no overriden socket address
|
||||
auto& destinationSockAddr = (overridenSockAddr.isNull()) ? *destinationNode.getActiveSocket()
|
||||
: overridenSockAddr;
|
||||
return sendPacket(std::move(packet), destinationSockAddr);
|
||||
}
|
||||
|
||||
PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) {
|
||||
// Thanks to std::map and std::unordered_map this line either default constructs the
|
||||
// PacketType::SequenceMap and the PacketSequenceNumber or returns the existing value.
|
||||
|
@ -402,6 +461,19 @@ std::unique_ptr<NLPacket> LimitedNodeList::constructICEPingReplyPacket(NLPacket&
|
|||
return icePingReplyPacket;
|
||||
}
|
||||
|
||||
unsigned int LimitedNodeList::broadcastToNodes(std::unique_ptr<NLPacket> packet, const NodeSet& destinationNodeTypes) {
|
||||
unsigned int n = 0;
|
||||
|
||||
eachNode([&](const SharedNodePointer& node){
|
||||
if (destinationNodeTypes.contains(node->getType())) {
|
||||
writeDatagram(*packet, *node->getActiveSocket());
|
||||
++n;
|
||||
}
|
||||
});
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
SharedNodePointer LimitedNodeList::soloNodeOfType(char nodeType) {
|
||||
return nodeMatchingPredicate([&](const SharedNodePointer& node){
|
||||
return node->getType() == nodeType;
|
||||
|
|
|
@ -37,14 +37,12 @@
|
|||
#include "DomainHandler.h"
|
||||
#include "Node.h"
|
||||
#include "NLPacket.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "PacketReceiver.h"
|
||||
#include "PacketListener.h"
|
||||
#include "NLPacketList.h"
|
||||
#include "UUIDHasher.h"
|
||||
|
||||
const int MAX_PACKET_SIZE = 1450;
|
||||
|
||||
const quint64 NODE_SILENCE_THRESHOLD_MSECS = 2 * 1000;
|
||||
|
||||
extern const char SOLO_NODE_TYPES[2];
|
||||
|
@ -121,14 +119,14 @@ public:
|
|||
|
||||
PacketReceiver& getPacketReceiver() { return _packetReceiver; }
|
||||
|
||||
qint64 sendUnreliablePacket(const NLPacket& packet, const SharedNodePointer& destinationNode) { assert(false); return 0; }
|
||||
qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) { assert(false); return 0; }
|
||||
qint64 sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode);
|
||||
qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr);
|
||||
|
||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const SharedNodePointer& destinationNode) { assert(false); return 0; }
|
||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr) { assert(false); return 0; }
|
||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode);
|
||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr);
|
||||
|
||||
qint64 sendPacketList(NLPacketList& packetList, const SharedNodePointer& destinationNode) { assert(false); return 0; }
|
||||
qint64 sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) { assert(false); return 0; }
|
||||
qint64 sendPacketList(NLPacketList& packetList, const Node& destinationNode);
|
||||
qint64 sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr);
|
||||
|
||||
void (*linkedDataCreateCallback)(Node *);
|
||||
|
||||
|
@ -150,7 +148,7 @@ public:
|
|||
|
||||
int updateNodeWithDataFromPacket(QSharedPointer<NLPacket> packet, SharedNodePointer matchingNode);
|
||||
|
||||
unsigned broadcastToNodes(std::unique_ptr<NLPacket> packet, const NodeSet& destinationNodeTypes) { assert(false); return 0; }
|
||||
unsigned int broadcastToNodes(std::unique_ptr<NLPacket> packet, const NodeSet& destinationNodeTypes);
|
||||
SharedNodePointer soloNodeOfType(char nodeType);
|
||||
|
||||
void getPacketStats(float &packetsPerSecond, float &bytesPerSecond);
|
||||
|
@ -246,7 +244,8 @@ protected:
|
|||
LimitedNodeList(unsigned short socketListenPort = 0, unsigned short dtlsListenPort = 0);
|
||||
LimitedNodeList(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton
|
||||
void operator=(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton
|
||||
|
||||
|
||||
qint64 writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr);
|
||||
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr);
|
||||
|
||||
PacketSequenceNumber getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType);
|
||||
|
@ -260,9 +259,8 @@ protected:
|
|||
void sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
|
||||
const QUuid& peerRequestID = QUuid());
|
||||
|
||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const SharedNodePointer& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr)
|
||||
{ assert(false); return 0; }
|
||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr);
|
||||
|
||||
|
||||
QUuid _sessionUUID;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef hifi_NLPacket_h
|
||||
#define hifi_NLPacket_h
|
||||
|
||||
#include "Packet.h"
|
||||
#include "udt/Packet.h"
|
||||
|
||||
class NLPacket : public Packet {
|
||||
Q_OBJECT
|
||||
|
|
|
@ -11,100 +11,12 @@
|
|||
|
||||
#include "NLPacketList.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
NLPacketList::NLPacketList(PacketType::Value packetType) :
|
||||
_packetType(packetType)
|
||||
{
|
||||
#include "NLPacket.h"
|
||||
|
||||
NLPacketList::NLPacketList(PacketType::Value packetType) : PacketList(packetType) {
|
||||
}
|
||||
|
||||
std::unique_ptr<NLPacket> NLPacketList::createPacketWithExtendedHeader() {
|
||||
// use the static create method to create a new packet
|
||||
auto packet = NLPacket::create(_packetType);
|
||||
|
||||
// add the extended header to the front of the packet
|
||||
if (packet->write(_extendedHeader) == -1) {
|
||||
qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader"
|
||||
<< "- make sure that _extendedHeader is not larger than the payload capacity.";
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
|
||||
qint64 NLPacketList::writeData(const char* data, qint64 maxSize) {
|
||||
if (!_currentPacket) {
|
||||
// we don't have a current packet, time to set one up
|
||||
_currentPacket = createPacketWithExtendedHeader();
|
||||
}
|
||||
|
||||
// check if this block of data can fit into the currentPacket
|
||||
if (maxSize <= _currentPacket->bytesAvailable()) {
|
||||
// it fits, just write it to the current packet
|
||||
_currentPacket->write(data, maxSize);
|
||||
|
||||
// return the number of bytes written
|
||||
return maxSize;
|
||||
} else {
|
||||
// it does not fit - this may need to be in the next packet
|
||||
|
||||
if (!_isOrdered) {
|
||||
auto newPacket = createPacketWithExtendedHeader();
|
||||
|
||||
if (_segmentStartIndex >= 0) {
|
||||
// We in the process of writing a segment for an unordered PacketList.
|
||||
// We need to try and pull the first part of the segment out to our new packet
|
||||
|
||||
// check now to see if this is an unsupported write
|
||||
int numBytesToEnd = _currentPacket->bytesAvailable();
|
||||
|
||||
if ((newPacket->size() - numBytesToEnd) < maxSize) {
|
||||
// this is an unsupported case - the segment is bigger than the size of an individual packet
|
||||
// but the PacketList is not going to be sent ordered
|
||||
qDebug() << "Error in PacketList::writeData - attempted to write a segment to an unordered packet that is"
|
||||
<< "larger than the payload size.";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
// copy from currentPacket where the segment started to the beginning of the newPacket
|
||||
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, numBytesToEnd);
|
||||
|
||||
// the current segment now starts at the beginning of the new packet
|
||||
_segmentStartIndex = 0;
|
||||
|
||||
// shrink the current payload to the actual size of the packet
|
||||
_currentPacket->setSizeUsed(_segmentStartIndex);
|
||||
}
|
||||
|
||||
// move the current packet to our list of packets
|
||||
_packets.push_back(std::move(_currentPacket));
|
||||
|
||||
// write the data to the newPacket
|
||||
newPacket->write(data, maxSize);
|
||||
|
||||
// swap our current packet with the new packet
|
||||
_currentPacket.swap(newPacket);
|
||||
|
||||
// return the number of bytes written to the new packet
|
||||
return maxSize;
|
||||
} else {
|
||||
// we're an ordered PacketList - let's fit what we can into the current packet and then put the leftover
|
||||
// into a new packet
|
||||
|
||||
int numBytesToEnd = _currentPacket->bytesAvailable();
|
||||
_currentPacket->write(data, numBytesToEnd);
|
||||
|
||||
// move the current packet to our list of packets
|
||||
_packets.push_back(std::move(_currentPacket));
|
||||
|
||||
// recursively call our writeData method for the remaining data to write to a new packet
|
||||
return numBytesToEnd + writeData(data + numBytesToEnd, maxSize - numBytesToEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NLPacketList::closeCurrentPacket() {
|
||||
// move the current packet to our list of packets
|
||||
_packets.push_back(std::move(_currentPacket));
|
||||
std::unique_ptr<Packet> NLPacketList::createPacket() {
|
||||
return std::move(NLPacket::create(getType()));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,59 +12,17 @@
|
|||
#ifndef hifi_NLPacketList_h
|
||||
#define hifi_NLPacketList_h
|
||||
|
||||
#include <QtCore/QIODevice>
|
||||
#include "udt/PacketList.h"
|
||||
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
#include "NLPacket.h"
|
||||
|
||||
class NLPacketList : public QIODevice {
|
||||
Q_OBJECT
|
||||
class NLPacketList : public PacketList {
|
||||
public:
|
||||
NLPacketList(PacketType::Value packetType);
|
||||
|
||||
virtual bool isSequential() const { return true; }
|
||||
|
||||
void startSegment() { _segmentStartIndex = _currentPacket->pos(); }
|
||||
void endSegment() { _segmentStartIndex = -1; }
|
||||
|
||||
int getNumPackets() const { return _packets.size() + (_currentPacket ? 1 : 0); }
|
||||
|
||||
void closeCurrentPacket();
|
||||
|
||||
void setExtendedHeader(const QByteArray& extendedHeader) { _extendedHeader = extendedHeader; }
|
||||
|
||||
template<typename T> qint64 readPrimitive(T* data);
|
||||
template<typename T> qint64 writePrimitive(const T& data);
|
||||
protected:
|
||||
virtual qint64 writeData(const char* data, qint64 maxSize);
|
||||
virtual qint64 readData(char* data, qint64 maxSize) { return 0; }
|
||||
|
||||
|
||||
private:
|
||||
NLPacketList(const NLPacketList& other) = delete;
|
||||
NLPacketList& operator=(const NLPacketList& other) = delete;
|
||||
|
||||
std::unique_ptr<NLPacket> createPacketWithExtendedHeader();
|
||||
|
||||
PacketType::Value _packetType;
|
||||
bool _isOrdered = false;
|
||||
|
||||
std::unique_ptr<NLPacket> _currentPacket;
|
||||
std::list<std::unique_ptr<NLPacket>> _packets;
|
||||
|
||||
int _segmentStartIndex = -1;
|
||||
|
||||
QByteArray _extendedHeader;
|
||||
|
||||
virtual std::unique_ptr<Packet> createPacket();
|
||||
};
|
||||
|
||||
template <typename T> qint64 NLPacketList::readPrimitive(T* data) {
|
||||
return QIODevice::read(reinterpret_cast<char*>(data), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T> qint64 NLPacketList::writePrimitive(const T& data) {
|
||||
static_assert(!std::is_pointer<T>::value, "T must not be a pointer");
|
||||
return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(T));
|
||||
}
|
||||
|
||||
|
||||
#endif // hifi_PacketList_h
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "NetworkPeer.h"
|
||||
#include "NodeData.h"
|
||||
#include "NodeType.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "SimpleMovingAverage.h"
|
||||
#include "MovingPercentile.h"
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include "HifiSockAddr.h"
|
||||
#include "JSONBreakableMarshal.h"
|
||||
#include "NodeList.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "UUID.h"
|
||||
#include "NetworkLogging.h"
|
||||
|
@ -170,7 +170,7 @@ void NodeList::processPingPacket(QSharedPointer<NLPacket> packet, SharedNodePoin
|
|||
// send back a reply
|
||||
auto replyPacket = constructPingReplyPacket(*packet);
|
||||
const HifiSockAddr& senderSockAddr = packet->getSenderSockAddr();
|
||||
sendPacket(std::move(replyPacket), sendingNode, senderSockAddr);
|
||||
sendPacket(std::move(replyPacket), *sendingNode, senderSockAddr);
|
||||
|
||||
// If we don't have a symmetric socket for this node and this socket doesn't match
|
||||
// what we have for public and local then set it as the symmetric.
|
||||
|
@ -549,14 +549,14 @@ void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) {
|
|||
|
||||
// send the ping packet to the local and public sockets for this node
|
||||
auto localPingPacket = constructPingPacket(PingType::Local);
|
||||
sendPacket(std::move(localPingPacket), node, node->getLocalSocket());
|
||||
sendPacket(std::move(localPingPacket), *node, node->getLocalSocket());
|
||||
|
||||
auto publicPingPacket = constructPingPacket(PingType::Public);
|
||||
sendPacket(std::move(publicPingPacket), node, node->getPublicSocket());
|
||||
sendPacket(std::move(publicPingPacket), *node, node->getPublicSocket());
|
||||
|
||||
if (!node->getSymmetricSocket().isNull()) {
|
||||
auto symmetricPingPacket = constructPingPacket(PingType::Symmetric);
|
||||
sendPacket(std::move(symmetricPingPacket), node, node->getSymmetricSocket());
|
||||
sendPacket(std::move(symmetricPingPacket), *node, node->getSymmetricSocket());
|
||||
}
|
||||
|
||||
node->incrementConnectionAttempts();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <QtCore/QSet>
|
||||
|
||||
#include "NLPacket.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "udt/PacketHeaders.h"
|
||||
|
||||
class PacketListener;
|
||||
|
||||
|
|
|
@ -272,7 +272,7 @@ bool PacketSender::nonThreadedProcess() {
|
|||
unlock();
|
||||
|
||||
// send the packet through the NodeList...
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(*(packetPair.second), packetPair.first);
|
||||
DependencyManager::get<NodeList>()->sendUnreliablePacket(*packetPair.second, *packetPair.first);
|
||||
|
||||
packetsSentThisCall++;
|
||||
_packetsOverCheckInterval++;
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
#include "Packet.h"
|
||||
|
||||
#include "LimitedNodeList.h"
|
||||
|
||||
qint64 Packet::localHeaderSize(PacketType::Value type) {
|
||||
qint64 size = numBytesForArithmeticCodedPacketType(type) + sizeof(PacketVersion) +
|
||||
((SEQUENCE_NUMBERED_PACKETS.contains(type)) ? sizeof(SequenceNumber) : 0);
|
||||
|
@ -60,13 +58,13 @@ Packet::Packet(PacketType::Value type, qint64 size) :
|
|||
// default size of -1, means biggest packet possible
|
||||
size = maxPayload;
|
||||
}
|
||||
|
||||
|
||||
// Sanity check
|
||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||
|
||||
|
||||
// copy packet type and version in header
|
||||
writePacketTypeAndVersion(type);
|
||||
|
||||
|
||||
// Set control bit and sequence number to 0 if necessary
|
||||
if (SEQUENCE_NUMBERED_PACKETS.contains(type)) {
|
||||
writeSequenceNumber(0);
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include <QIODevice>
|
||||
|
||||
#include "HifiSockAddr.h"
|
||||
#include "../HifiSockAddr.h"
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
class Packet : public QIODevice {
|
|
@ -68,48 +68,48 @@ PacketVersion versionForPacketType(PacketType::Value packetType) {
|
|||
switch (packetType) {
|
||||
case MicrophoneAudioNoEcho:
|
||||
case MicrophoneAudioWithEcho:
|
||||
return 2;
|
||||
return 3;
|
||||
case SilentAudioFrame:
|
||||
return 4;
|
||||
return 5;
|
||||
case MixedAudio:
|
||||
return 1;
|
||||
case InjectAudio:
|
||||
return 1;
|
||||
case AvatarData:
|
||||
return 6;
|
||||
case AvatarIdentity:
|
||||
return 1;
|
||||
case EnvironmentData:
|
||||
return 2;
|
||||
case InjectAudio:
|
||||
return 2;
|
||||
case AvatarData:
|
||||
return 7;
|
||||
case AvatarIdentity:
|
||||
return 2;
|
||||
case EnvironmentData:
|
||||
return 3;
|
||||
case DomainList:
|
||||
case DomainListRequest:
|
||||
return 5;
|
||||
return 6;
|
||||
case DomainConnectRequest:
|
||||
return 1;
|
||||
return 2;
|
||||
case CreateAssignment:
|
||||
case RequestAssignment:
|
||||
return 2;
|
||||
return 3;
|
||||
case OctreeStats:
|
||||
return 1;
|
||||
return 2;
|
||||
case OctreeDataNack:
|
||||
return 1;
|
||||
return 2;
|
||||
case StopNode:
|
||||
return 1;
|
||||
return 2;
|
||||
case EntityAdd:
|
||||
case EntityEdit:
|
||||
case EntityData:
|
||||
return VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE;
|
||||
return VERSION_ENTITIES_NEW_PROTOCOL_LAYER;
|
||||
case EntityEditNack:
|
||||
return 1;
|
||||
case EntityErase:
|
||||
return 2;
|
||||
case EntityErase:
|
||||
return 3;
|
||||
case AudioStreamStats:
|
||||
return 1;
|
||||
return 2;
|
||||
case ICEServerHeartbeat:
|
||||
case ICEServerQuery:
|
||||
return 1;
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -83,6 +83,7 @@ namespace PacketType {
|
|||
ICEPingReply
|
||||
};
|
||||
};
|
||||
const int MAX_PACKET_SIZE = 1450;
|
||||
|
||||
typedef char PacketVersion;
|
||||
|
||||
|
@ -164,5 +165,6 @@ const PacketVersion VERSION_ENTITIES_FACE_CAMERA = 30;
|
|||
const PacketVersion VERSION_ENTITIES_SCRIPT_TIMESTAMP = 31;
|
||||
const PacketVersion VERSION_ENTITIES_SCRIPT_TIMESTAMP_FIX = 32;
|
||||
const PacketVersion VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE = 33;
|
||||
const PacketVersion VERSION_ENTITIES_NEW_PROTOCOL_LAYER = 34;
|
||||
|
||||
#endif // hifi_PacketHeaders_h
|
123
libraries/networking/src/udt/PacketList.cpp
Normal file
123
libraries/networking/src/udt/PacketList.cpp
Normal file
|
@ -0,0 +1,123 @@
|
|||
//
|
||||
// PacketList.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 7/13/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 "PacketList.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "Packet.h"
|
||||
|
||||
PacketList::PacketList(PacketType::Value packetType) : _packetType(packetType) {
|
||||
}
|
||||
|
||||
void PacketList::startSegment() {
|
||||
_segmentStartIndex = _currentPacket->pos();
|
||||
}
|
||||
|
||||
void PacketList::endSegment() {
|
||||
_segmentStartIndex = -1;
|
||||
}
|
||||
|
||||
std::unique_ptr<Packet> PacketList::createPacket() {
|
||||
// use the static create method to create a new packet
|
||||
return std::move(Packet::create(getType()));
|
||||
}
|
||||
|
||||
std::unique_ptr<Packet> PacketList::createPacketWithExtendedHeader() {
|
||||
// use the static create method to create a new packet
|
||||
auto packet = createPacket();
|
||||
|
||||
if (!_extendedHeader.isEmpty()) {
|
||||
// add the extended header to the front of the packet
|
||||
if (packet->write(_extendedHeader) == -1) {
|
||||
qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader"
|
||||
<< "- make sure that _extendedHeader is not larger than the payload capacity.";
|
||||
}
|
||||
}
|
||||
|
||||
return std::move(packet);
|
||||
}
|
||||
|
||||
qint64 PacketList::writeData(const char* data, qint64 maxSize) {
|
||||
if (!_currentPacket) {
|
||||
// we don't have a current packet, time to set one up
|
||||
_currentPacket = createPacketWithExtendedHeader();
|
||||
}
|
||||
|
||||
// check if this block of data can fit into the currentPacket
|
||||
if (maxSize <= _currentPacket->bytesAvailable()) {
|
||||
// it fits, just write it to the current packet
|
||||
_currentPacket->write(data, maxSize);
|
||||
|
||||
// return the number of bytes written
|
||||
return maxSize;
|
||||
} else {
|
||||
// it does not fit - this may need to be in the next packet
|
||||
|
||||
if (!_isOrdered) {
|
||||
auto newPacket = createPacketWithExtendedHeader();
|
||||
|
||||
if (_segmentStartIndex >= 0) {
|
||||
// We in the process of writing a segment for an unordered PacketList.
|
||||
// We need to try and pull the first part of the segment out to our new packet
|
||||
|
||||
// check now to see if this is an unsupported write
|
||||
int numBytesToEnd = _currentPacket->bytesAvailable();
|
||||
|
||||
if ((newPacket->size() - numBytesToEnd) < maxSize) {
|
||||
// this is an unsupported case - the segment is bigger than the size of an individual packet
|
||||
// but the PacketList is not going to be sent ordered
|
||||
qDebug() << "Error in PacketList::writeData - attempted to write a segment to an unordered packet that is"
|
||||
<< "larger than the payload size.";
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
// copy from currentPacket where the segment started to the beginning of the newPacket
|
||||
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, numBytesToEnd);
|
||||
|
||||
// the current segment now starts at the beginning of the new packet
|
||||
_segmentStartIndex = 0;
|
||||
|
||||
// shrink the current payload to the actual size of the packet
|
||||
_currentPacket->setSizeUsed(_segmentStartIndex);
|
||||
}
|
||||
|
||||
// move the current packet to our list of packets
|
||||
_packets.push_back(std::move(_currentPacket));
|
||||
|
||||
// write the data to the newPacket
|
||||
newPacket->write(data, maxSize);
|
||||
|
||||
// swap our current packet with the new packet
|
||||
_currentPacket.swap(newPacket);
|
||||
|
||||
// return the number of bytes written to the new packet
|
||||
return maxSize;
|
||||
} else {
|
||||
// we're an ordered PacketList - let's fit what we can into the current packet and then put the leftover
|
||||
// into a new packet
|
||||
|
||||
int numBytesToEnd = _currentPacket->bytesAvailable();
|
||||
_currentPacket->write(data, numBytesToEnd);
|
||||
|
||||
// move the current packet to our list of packets
|
||||
_packets.push_back(std::move(_currentPacket));
|
||||
|
||||
// recursively call our writeData method for the remaining data to write to a new packet
|
||||
return numBytesToEnd + writeData(data + numBytesToEnd, maxSize - numBytesToEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PacketList::closeCurrentPacket() {
|
||||
// move the current packet to our list of packets
|
||||
_packets.push_back(std::move(_currentPacket));
|
||||
}
|
86
libraries/networking/src/udt/PacketList.h
Normal file
86
libraries/networking/src/udt/PacketList.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
//
|
||||
// PacketList.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 7/13/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
|
||||
//
|
||||
|
||||
#ifndef hifi_PacketList_h
|
||||
#define hifi_PacketList_h
|
||||
|
||||
#include <QtCore/QIODevice>
|
||||
|
||||
#include "PacketHeaders.h"
|
||||
|
||||
class Packet;
|
||||
|
||||
class PacketList : public QIODevice {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PacketList(PacketType::Value packetType);
|
||||
|
||||
virtual bool isSequential() const { return true; }
|
||||
|
||||
void startSegment();
|
||||
void endSegment();
|
||||
|
||||
PacketType::Value getType() const { return _packetType; }
|
||||
int getNumPackets() const { return _packets.size() + (_currentPacket ? 1 : 0); }
|
||||
|
||||
void closeCurrentPacket();
|
||||
|
||||
void setExtendedHeader(const QByteArray& extendedHeader) { _extendedHeader = extendedHeader; }
|
||||
|
||||
template<typename T> qint64 readPrimitive(T* data);
|
||||
template<typename T> qint64 writePrimitive(const T& data);
|
||||
protected:
|
||||
virtual qint64 writeData(const char* data, qint64 maxSize);
|
||||
virtual qint64 readData(char* data, qint64 maxSize) { return 0; }
|
||||
|
||||
private:
|
||||
friend class LimitedNodeList;
|
||||
|
||||
PacketList(const PacketList& other) = delete;
|
||||
PacketList& operator=(const PacketList& other) = delete;
|
||||
|
||||
// Takes the first packet of the list and returns it.
|
||||
template<typename T> std::unique_ptr<T> takeFront();
|
||||
|
||||
// Creates a new packet, can be overriden to change return underlying type
|
||||
virtual std::unique_ptr<Packet> createPacket();
|
||||
std::unique_ptr<Packet> createPacketWithExtendedHeader();
|
||||
|
||||
PacketType::Value _packetType;
|
||||
bool _isOrdered = false;
|
||||
|
||||
std::unique_ptr<Packet> _currentPacket;
|
||||
std::list<std::unique_ptr<Packet>> _packets;
|
||||
|
||||
int _segmentStartIndex = -1;
|
||||
|
||||
QByteArray _extendedHeader;
|
||||
};
|
||||
|
||||
template <typename T> qint64 PacketList::readPrimitive(T* data) {
|
||||
static_assert(!std::is_pointer<T>::value, "T must not be a pointer");
|
||||
return QIODevice::read(reinterpret_cast<char*>(data), sizeof(T));
|
||||
}
|
||||
|
||||
template <typename T> qint64 PacketList::writePrimitive(const T& data) {
|
||||
static_assert(!std::is_pointer<T>::value, "T must not be a pointer");
|
||||
return QIODevice::write(reinterpret_cast<const char*>(&data), sizeof(T));
|
||||
}
|
||||
|
||||
template<typename T> std::unique_ptr<T> PacketList::takeFront() {
|
||||
static_assert(std::is_base_of<Packet, T>::value, "T must derive from Packet.");
|
||||
|
||||
auto packet = std::move(_packets.front());
|
||||
_packets.pop_front();
|
||||
return std::move(std::unique_ptr<T>(dynamic_cast<T*>(packet.release())));
|
||||
}
|
||||
|
||||
#endif // hifi_PacketList_h
|
12
libraries/networking/src/udt/udt.cpp
Normal file
12
libraries/networking/src/udt/udt.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// udt.cpp
|
||||
//
|
||||
//
|
||||
// Created by Clement on 7/13/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 "udt.h"
|
15
libraries/networking/src/udt/udt.h
Normal file
15
libraries/networking/src/udt/udt.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
//
|
||||
// udt.h
|
||||
//
|
||||
//
|
||||
// Created by Clement on 7/13/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
|
||||
//
|
||||
|
||||
#ifndef hifi_udt_h
|
||||
#define hifi_udt_h
|
||||
|
||||
#endif // hifi_udt_h
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <OctalCode.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include "JurisdictionListener.h"
|
||||
|
||||
JurisdictionListener::JurisdictionListener(NodeType_t type) :
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include <DependencyManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <OctalCode.h>
|
||||
|
||||
#include "OctreeLogging.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <OctalCode.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include "JurisdictionSender.h"
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <LogHandler.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <OctalCode.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
#include <Shape.h>
|
||||
#include <PathUtils.h>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <PerfStat.h>
|
||||
|
||||
#include <OctalCode.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include "OctreeLogging.h"
|
||||
#include "OctreeEditPacketSender.h"
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#define hifi_OctreeEditPacketSender_h
|
||||
|
||||
#include <PacketSender.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "JurisdictionMap.h"
|
||||
#include "SentPacketHistory.h"
|
||||
|
|
|
@ -219,7 +219,7 @@ void OctreeHeadlessViewer::queryOctree() {
|
|||
_octreeQuery.getBroadcastData(reinterpret_cast<unsigned char*>(queryPacket->getPayload()));
|
||||
|
||||
// ask the NodeList to send it
|
||||
nodeList->sendPacket(std::move(queryPacket), node);
|
||||
nodeList->sendPacket(std::move(queryPacket), *node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#ifndef hifi_OctreeHeadlessViewer_h
|
||||
#define hifi_OctreeHeadlessViewer_h
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include "JurisdictionListener.h"
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <QUuid>
|
||||
|
||||
#include <LimitedNodeList.h> // for MAX_PACKET_SIZE
|
||||
#include <PacketHeaders.h> // for MAX_PACKET_HEADER_BYTES
|
||||
#include <udt/PacketHeaders.h> // for MAX_PACKET_HEADER_BYTES
|
||||
#include <SharedUtil.h>
|
||||
#include <ShapeInfo.h>
|
||||
#include <BackgroundMode.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
//
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeQuery.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <RenderArgs.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#include <LogHandler.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
||||
#include "OctreePacketData.h"
|
||||
#include "OctreeElement.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <GeometryUtil.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <OctreePacketData.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <PathUtils.h>
|
||||
#include <SharedUtil.h>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <EntityScriptingInterface.h>
|
||||
#include <NetworkAccessManager.h>
|
||||
#include <NodeList.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <UUID.h>
|
||||
|
||||
#include "AnimationObject.h"
|
||||
|
@ -675,7 +675,7 @@ void ScriptEngine::run() {
|
|||
audioPacket->writePrimitive(sequence);
|
||||
|
||||
// send audio packet
|
||||
nodeList->sendUnreliablePacket(*audioPacket, node);
|
||||
nodeList->sendUnreliablePacket(*audioPacket, *node);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue