mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
some cleanup for audio/avatar replicated packet checking
This commit is contained in:
parent
f450e70f1e
commit
2933a20a0c
6 changed files with 39 additions and 34 deletions
|
@ -132,18 +132,10 @@ void AudioMixer::queueReplicatedAudioPacket(QSharedPointer<ReceivedMessage> mess
|
||||||
// construct a "fake" audio received message from the byte array and packet list information
|
// construct a "fake" audio received message from the byte array and packet list information
|
||||||
auto audioData = message->getMessage().mid(NUM_BYTES_RFC4122_UUID);
|
auto audioData = message->getMessage().mid(NUM_BYTES_RFC4122_UUID);
|
||||||
|
|
||||||
PacketType rewrittenType;
|
PacketType rewrittenType = REPLICATED_PACKET_MAPPING.key(message->getType());
|
||||||
|
|
||||||
if (message->getType() == PacketType::ReplicatedMicrophoneAudioNoEcho) {
|
if (rewrittenType == PacketType::Unknown) {
|
||||||
rewrittenType = PacketType::MicrophoneAudioNoEcho;
|
qDebug() << "Cannot unwrap replicated packet type not present in REPLICATED_PACKET_WRAPPING";
|
||||||
} else if (message->getType() == PacketType::ReplicatedMicrophoneAudioWithEcho) {
|
|
||||||
rewrittenType = PacketType::MicrophoneAudioWithEcho;
|
|
||||||
} else if (message->getType() == PacketType::ReplicatedInjectAudio) {
|
|
||||||
rewrittenType = PacketType::InjectAudio;
|
|
||||||
} else if (message->getType() == PacketType::ReplicatedSilentAudioFrame) {
|
|
||||||
rewrittenType = PacketType::SilentAudioFrame;
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(audioData, rewrittenType,
|
auto replicatedMessage = QSharedPointer<ReceivedMessage>::create(audioData, rewrittenType,
|
||||||
|
|
|
@ -124,27 +124,18 @@ void AudioMixerClientData::optionallyReplicatePacket(ReceivedMessage& message, c
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
// now make sure it's a packet type that we want to replicate
|
// now make sure it's a packet type that we want to replicate
|
||||||
PacketType mirroredType;
|
|
||||||
|
|
||||||
switch (message.getType()) {
|
// first check if it is an original type that we should replicate
|
||||||
case PacketType::MicrophoneAudioNoEcho:
|
PacketType mirroredType = REPLICATED_PACKET_MAPPING.value(message.getType());
|
||||||
case PacketType::ReplicatedMicrophoneAudioNoEcho:
|
|
||||||
mirroredType = PacketType::ReplicatedMicrophoneAudioNoEcho;
|
if (mirroredType == PacketType::Unknown) {
|
||||||
break;
|
// if it wasn't check if it is a replicated type that we should re-replicate
|
||||||
case PacketType::MicrophoneAudioWithEcho:
|
if (REPLICATED_PACKET_MAPPING.key(message.getType()) != PacketType::Unknown) {
|
||||||
case PacketType::ReplicatedMicrophoneAudioWithEcho:
|
mirroredType = message.getType();
|
||||||
mirroredType = PacketType::ReplicatedMicrophoneAudioWithEcho;
|
} else {
|
||||||
break;
|
qDebug() << "Packet passed to optionallyReplicatePacket was not a replicatable type - returning";
|
||||||
case PacketType::InjectAudio:
|
|
||||||
case PacketType::ReplicatedInjectAudio:
|
|
||||||
mirroredType = PacketType::ReplicatedInjectAudio;
|
|
||||||
break;
|
|
||||||
case PacketType::SilentAudioFrame:
|
|
||||||
case PacketType::ReplicatedSilentAudioFrame:
|
|
||||||
mirroredType = PacketType::ReplicatedSilentAudioFrame;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<NLPacket> packet;
|
std::unique_ptr<NLPacket> packet;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "PositionalAudioStream.h"
|
#include "PositionalAudioStream.h"
|
||||||
#include "AvatarAudioStream.h"
|
#include "AvatarAudioStream.h"
|
||||||
|
|
||||||
|
|
||||||
class AudioMixerClientData : public NodeData {
|
class AudioMixerClientData : public NodeData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -127,9 +127,21 @@ void AvatarMixer::handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessag
|
||||||
|
|
||||||
void AvatarMixer::optionallyReplicatePacket(ReceivedMessage& message, const Node& node) {
|
void AvatarMixer::optionallyReplicatePacket(ReceivedMessage& message, const Node& node) {
|
||||||
// first, make sure that this is a packet from a node we are supposed to replicate
|
// first, make sure that this is a packet from a node we are supposed to replicate
|
||||||
if (node.isReplicated()
|
if (node.isReplicated()) {
|
||||||
&& (message.getType() == PacketType::KillAvatar || message.getType() == PacketType::ReplicatedKillAvatar)) {
|
|
||||||
PacketType replicatedType = PacketType::ReplicatedKillAvatar;
|
// check if this is a packet type we replicate
|
||||||
|
// which means it must be a packet type present in REPLICATED_PACKET_MAPPING or must be the
|
||||||
|
// replicated version of one of those packet types
|
||||||
|
PacketType replicatedType = REPLICATED_PACKET_MAPPING.value(message.getType());
|
||||||
|
|
||||||
|
if (replicatedType == PacketType::Unknown) {
|
||||||
|
if (REPLICATED_PACKET_MAPPING.key(message.getType()) != PacketType::Unknown) {
|
||||||
|
replicatedType = message.getType();
|
||||||
|
} else {
|
||||||
|
qDebug() << __FUNCTION__ << "called without replicatable packet type - returning";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<NLPacket> packet;
|
std::unique_ptr<NLPacket> packet;
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,15 @@ const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
||||||
<< PacketType::ReplicatedInjectAudio << PacketType::ReplicatedSilentAudioFrame
|
<< PacketType::ReplicatedInjectAudio << PacketType::ReplicatedSilentAudioFrame
|
||||||
<< PacketType::ReplicatedAvatarIdentity << PacketType::ReplicatedKillAvatar << PacketType::ReplicatedBulkAvatarData;
|
<< PacketType::ReplicatedAvatarIdentity << PacketType::ReplicatedKillAvatar << PacketType::ReplicatedBulkAvatarData;
|
||||||
|
|
||||||
|
const QHash<PacketType, PacketType> REPLICATED_PACKET_MAPPING {
|
||||||
|
{ PacketType::MicrophoneAudioNoEcho, PacketType::ReplicatedMicrophoneAudioNoEcho },
|
||||||
|
{ PacketType::MicrophoneAudioWithEcho, PacketType::ReplicatedMicrophoneAudioWithEcho },
|
||||||
|
{ PacketType::InjectAudio, PacketType::ReplicatedInjectAudio },
|
||||||
|
{ PacketType::SilentAudioFrame, PacketType::ReplicatedSilentAudioFrame },
|
||||||
|
{ PacketType::AvatarIdentity, PacketType::ReplicatedAvatarIdentity },
|
||||||
|
{ PacketType::KillAvatar, PacketType::ReplicatedKillAvatar },
|
||||||
|
};
|
||||||
|
|
||||||
PacketVersion versionForPacketType(PacketType packetType) {
|
PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
switch (packetType) {
|
switch (packetType) {
|
||||||
case PacketType::DomainList:
|
case PacketType::DomainList:
|
||||||
|
|
|
@ -128,6 +128,8 @@ public:
|
||||||
|
|
||||||
using PacketType = PacketTypeEnum::Value;
|
using PacketType = PacketTypeEnum::Value;
|
||||||
|
|
||||||
|
extern const QHash<PacketType, PacketType> REPLICATED_PACKET_MAPPING;
|
||||||
|
|
||||||
const int NUM_BYTES_MD5_HASH = 16;
|
const int NUM_BYTES_MD5_HASH = 16;
|
||||||
|
|
||||||
typedef char PacketVersion;
|
typedef char PacketVersion;
|
||||||
|
|
Loading…
Reference in a new issue