mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-12 12:54:25 +02:00
mv codec init to ctor from negotiateCodecs
This commit is contained in:
parent
06c8fba35d
commit
41a4ec4200
2 changed files with 18 additions and 23 deletions
|
@ -47,15 +47,21 @@ static const QString AUDIO_THREADING_GROUP_KEY = "audio_threading";
|
||||||
int AudioMixer::_numStaticJitterFrames{ -1 };
|
int AudioMixer::_numStaticJitterFrames{ -1 };
|
||||||
float AudioMixer::_noiseMutingThreshold{ DEFAULT_NOISE_MUTING_THRESHOLD };
|
float AudioMixer::_noiseMutingThreshold{ DEFAULT_NOISE_MUTING_THRESHOLD };
|
||||||
float AudioMixer::_attenuationPerDoublingInDistance{ DEFAULT_ATTENUATION_PER_DOUBLING_IN_DISTANCE };
|
float AudioMixer::_attenuationPerDoublingInDistance{ DEFAULT_ATTENUATION_PER_DOUBLING_IN_DISTANCE };
|
||||||
QString AudioMixer::_codecPreferenceOrder{};
|
std::map<QString, std::shared_ptr<CodecPlugin>> AudioMixer::_availableCodecs{ };
|
||||||
|
QStringList AudioMixer::_codecPreferenceOrder{};
|
||||||
QHash<QString, AABox> AudioMixer::_audioZones;
|
QHash<QString, AABox> AudioMixer::_audioZones;
|
||||||
QVector<AudioMixer::ZoneSettings> AudioMixer::_zoneSettings;
|
QVector<AudioMixer::ZoneSettings> AudioMixer::_zoneSettings;
|
||||||
QVector<AudioMixer::ReverbSettings> AudioMixer::_zoneReverbSettings;
|
QVector<AudioMixer::ReverbSettings> AudioMixer::_zoneReverbSettings;
|
||||||
|
|
||||||
AudioMixer::AudioMixer(ReceivedMessage& message) :
|
AudioMixer::AudioMixer(ReceivedMessage& message) :
|
||||||
ThreadedAssignment(message) {
|
ThreadedAssignment(message) {
|
||||||
// initialize the plugins
|
|
||||||
PluginManager::getInstance()->getCodecPlugins();
|
// hash the available codecs (on the mixer)
|
||||||
|
auto codecPlugins = PluginManager::getInstance()->getCodecPlugins();
|
||||||
|
std::for_each(codecPlugins.cbegin(), codecPlugins.cend(),
|
||||||
|
[&](const CodecPluginPointer& codec) {
|
||||||
|
_availableCodecs[codec->getName()] = codec;
|
||||||
|
});
|
||||||
|
|
||||||
auto nodeList = DependencyManager::get<NodeList>();
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||||
|
@ -134,34 +140,21 @@ const std::pair<QString, CodecPluginPointer> AudioMixer::negotiateCodec(std::vec
|
||||||
QString selectedCodecName;
|
QString selectedCodecName;
|
||||||
CodecPluginPointer selectedCodec;
|
CodecPluginPointer selectedCodec;
|
||||||
|
|
||||||
// get the available codecs (on the mixer)
|
|
||||||
auto codecPlugins = PluginManager::getInstance()->getCodecPlugins();
|
|
||||||
std::map<QString, CodecPluginPointer> availableCodecs;
|
|
||||||
std::for_each(codecPlugins.cbegin(), codecPlugins.cend(),
|
|
||||||
[&availableCodecs](const CodecPluginPointer& codec) {
|
|
||||||
availableCodecs[codec->getName()] = codec;
|
|
||||||
});
|
|
||||||
|
|
||||||
// get the codec preferences (on the mixer)
|
|
||||||
QStringList codecPreferenceList = _codecPreferenceOrder.split(",");
|
|
||||||
|
|
||||||
// read the codecs requested (by the client)
|
// read the codecs requested (by the client)
|
||||||
const int MAX_PREFERENCE = 99999;
|
int minPreference = std::numeric_limits<int>::max();
|
||||||
int minPreference = MAX_PREFERENCE;
|
|
||||||
for (auto& codec : codecs) {
|
for (auto& codec : codecs) {
|
||||||
bool codecAvailable = (availableCodecs.count(codec) > 0);
|
if (_availableCodecs.count(codec) > 0) {
|
||||||
|
int preference = _codecPreferenceOrder.indexOf(codec);
|
||||||
|
|
||||||
if (codecAvailable) {
|
// choose the preferred, available codec
|
||||||
int preference = codecPreferenceList.indexOf(codec);
|
|
||||||
if (preference >= 0 && preference < minPreference) {
|
if (preference >= 0 && preference < minPreference) {
|
||||||
minPreference = preference;
|
minPreference = preference;
|
||||||
// choose the preferred, available codec
|
|
||||||
selectedCodecName = codec;
|
selectedCodecName = codec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_pair(selectedCodecName, availableCodecs[selectedCodecName]);
|
return std::make_pair(selectedCodecName, _availableCodecs[selectedCodecName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioMixer::handleNodeKilled(SharedNodePointer killedNode) {
|
void AudioMixer::handleNodeKilled(SharedNodePointer killedNode) {
|
||||||
|
@ -582,7 +575,8 @@ void AudioMixer::parseSettingsObject(const QJsonObject &settingsObject) {
|
||||||
|
|
||||||
const QString CODEC_PREFERENCE_ORDER = "codec_preference_order";
|
const QString CODEC_PREFERENCE_ORDER = "codec_preference_order";
|
||||||
if (audioEnvGroupObject[CODEC_PREFERENCE_ORDER].isString()) {
|
if (audioEnvGroupObject[CODEC_PREFERENCE_ORDER].isString()) {
|
||||||
_codecPreferenceOrder = audioEnvGroupObject[CODEC_PREFERENCE_ORDER].toString();
|
QString codecPreferenceOrder = audioEnvGroupObject[CODEC_PREFERENCE_ORDER].toString();
|
||||||
|
_codecPreferenceOrder = codecPreferenceOrder.split(",");
|
||||||
qDebug() << "Codec preference order changed to" << _codecPreferenceOrder;
|
qDebug() << "Codec preference order changed to" << _codecPreferenceOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,8 @@ private:
|
||||||
static int _numStaticJitterFrames; // -1 denotes dynamic jitter buffering
|
static int _numStaticJitterFrames; // -1 denotes dynamic jitter buffering
|
||||||
static float _noiseMutingThreshold;
|
static float _noiseMutingThreshold;
|
||||||
static float _attenuationPerDoublingInDistance;
|
static float _attenuationPerDoublingInDistance;
|
||||||
static QString _codecPreferenceOrder;
|
static std::map<QString, CodecPluginPointer> _availableCodecs;
|
||||||
|
static QStringList _codecPreferenceOrder;
|
||||||
static QHash<QString, AABox> _audioZones;
|
static QHash<QString, AABox> _audioZones;
|
||||||
static QVector<ZoneSettings> _zoneSettings;
|
static QVector<ZoneSettings> _zoneSettings;
|
||||||
static QVector<ReverbSettings> _zoneReverbSettings;
|
static QVector<ReverbSettings> _zoneReverbSettings;
|
||||||
|
|
Loading…
Reference in a new issue