mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:48:44 +02:00
only replicate packets for agents being replicated
This commit is contained in:
parent
1868971cfc
commit
03a8d7b8c8
2 changed files with 45 additions and 34 deletions
|
@ -80,8 +80,8 @@ void AudioMixerClientData::processPackets() {
|
||||||
|
|
||||||
QMutexLocker lock(&getMutex());
|
QMutexLocker lock(&getMutex());
|
||||||
parseData(*packet);
|
parseData(*packet);
|
||||||
|
|
||||||
replicatePacket(*packet);
|
optionallyReplicatePacket(*packet, *node);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -109,41 +109,52 @@ void AudioMixerClientData::processPackets() {
|
||||||
assert(_packetQueue.empty());
|
assert(_packetQueue.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixerClientData::replicatePacket(ReceivedMessage& message) {
|
void AudioMixerClientData::optionallyReplicatePacket(ReceivedMessage& message, const Node& node) {
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
|
||||||
|
|
||||||
PacketType mirroredType;
|
// first, make sure that this is a packet from a node we are supposed to replicate
|
||||||
|
if (node.isReplicated()) {
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
|
||||||
if (message.getType() == PacketType::MicrophoneAudioNoEcho) {
|
// now make sure it's a packet type that we want to replicate
|
||||||
mirroredType = PacketType::ReplicatedMicrophoneAudioNoEcho;
|
PacketType mirroredType;
|
||||||
} else if (message.getType() == PacketType::MicrophoneAudioWithEcho) {
|
|
||||||
mirroredType = PacketType::ReplicatedMicrophoneAudioNoEcho;
|
if (message.getType() == PacketType::MicrophoneAudioNoEcho) {
|
||||||
} else if (message.getType() == PacketType::InjectAudio) {
|
mirroredType = PacketType::ReplicatedMicrophoneAudioNoEcho;
|
||||||
mirroredType = PacketType::ReplicatedInjectAudio;
|
} else if (message.getType() == PacketType::MicrophoneAudioWithEcho) {
|
||||||
} else if (message.getType() == PacketType::SilentAudioFrame) {
|
mirroredType = PacketType::ReplicatedMicrophoneAudioNoEcho;
|
||||||
mirroredType = PacketType::ReplicatedSilentAudioFrame;
|
} else if (message.getType() == PacketType::InjectAudio) {
|
||||||
} else {
|
mirroredType = PacketType::ReplicatedInjectAudio;
|
||||||
return;
|
} else if (message.getType() == PacketType::SilentAudioFrame) {
|
||||||
|
mirroredType = PacketType::ReplicatedSilentAudioFrame;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<NLPacket> packet;
|
||||||
|
|
||||||
|
// enumerate the replicant audio mixers and send them the replicated version of this packet
|
||||||
|
nodeList->eachMatchingNode([&](const SharedNodePointer& node)->bool {
|
||||||
|
return node->getType() == NodeType::DownstreamAudioMixer;
|
||||||
|
}, [&](const SharedNodePointer& node) {
|
||||||
|
// construct the packet only once, if we have any downstream audio mixers to send to
|
||||||
|
if (!packet) {
|
||||||
|
// construct an NLPacket to send to the replicant that has the contents of the received packet
|
||||||
|
packet = NLPacket::create(mirroredType);
|
||||||
|
|
||||||
|
// since this packet will be non-sourced, we add the replicated node's ID here
|
||||||
|
packet->write(message.getSourceID().toRfc4122());
|
||||||
|
|
||||||
|
// we won't negotiate an audio format with the replicant, because we aren't a listener
|
||||||
|
// so pack the codec string here so that it can statelessly setup a decoder for this string when it needs
|
||||||
|
packet->writeString(_selectedCodecName);
|
||||||
|
|
||||||
|
packet->write(message.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeList->sendUnreliablePacket(*packet, node->getPublicSocket());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct an NLPacket to send to the replicant that has the contents of the received packet
|
|
||||||
auto packet = NLPacket::create(mirroredType);
|
|
||||||
|
|
||||||
// since this packet will be non-sourced, we add the replicated node's ID here
|
|
||||||
packet->write(message.getSourceID().toRfc4122());
|
|
||||||
|
|
||||||
// we won't negotiate an audio format with the replicant, because we aren't a listener
|
|
||||||
// so pack the codec string here so that it can statelessly setup a decoder for this string when it needs
|
|
||||||
packet->writeString(_selectedCodecName);
|
|
||||||
|
|
||||||
packet->write(message.getMessage());
|
|
||||||
|
|
||||||
// enumerate the replicant audio mixers and send them the replicated version of this packet
|
|
||||||
nodeList->eachMatchingNode([&](const SharedNodePointer& node)->bool {
|
|
||||||
return node->getType() == NodeType::DownstreamAudioMixer;
|
|
||||||
}, [&](const SharedNodePointer& node) {
|
|
||||||
nodeList->sendUnreliablePacket(*packet, node->getPublicSocket());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixerClientData::negotiateAudioFormat(ReceivedMessage& message, const SharedNodePointer& node) {
|
void AudioMixerClientData::negotiateAudioFormat(ReceivedMessage& message, const SharedNodePointer& node) {
|
||||||
|
|
|
@ -126,7 +126,7 @@ private:
|
||||||
QReadWriteLock _streamsLock;
|
QReadWriteLock _streamsLock;
|
||||||
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
||||||
|
|
||||||
void replicatePacket(ReceivedMessage& packet);
|
void optionallyReplicatePacket(ReceivedMessage& packet, const Node& node);
|
||||||
|
|
||||||
using IgnoreZone = AABox;
|
using IgnoreZone = AABox;
|
||||||
class IgnoreZoneMemo {
|
class IgnoreZoneMemo {
|
||||||
|
|
Loading…
Reference in a new issue