From eabc1b5c3dc281529d14dd3caf94cfd7ef5d88de Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Thu, 8 Sep 2022 20:54:01 +0300 Subject: [PATCH] - add stun server IP setting + fix problem when processing incoming audio data --- src/engine/agent/Agent_Impl.cpp | 1 + src/engine/audio/Audio_DevicePair.cpp | 9 +++++++-- src/engine/media/MT_AudioReceiver.cpp | 12 ++++++++++-- src/engine/media/MT_CodecList.cpp | 10 ++++++---- src/libs/resiprocate/resip/stack/ssl/Security.cxx | 4 ++-- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/engine/agent/Agent_Impl.cpp b/src/engine/agent/Agent_Impl.cpp index cdca39f0..5082206e 100644 --- a/src/engine/agent/Agent_Impl.cpp +++ b/src/engine/agent/Agent_Impl.cpp @@ -190,6 +190,7 @@ void AgentImpl::processConfig(JsonCpp::Value &d, JsonCpp::Value &answer) mUseNativeAudio = d["nativeaudio"].asBool(); config()[CONFIG_OWN_DNS] = d["dns_servers"].asString(); config()[CONFIG_SIPS] = d["secure"].asBool(); + config()[CONFIG_STUNSERVER_IP] = d["stun_server"].asString(); answer["status"] = Status_Ok; } diff --git a/src/engine/audio/Audio_DevicePair.cpp b/src/engine/audio/Audio_DevicePair.cpp index 94ce5266..eed525f0 100644 --- a/src/engine/audio/Audio_DevicePair.cpp +++ b/src/engine/audio/Audio_DevicePair.cpp @@ -185,6 +185,7 @@ void DevicePair::onSpkData(const Format& f, void* buffer, int length) { memset(mOutput10msBuffer.mutableData(), 0, (size_t)mOutput10msBuffer.capacity()); + // Ask audio data on main AUDIO_SAMPLERATE frequency if (mDelegate) mDelegate->onSpkData(Format(), mOutput10msBuffer.mutableData(), mOutput10msBuffer.capacity()); @@ -197,8 +198,12 @@ void DevicePair::onSpkData(const Format& f, void* buffer, int length) // Resample these 10 milliseconds it to native format size_t wasProcessed = 0; - size_t wasProduced = mSpkResampler.resample(nativeFormat.mRate, mOutput10msBuffer.data(), mOutput10msBuffer.capacity(), wasProcessed, f.mRate, - mOutputNativeData.mutableData() + mOutputNativeData.filled(), mOutputNativeData.capacity() - mOutputNativeData.filled()); + size_t wasProduced = mSpkResampler.resample(Format().mRate, + mOutput10msBuffer.data(), + mOutput10msBuffer.capacity(), + wasProcessed, f.mRate, + mOutputNativeData.mutableData() + mOutputNativeData.filled(), + mOutputNativeData.capacity() - mOutputNativeData.filled()); mOutputNativeData.setFilled(mOutputNativeData.filled() + wasProduced); #ifdef CONSOLE_LOGGING printf("Resampled %d to %d\n", wasProcessed, wasProduced); diff --git a/src/engine/media/MT_AudioReceiver.cpp b/src/engine/media/MT_AudioReceiver.cpp index cc677731..6e380549 100644 --- a/src/engine/media/MT_AudioReceiver.cpp +++ b/src/engine/media/MT_AudioReceiver.cpp @@ -730,7 +730,11 @@ void AudioReceiver::initPvqa() if (!mPVQA) { mPVQA = std::make_shared(); - mPVQA->open(AUDIO_SAMPLERATE, 1, PVQA_INTERVAL); + bool is_opened = mPVQA->open(AUDIO_SAMPLERATE, 1, PVQA_INTERVAL); + if (!is_opened) + { + // + } } } @@ -753,7 +757,11 @@ void AudioReceiver::updatePvqa(const void *data, int size) int time4pvqa = (int)(frames * PVQA_INTERVAL * 1000); int size4pvqa = (int)fmt.sizeFromTime(time4pvqa); ICELogDebug(<< "PVQA buffer has " << time4pvqa << " milliseconds of audio."); - mPVQA->update(mPvqaBuffer->data(), size4pvqa); + bool update_result = mPVQA->update(mPvqaBuffer->data(), size4pvqa); + if (!update_result) + { + // + } mPvqaBuffer->erase(size4pvqa); } } diff --git a/src/engine/media/MT_CodecList.cpp b/src/engine/media/MT_CodecList.cpp index 1d7ea616..c3c937ac 100644 --- a/src/engine/media/MT_CodecList.cpp +++ b/src/engine/media/MT_CodecList.cpp @@ -132,6 +132,7 @@ CodecList::CodecList(const Settings& settings) :mSettings(settings) { //mFactoryList.push_back(new OpusCodec::OpusFactory(16000, 1)); +/* #if defined(USE_OPUS_CODEC) if (settings.mOpusSpec.empty()) { @@ -145,6 +146,7 @@ CodecList::CodecList(const Settings& settings) } } #endif + */ #if !defined(TARGET_ANDROID) && !defined(TARGET_OPENWRT) && !defined(TARGET_RPI) #if defined(USE_AMR_CODEC) @@ -161,14 +163,14 @@ CodecList::CodecList(const Settings& settings) mFactoryList.push_back(new GsmEfrCodec::GsmEfrFactory(mSettings.mWrapIuUP, mSettings.mGsmEfrPayloadType)); #endif #endif - mFactoryList.push_back(new IsacCodec::IsacFactory16K(mSettings.mIsac16KPayloadType)); - mFactoryList.push_back(new IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType)); + // mFactoryList.push_back(new IsacCodec::IsacFactory16K(mSettings.mIsac16KPayloadType)); + // mFactoryList.push_back(new IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType)); mFactoryList.push_back(new G711Codec::AlawFactory()); mFactoryList.push_back(new G711Codec::UlawFactory()); mFactoryList.push_back(new GsmCodec::GsmFactory(mSettings.mGsmFrPayloadLength == 32 ? GsmCodec::Type::Bytes_32 : GsmCodec::Type::Bytes_33, mSettings.mGsmFrPayloadType)); - mFactoryList.push_back(new G722Codec::G722Factory()); - mFactoryList.push_back(new G729Codec::G729Factory()); + // mFactoryList.push_back(new G722Codec::G722Factory()); + // mFactoryList.push_back(new G729Codec::G729Factory()); #ifndef TARGET_ANDROID mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType)); #endif diff --git a/src/libs/resiprocate/resip/stack/ssl/Security.cxx b/src/libs/resiprocate/resip/stack/ssl/Security.cxx index 1e08f096..ea96fff4 100644 --- a/src/libs/resiprocate/resip/stack/ssl/Security.cxx +++ b/src/libs/resiprocate/resip/stack/ssl/Security.cxx @@ -453,7 +453,7 @@ BaseSecurity::addCertPEM (PEMType type, ErrLog(<< name << " is empty. Skipping."); return; } - X509* cert=NULL; + X509* cert = NULL; BIO* in = BIO_new_mem_buf(const_cast(certPEM.c_str()), -1); if ( !in ) @@ -466,7 +466,7 @@ BaseSecurity::addCertPEM (PEMType type, { ErrLog( << "Could not load X509 cert from '" << certPEM << "'" ); BIO_free(in); - throw Exception("Could not load X509 cert from BIO buffer", __FILE__,__LINE__); + // throw Exception("Could not load X509 cert from BIO buffer", __FILE__,__LINE__); } addCertX509(type,name,cert,write);