mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 19:50:38 +02:00
fixes for new read and NLPacketList
This commit is contained in:
parent
ad63be4efc
commit
0f534b9f7b
9 changed files with 31 additions and 22 deletions
|
@ -204,8 +204,7 @@ void AssignmentClientMonitor::checkSpares() {
|
||||||
|
|
||||||
void AssignmentClientMonitor::handleChildStatusPacket(QSharedPointer<NLPacket> packet) {
|
void AssignmentClientMonitor::handleChildStatusPacket(QSharedPointer<NLPacket> packet) {
|
||||||
// read out the sender ID
|
// read out the sender ID
|
||||||
QUuid senderID = QUuid::fromRfc4122(QByteArray::fromRawData(packet->getPayload(), NUM_BYTES_RFC4122_UUID));
|
QUuid senderID = QUuid::fromRfc4122(packet->read(NUM_BYTES_RFC4122_UUID));
|
||||||
packet->seek(NUM_BYTES_RFC4122_UUID);
|
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,7 @@
|
||||||
|
|
||||||
int AvatarMixerClientData::parseData(NLPacket& packet) {
|
int AvatarMixerClientData::parseData(NLPacket& packet) {
|
||||||
// compute the offset to the data payload
|
// compute the offset to the data payload
|
||||||
QByteArray byteArray = QByteArray::fromRawData(packet.getPayload() + packet.pos(),
|
return _avatar.parseDataFromBuffer(packet.read(packet.bytesLeftToRead()));
|
||||||
packet.bytesLeftToRead());
|
|
||||||
return _avatar.parseDataFromBuffer(byteArray);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AvatarMixerClientData::checkAndSetHasReceivedFirstPackets() {
|
bool AvatarMixerClientData::checkAndSetHasReceivedFirstPackets() {
|
||||||
|
|
|
@ -971,13 +971,13 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
||||||
// this data is at the beginning of each of the domain list packets
|
// this data is at the beginning of each of the domain list packets
|
||||||
QByteArray extendedHeader(NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES, 0);
|
QByteArray extendedHeader(NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES, 0);
|
||||||
QDataStream extendedHeaderStream(&extendedHeader, QIODevice::WriteOnly);
|
QDataStream extendedHeaderStream(&extendedHeader, QIODevice::WriteOnly);
|
||||||
|
|
||||||
|
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||||
|
|
||||||
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
||||||
extendedHeaderStream << node->getUUID();
|
extendedHeaderStream << node->getUUID();
|
||||||
extendedHeaderStream << (quint8) node->getCanAdjustLocks();
|
extendedHeaderStream << (quint8) node->getCanAdjustLocks();
|
||||||
extendedHeaderStream << (quint8) node->getCanRez();
|
extendedHeaderStream << (quint8) node->getCanRez();
|
||||||
|
|
||||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
|
||||||
|
|
||||||
NLPacketList domainListPackets(PacketType::DomainList, extendedHeader);
|
NLPacketList domainListPackets(PacketType::DomainList, extendedHeader);
|
||||||
|
|
||||||
|
|
|
@ -112,9 +112,7 @@ int InboundAudioStream::parseData(NLPacket& packet) {
|
||||||
int networkSamples;
|
int networkSamples;
|
||||||
|
|
||||||
// parse the info after the seq number and before the audio data (the stream properties)
|
// parse the info after the seq number and before the audio data (the stream properties)
|
||||||
int propertyBytes = parseStreamProperties(packet.getType(),
|
int propertyBytes = parseStreamProperties(packet.getType(), packet.read(packet.bytesLeftToRead()), networkSamples);
|
||||||
QByteArray::fromRawData(packet.getPayload() + packet.pos(), packet.bytesLeftToRead()),
|
|
||||||
networkSamples);
|
|
||||||
packet.seek(packet.pos() + propertyBytes);
|
packet.seek(packet.pos() + propertyBytes);
|
||||||
|
|
||||||
// handle this packet based on its arrival status.
|
// handle this packet based on its arrival status.
|
||||||
|
@ -133,10 +131,7 @@ int InboundAudioStream::parseData(NLPacket& packet) {
|
||||||
if (packet.getType() == PacketType::SilentAudioFrame) {
|
if (packet.getType() == PacketType::SilentAudioFrame) {
|
||||||
writeDroppableSilentSamples(networkSamples);
|
writeDroppableSilentSamples(networkSamples);
|
||||||
} else {
|
} else {
|
||||||
int audioBytes = parseAudioData(packet.getType(),
|
int audioBytes = parseAudioData(packet.getType(), packet.read(packet.bytesLeftToRead()), networkSamples);
|
||||||
QByteArray::fromRawData(packet.getPayload() + packet.pos(),
|
|
||||||
packet.bytesLeftToRead()),
|
|
||||||
networkSamples);
|
|
||||||
packet.seek(packet.pos() + audioBytes);
|
packet.seek(packet.pos() + audioBytes);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -55,8 +55,8 @@ void AvatarHashMap::processAvatarDataPacket(QSharedPointer<NLPacket> packet, Sha
|
||||||
while (packet->bytesLeftToRead()) {
|
while (packet->bytesLeftToRead()) {
|
||||||
QUuid sessionUUID = QUuid::fromRfc4122(packet->read(NUM_BYTES_RFC4122_UUID));
|
QUuid sessionUUID = QUuid::fromRfc4122(packet->read(NUM_BYTES_RFC4122_UUID));
|
||||||
|
|
||||||
QByteArray byteArray = QByteArray::fromRawData(packet->getPayload() + packet->pos(),
|
QByteArray byteArray = packet->read(packet->bytesLeftToRead());
|
||||||
packet->bytesLeftToRead());
|
|
||||||
if (sessionUUID != _lastOwnerSessionUUID) {
|
if (sessionUUID != _lastOwnerSessionUUID) {
|
||||||
AvatarSharedPointer avatar = _avatarHash.value(sessionUUID);
|
AvatarSharedPointer avatar = _avatarHash.value(sessionUUID);
|
||||||
if (!avatar) {
|
if (!avatar) {
|
||||||
|
|
|
@ -13,7 +13,16 @@
|
||||||
|
|
||||||
#include "NLPacket.h"
|
#include "NLPacket.h"
|
||||||
|
|
||||||
NLPacketList::NLPacketList(PacketType::Value packetType) : PacketList(packetType) {
|
NLPacketList::NLPacketList(PacketType::Value packetType) :
|
||||||
|
PacketList(packetType)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NLPacketList::NLPacketList(PacketType::Value packetType, const QByteArray& extendedHeader) :
|
||||||
|
PacketList(packetType, extendedHeader)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Packet> NLPacketList::createPacket() {
|
std::unique_ptr<Packet> NLPacketList::createPacket() {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
class NLPacketList : public PacketList {
|
class NLPacketList : public PacketList {
|
||||||
public:
|
public:
|
||||||
NLPacketList(PacketType::Value packetType);
|
NLPacketList(PacketType::Value packetType);
|
||||||
|
NLPacketList(PacketType::Value packetType, const QByteArray& extendedHeader);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NLPacketList(const NLPacketList& other) = delete;
|
NLPacketList(const NLPacketList& other) = delete;
|
||||||
|
|
|
@ -18,11 +18,18 @@
|
||||||
PacketList::PacketList(PacketType::Value packetType) :
|
PacketList::PacketList(PacketType::Value packetType) :
|
||||||
_packetType(packetType)
|
_packetType(packetType)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketList::PacketList(PacketType::Value packetType, const QByteArray& extendedHeader) :
|
||||||
|
_packetType(packetType),
|
||||||
|
_extendedHeader(extendedHeader)
|
||||||
|
{
|
||||||
QIODevice::open(WriteOnly);
|
QIODevice::open(WriteOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::startSegment() {
|
void PacketList::startSegment() {
|
||||||
_segmentStartIndex = _currentPacket ? _currentPacket->pos() : 0;
|
_segmentStartIndex = _currentPacket ? _currentPacket->pos() : _extendedHeader.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketList::endSegment() {
|
void PacketList::endSegment() {
|
||||||
|
@ -39,6 +46,7 @@ std::unique_ptr<Packet> PacketList::createPacketWithExtendedHeader() {
|
||||||
auto packet = createPacket();
|
auto packet = createPacket();
|
||||||
|
|
||||||
if (!_extendedHeader.isEmpty()) {
|
if (!_extendedHeader.isEmpty()) {
|
||||||
|
qDebug() << "Writing a header of" << _extendedHeader.size();
|
||||||
// add the extended header to the front of the packet
|
// add the extended header to the front of the packet
|
||||||
if (packet->write(_extendedHeader) == -1) {
|
if (packet->write(_extendedHeader) == -1) {
|
||||||
qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader"
|
qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader"
|
||||||
|
@ -89,7 +97,7 @@ qint64 PacketList::writeData(const char* data, qint64 maxSize) {
|
||||||
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, segmentSize);
|
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, segmentSize);
|
||||||
|
|
||||||
// the current segment now starts at the beginning of the new packet
|
// the current segment now starts at the beginning of the new packet
|
||||||
_segmentStartIndex = 0;
|
_segmentStartIndex = _extendedHeader.size();
|
||||||
|
|
||||||
// shrink the current payload to the actual size of the packet
|
// shrink the current payload to the actual size of the packet
|
||||||
_currentPacket->setPayloadSize(_segmentStartIndex);
|
_currentPacket->setPayloadSize(_segmentStartIndex);
|
||||||
|
|
|
@ -22,6 +22,7 @@ class PacketList : public QIODevice {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
PacketList(PacketType::Value packetType);
|
PacketList(PacketType::Value packetType);
|
||||||
|
PacketList(PacketType::Value packetType, const QByteArray& extendedHeader);
|
||||||
|
|
||||||
virtual bool isSequential() const { return true; }
|
virtual bool isSequential() const { return true; }
|
||||||
|
|
||||||
|
@ -33,8 +34,6 @@ public:
|
||||||
|
|
||||||
void closeCurrentPacket(bool shouldSendEmpty = false);
|
void closeCurrentPacket(bool shouldSendEmpty = false);
|
||||||
|
|
||||||
void setExtendedHeader(const QByteArray& extendedHeader) { _extendedHeader = extendedHeader; }
|
|
||||||
|
|
||||||
template<typename T> qint64 readPrimitive(T* data);
|
template<typename T> qint64 readPrimitive(T* data);
|
||||||
template<typename T> qint64 writePrimitive(const T& data);
|
template<typename T> qint64 writePrimitive(const T& data);
|
||||||
protected:
|
protected:
|
||||||
|
@ -83,4 +82,4 @@ template<typename T> std::unique_ptr<T> PacketList::takeFront() {
|
||||||
return std::unique_ptr<T>(dynamic_cast<T*>(packet.release()));
|
return std::unique_ptr<T>(dynamic_cast<T*>(packet.release()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // hifi_PacketList_h
|
#endif // hifi_PacketList_h
|
||||||
|
|
Loading…
Reference in a new issue