diff --git a/src/engine/media/MT_AudioReceiver.cpp b/src/engine/media/MT_AudioReceiver.cpp index 667749be..0c7e77d7 100644 --- a/src/engine/media/MT_AudioReceiver.cpp +++ b/src/engine/media/MT_AudioReceiver.cpp @@ -452,8 +452,12 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, DecodeOptions options, i if (mCodec && mFrameCount && !mCodecSettings.mSkipDecode) { // Do PLC to mDecodedFrame/mDecodedLength - mDecodedLength = mCodec->plc(mFrameCount, mDecodedFrame, sizeof mDecodedFrame); + if ((int)options & (int)DecodeOptions::SkipDecode) + mDecodedLength = 0; + else + mDecodedLength = mCodec->plc(mFrameCount, mDecodedFrame, sizeof mDecodedFrame); } + if (mDecodedLength) { processDecoded(output, options); @@ -487,7 +491,11 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, DecodeOptions options, i int frames100ms = milliseconds / 100; for (int frameIndex = 0; frameIndex < frames100ms; frameIndex++) { - mDecodedLength = mCngDecoder.produce(mCodec->samplerate(), 100, (short*)mDecodedFrame, false); + if ((int)options & (int)DecodeOptions::SkipDecode) + mDecodedLength = 0; + else + mDecodedLength = mCngDecoder.produce(mCodec->samplerate(), 100, (short*)mDecodedFrame, false); + if (mDecodedLength) processDecoded(output, options); } @@ -495,7 +503,11 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, DecodeOptions options, i int tail = milliseconds % 100; if (tail) { - mDecodedLength = mCngDecoder.produce(mCodec->samplerate(), tail, (short*)mDecodedFrame, false); + if ((int)options & (int)DecodeOptions::SkipDecode) + mDecodedLength = 0; + else + mDecodedLength = mCngDecoder.produce(mCodec->samplerate(), tail, (short*)mDecodedFrame, false); + if (mDecodedLength) processDecoded(output, options); } @@ -513,12 +525,17 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, DecodeOptions options, i // Check if it is CNG packet if ((p->GetPayloadType() == 0 || p->GetPayloadType() == 8) && p->GetPayloadLength() >= 1 && p->GetPayloadLength() <= 6) { - mCngPacket = p; - mCngDecoder.decode3389(p->GetPayloadData(), p->GetPayloadLength()); - // Emit CNG mLastPacketLength milliseconds - mDecodedLength = mCngDecoder.produce(mCodec->samplerate(), mLastPacketTimeLength, (short*)mDecodedFrame, true); - if (mDecodedLength) - processDecoded(output, options); + if ((int)options & (int)DecodeOptions::SkipDecode) + mDecodedLength = 0; + else + { + mCngPacket = p; + mCngDecoder.decode3389(p->GetPayloadData(), p->GetPayloadLength()); + // Emit CNG mLastPacketLength milliseconds + mDecodedLength = mCngDecoder.produce(mCodec->samplerate(), mLastPacketTimeLength, (short*)mDecodedFrame, true); + if (mDecodedLength) + processDecoded(output, options); + } result = true; } else @@ -542,11 +559,16 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, DecodeOptions options, i // Decode for (int i=0; idecode(p->GetPayloadData() + i*mCodec->rtpLength(), - frameLength, mDecodedFrame, sizeof mDecodedFrame); - if (mDecodedLength) - processDecoded(output, options); + if ((int)options & (int)DecodeOptions::SkipDecode) + mDecodedLength = 0; + else + { + // Decode frame by frame + mDecodedLength = mCodec->decode(p->GetPayloadData() + i*mCodec->rtpLength(), + frameLength, mDecodedFrame, sizeof mDecodedFrame); + if (mDecodedLength) + processDecoded(output, options); + } } result = mFrameCount > 0; diff --git a/src/engine/media/MT_AudioReceiver.h b/src/engine/media/MT_AudioReceiver.h index 4a608bc0..b66ed5bb 100644 --- a/src/engine/media/MT_AudioReceiver.h +++ b/src/engine/media/MT_AudioReceiver.h @@ -117,7 +117,8 @@ namespace MT { ResampleToMainRate = 0, DontResample = 1, - FillCngGap = 2 + FillCngGap = 2, + SkipDecode = 4 }; bool getAudio(Audio::DataWindow& output, DecodeOptions options = DecodeOptions::ResampleToMainRate, int* rate = nullptr); diff --git a/src/engine/media/MT_SevanaMos.cpp b/src/engine/media/MT_SevanaMos.cpp index 03dc1536..6ffd1d86 100644 --- a/src/engine/media/MT_SevanaMos.cpp +++ b/src/engine/media/MT_SevanaMos.cpp @@ -172,12 +172,15 @@ bool SevanaPVQA::initializeLibrary(const std::string& pathToLicenseFile, const s return false; } - mLibraryConfiguration = PVQA_LoadCFGFile(const_cast(pathToConfigFile.c_str()), &mLibraryErrorCode); - if (!mLibraryConfiguration) + if (pathToConfigFile.size()) { - PVQA_ReleaseLib(); - ICELogError(<< "Problem with PVQA configuration file."); - return false; + mLibraryConfiguration = PVQA_LoadCFGFile(const_cast(pathToConfigFile.c_str()), &mLibraryErrorCode); + if (!mLibraryConfiguration) + { + PVQA_ReleaseLib(); + ICELogError(<< "Problem with PVQA configuration file."); + return false; + } } mPvqaLoaded = true; } @@ -202,12 +205,15 @@ bool SevanaPVQA::initializeLibraryWithData(const void* license_buffer, size_t li return false; } - mLibraryConfiguration = PVQA_LoadCFGData(config_buffer, config_len, &mLibraryErrorCode); - if (!mLibraryConfiguration) + if (config_buffer && config_len) { - PVQA_ReleaseLib(); - ICELogError(<< "Problem with PVQA configuration file."); - return false; + mLibraryConfiguration = PVQA_LoadCFGData(config_buffer, config_len, &mLibraryErrorCode); + if (!mLibraryConfiguration) + { + PVQA_ReleaseLib(); + ICELogError(<< "Problem with PVQA configuration file."); + return false; + } } mPvqaLoaded = true; } diff --git a/src/engine/media/MT_SevanaMos.h b/src/engine/media/MT_SevanaMos.h index 155510bf..64a42957 100644 --- a/src/engine/media/MT_SevanaMos.h +++ b/src/engine/media/MT_SevanaMos.h @@ -76,6 +76,8 @@ public: #if defined(TARGET_ANDROID) static void setupAndroidEnvironment(void* environment, void* appcontext); #endif + // Path to config file can be empty + // In this case library will be considered initialized (but will produce zero MOS) static bool initializeLibrary(const std::string& pathToLicenseFile, const std::string& pathToConfigFile); static bool initializeLibraryWithData(const void* license_buffer, size_t license_len, const void* config_buffer, size_t config_len);