mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 08:22:30 +02:00
when getting unexpected codec in the mixer, send a message to the client to select a different codec
This commit is contained in:
parent
20824f038c
commit
2e63aba8c9
5 changed files with 26 additions and 9 deletions
|
@ -525,7 +525,6 @@ void AudioMixer::handleNegotiateAudioFormat(QSharedPointer<ReceivedMessage> mess
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
auto clientData = dynamic_cast<AudioMixerClientData*>(sendingNode->getLinkedData());
|
||||
|
||||
// FIXME - why would we not have client data at this point??
|
||||
|
@ -539,14 +538,7 @@ void AudioMixer::handleNegotiateAudioFormat(QSharedPointer<ReceivedMessage> mess
|
|||
clientData->setupCodec(selectedCodec, selectedCodecName);
|
||||
|
||||
qDebug() << "selectedCodecName:" << selectedCodecName;
|
||||
|
||||
auto replyPacket = NLPacket::create(PacketType::SelectedAudioFormat);
|
||||
|
||||
// write them to our packet
|
||||
replyPacket->writeString(selectedCodecName);
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
nodeList->sendPacket(std::move(replyPacket), *sendingNode);
|
||||
clientData->sendSelectAudioFormat(sendingNode, selectedCodecName);
|
||||
}
|
||||
|
||||
void AudioMixer::handleNodeKilled(SharedNodePointer killedNode) {
|
||||
|
|
|
@ -113,6 +113,8 @@ int AudioMixerClientData::parseData(ReceivedMessage& message) {
|
|||
avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO);
|
||||
qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName;
|
||||
|
||||
connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::sendSelectAudioFormat);
|
||||
|
||||
auto emplaced = _audioStreams.emplace(
|
||||
QUuid(),
|
||||
std::unique_ptr<PositionalAudioStream> { avatarAudioStream }
|
||||
|
@ -344,6 +346,16 @@ QJsonObject AudioMixerClientData::getAudioStreamStats() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void AudioMixerClientData::sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName) {
|
||||
auto replyPacket = NLPacket::create(PacketType::SelectedAudioFormat);
|
||||
|
||||
// write them to our packet
|
||||
replyPacket->writeString(selectedCodecName);
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
nodeList->sendPacket(std::move(replyPacket), *node);
|
||||
}
|
||||
|
||||
|
||||
void AudioMixerClientData::setupCodec(CodecPluginPointer codec, const QString& codecName) {
|
||||
cleanupCodec(); // cleanup any previously allocated coders first
|
||||
_codec = codec;
|
||||
|
|
|
@ -84,6 +84,9 @@ public:
|
|||
signals:
|
||||
void injectorStreamFinished(const QUuid& streamIdentifier);
|
||||
|
||||
public slots:
|
||||
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
||||
|
||||
private:
|
||||
QReadWriteLock _streamsLock;
|
||||
AudioStreamMap _audioStreams; // microphone stream from avatar is stored under key of null UUID
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <NLPacket.h>
|
||||
#include <Node.h>
|
||||
#include <NodeList.h>
|
||||
|
||||
#include "InboundAudioStream.h"
|
||||
|
||||
|
@ -147,7 +148,12 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
|
|||
parseAudioData(message.getType(), afterProperties);
|
||||
} else {
|
||||
qDebug() << __FUNCTION__ << "codec mismatch: expected" << _selectedCodecName << "got" << codecInPacket << "writing silence";
|
||||
|
||||
writeDroppableSilentSamples(networkSamples);
|
||||
|
||||
// inform others of the mismatch
|
||||
auto sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(message.getSourceID());
|
||||
emit mismatchedAudioCodec(sendingNode, _selectedCodecName);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#ifndef hifi_InboundAudioStream_h
|
||||
#define hifi_InboundAudioStream_h
|
||||
|
||||
#include <Node.h>
|
||||
#include <NodeData.h>
|
||||
#include <NumericalConstants.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
|
@ -180,6 +181,9 @@ public:
|
|||
void setupCodec(CodecPluginPointer codec, const QString& codecName, int numChannels);
|
||||
void cleanupCodec();
|
||||
|
||||
signals:
|
||||
void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& desiredCodec);
|
||||
|
||||
public slots:
|
||||
/// This function should be called every second for all the stats to function properly. If dynamic jitter buffers
|
||||
/// is enabled, those stats are used to calculate _desiredJitterBufferFrames.
|
||||
|
|
Loading…
Reference in a new issue