mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:29:40 +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());
|
auto clientData = dynamic_cast<AudioMixerClientData*>(sendingNode->getLinkedData());
|
||||||
|
|
||||||
// FIXME - why would we not have client data at this point??
|
// 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);
|
clientData->setupCodec(selectedCodec, selectedCodecName);
|
||||||
|
|
||||||
qDebug() << "selectedCodecName:" << selectedCodecName;
|
qDebug() << "selectedCodecName:" << selectedCodecName;
|
||||||
|
clientData->sendSelectAudioFormat(sendingNode, 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixer::handleNodeKilled(SharedNodePointer killedNode) {
|
void AudioMixer::handleNodeKilled(SharedNodePointer killedNode) {
|
||||||
|
|
|
@ -113,6 +113,8 @@ int AudioMixerClientData::parseData(ReceivedMessage& message) {
|
||||||
avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO);
|
avatarAudioStream->setupCodec(_codec, _selectedCodecName, AudioConstants::MONO);
|
||||||
qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName;
|
qDebug() << "creating new AvatarAudioStream... codec:" << _selectedCodecName;
|
||||||
|
|
||||||
|
connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::sendSelectAudioFormat);
|
||||||
|
|
||||||
auto emplaced = _audioStreams.emplace(
|
auto emplaced = _audioStreams.emplace(
|
||||||
QUuid(),
|
QUuid(),
|
||||||
std::unique_ptr<PositionalAudioStream> { avatarAudioStream }
|
std::unique_ptr<PositionalAudioStream> { avatarAudioStream }
|
||||||
|
@ -344,6 +346,16 @@ QJsonObject AudioMixerClientData::getAudioStreamStats() {
|
||||||
return result;
|
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) {
|
void AudioMixerClientData::setupCodec(CodecPluginPointer codec, const QString& codecName) {
|
||||||
cleanupCodec(); // cleanup any previously allocated coders first
|
cleanupCodec(); // cleanup any previously allocated coders first
|
||||||
_codec = codec;
|
_codec = codec;
|
||||||
|
|
|
@ -84,6 +84,9 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void injectorStreamFinished(const QUuid& streamIdentifier);
|
void injectorStreamFinished(const QUuid& streamIdentifier);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void sendSelectAudioFormat(SharedNodePointer node, const QString& selectedCodecName);
|
||||||
|
|
||||||
private:
|
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
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <NLPacket.h>
|
#include <NLPacket.h>
|
||||||
#include <Node.h>
|
#include <Node.h>
|
||||||
|
#include <NodeList.h>
|
||||||
|
|
||||||
#include "InboundAudioStream.h"
|
#include "InboundAudioStream.h"
|
||||||
|
|
||||||
|
@ -147,7 +148,12 @@ int InboundAudioStream::parseData(ReceivedMessage& message) {
|
||||||
parseAudioData(message.getType(), afterProperties);
|
parseAudioData(message.getType(), afterProperties);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << __FUNCTION__ << "codec mismatch: expected" << _selectedCodecName << "got" << codecInPacket << "writing silence";
|
qDebug() << __FUNCTION__ << "codec mismatch: expected" << _selectedCodecName << "got" << codecInPacket << "writing silence";
|
||||||
|
|
||||||
writeDroppableSilentSamples(networkSamples);
|
writeDroppableSilentSamples(networkSamples);
|
||||||
|
|
||||||
|
// inform others of the mismatch
|
||||||
|
auto sendingNode = DependencyManager::get<NodeList>()->nodeWithUUID(message.getSourceID());
|
||||||
|
emit mismatchedAudioCodec(sendingNode, _selectedCodecName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#ifndef hifi_InboundAudioStream_h
|
#ifndef hifi_InboundAudioStream_h
|
||||||
#define hifi_InboundAudioStream_h
|
#define hifi_InboundAudioStream_h
|
||||||
|
|
||||||
|
#include <Node.h>
|
||||||
#include <NodeData.h>
|
#include <NodeData.h>
|
||||||
#include <NumericalConstants.h>
|
#include <NumericalConstants.h>
|
||||||
#include <udt/PacketHeaders.h>
|
#include <udt/PacketHeaders.h>
|
||||||
|
@ -180,6 +181,9 @@ public:
|
||||||
void setupCodec(CodecPluginPointer codec, const QString& codecName, int numChannels);
|
void setupCodec(CodecPluginPointer codec, const QString& codecName, int numChannels);
|
||||||
void cleanupCodec();
|
void cleanupCodec();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void mismatchedAudioCodec(SharedNodePointer sendingNode, const QString& desiredCodec);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/// This function should be called every second for all the stats to function properly. If dynamic jitter buffers
|
/// 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.
|
/// is enabled, those stats are used to calculate _desiredJitterBufferFrames.
|
||||||
|
|
Loading…
Reference in a new issue