From 7efef755fa4f23406ee7bf15581e8b20dd2eb95b Mon Sep 17 00:00:00 2001 From: Dmytro Bogovych Date: Sun, 26 Sep 2021 19:50:02 +0300 Subject: [PATCH] - more fixes from pvqa_server project --- src/CMakeLists.txt | 9 +++++-- src/engine/config.h | 10 ++++---- src/engine/media/MT_CodecList.cpp | 40 +++++++++++++++++++++++++++++-- src/engine/media/MT_CodecList.h | 3 +++ src/libs/pvqa/include/pvqa++.h | 9 ++++++- src/libs/pvqa/include/pvqa.h | 11 +++++---- 6 files changed, 68 insertions(+), 14 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 444d1c7d..fcc322e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,7 +102,8 @@ endif() if (USE_PVQA_LIBRARY) message("Use PVQA libraries") add_definitions( -DUSE_PVQA_LIBRARY ) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/pvqa/include) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/pvqa/include + ${CMAKE_CURRENT_SOURCE_DIR}/libs/pvqa++/include) endif() set (RTPHONE_SOURCES @@ -201,6 +202,10 @@ else () set (LIBS ${LIBS} dl uuid) endif () +if (CMAKE_SYSTEM MATCHES "Android") + set (LIBS ${LIBS} oboe) +endif() + if (USE_AMR_CODEC) set (LIBS ${LIBS}) endif (USE_AMR_CODEC) @@ -215,7 +220,7 @@ target_link_libraries(rtphone uuid ${OPENSSL_SSL} ${OPENSSL_CRYPTO} - ${LIBS} oboe) + ${LIBS} ) target_include_directories(rtphone diff --git a/src/engine/config.h b/src/engine/config.h index f6c4de0f..0d84f550 100644 --- a/src/engine/config.h +++ b/src/engine/config.h @@ -17,7 +17,7 @@ #define AUDIO_CHANNELS 1 // Samplerate must be 8 / 16 / 24 / 32 / 48 KHz -#define AUDIO_SAMPLERATE 48000 +#define AUDIO_SAMPLERATE 8000 #define AUDIO_MIC_BUFFER_COUNT 16 #define AUDIO_MIC_BUFFER_LENGTH 10 #define AUDIO_MIC_BUFFER_SIZE (AUDIO_MIC_BUFFER_LENGTH * AUDIO_SAMPLERATE / 1000 * 2 * AUDIO_CHANNELS) @@ -66,15 +66,15 @@ // AMR codec defines - it requires USE_AMR_CODEC defined // #define USE_AMR_CODEC -#define MT_AMRNB_PAYLOADTYPE 122 +#define MT_AMRNB_PAYLOADTYPE 112 #define MT_AMRNB_CODECNAME "amr" -#define MT_AMRNB_OCTET_PAYLOADTYPE 123 +#define MT_AMRNB_OCTET_PAYLOADTYPE 113 -#define MT_AMRWB_PAYLOADTYPE 124 +#define MT_AMRWB_PAYLOADTYPE 96 #define MT_AMRWB_CODECNAME "amr-wb" -#define MT_AMRWB_OCTET_PAYLOADTYPE 125 +#define MT_AMRWB_OCTET_PAYLOADTYPE 97 #define MT_GSMEFR_PAYLOADTYPE 126 #define MT_GSMEFR_CODECNAME "GERAN-EFR" diff --git a/src/engine/media/MT_CodecList.cpp b/src/engine/media/MT_CodecList.cpp index 66b5bbce..1d7ea616 100644 --- a/src/engine/media/MT_CodecList.cpp +++ b/src/engine/media/MT_CodecList.cpp @@ -25,6 +25,42 @@ using namespace MT; using strx = StringHelper; // ---------------- EvsSpec --------------- + +std::string CodecList::Settings::toString() const +{ + std::ostringstream oss; + oss << "wrap IuUP: " << mWrapIuUP << std::endl + << "skip decode: " << mSkipDecode << std::endl; + for (int ptype: mAmrWbPayloadType) + oss << "AMR WB ptype: " << ptype << std::endl; + for (int ptype: mAmrWbOctetPayloadType) + oss << "AMR WB octet-aligned ptype: " << ptype << std::endl; + for (int ptype: mAmrNbPayloadType) + oss << "AMR NB ptype: " << ptype << std::endl; + for (int ptype: mAmrNbOctetPayloadType) + oss << "AMR NB octet-aligned ptype:" << ptype << std::endl; + + oss << "ISAC 16Khz ptype: " << mIsac16KPayloadType << std::endl + << "ISAC 32Khz ptype: " << mIsac32KPayloadType << std::endl + << "iLBC 20ms ptype: " << mIlbc20PayloadType << std::endl + << "iLBC 30ms ptype: " << mIlbc30PayloadType << std::endl + << "GSM FR ptype: " << mGsmFrPayloadType << ", GSM FR plength: " << mGsmFrPayloadLength << std::endl + << "GSM HR ptype: " << mGsmHrPayloadType << std::endl + << "GSM EFR ptype: " << mGsmEfrPayloadType << std::endl; + + for (auto& spec: mEvsSpec) + { + oss << "EVS ptype: " << spec.mPayloadType << ", bw: " << spec.mBandwidth << ", enc: " << (spec.mEncodingType == EvsSpec::Encoding_MIME ? "mime" : "g192") << std::endl; + } + + for (auto& spec: mOpusSpec) + { + oss << "OPUS ptype: " << spec.mPayloadType << ", rate: " << spec.mRate << ", channels: " << spec.mChannels << std::endl; + } + + return oss.str(); +} + bool CodecList::Settings::EvsSpec::isValid() const { return mPayloadType >= 96 && mPayloadType <= 127; @@ -125,14 +161,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 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 G729Codec::G729Factory()); #ifndef TARGET_ANDROID mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType)); #endif diff --git a/src/engine/media/MT_CodecList.h b/src/engine/media/MT_CodecList.h index 1024dc26..ef84ba47 100644 --- a/src/engine/media/MT_CodecList.h +++ b/src/engine/media/MT_CodecList.h @@ -82,6 +82,9 @@ public: }; std::vector mOpusSpec; + // Textual representation - used in logging + std::string toString() const; + static Settings DefaultSettings; }; diff --git a/src/libs/pvqa/include/pvqa++.h b/src/libs/pvqa/include/pvqa++.h index 44193643..0c6559f3 100644 --- a/src/libs/pvqa/include/pvqa++.h +++ b/src/libs/pvqa/include/pvqa++.h @@ -111,6 +111,9 @@ public: static void setupAndroidEnvironment(void* environment, void* appcontext); #endif + // Verbose run - dump debugging info to console + static void set_verbose(bool verbose = true); + // Path to config file can be empty // In this case library will be considered initialized (but will produce zero MOS) static bool initialize(const std::string& pathToLicenseFile, const std::string& pathToConfigFile); @@ -118,6 +121,8 @@ public: const void* config_buffer, size_t config_len); static bool is_initialized(); + static std::string get_copyright_string(); + static int library_error(); static void release(); static int instance_counter() { return mInstanceCounter; } @@ -145,6 +150,7 @@ public: bool is_open() const; // Update/Get model. pcm_length is bytes. + // Please - pcm_length must be a multiple of interval time! bool update(const void* pcm_buffer, size_t pcm_length); int error() const; @@ -153,7 +159,7 @@ public: { float mMos = 0.0f; std::string mReport; - size_t mIntervals = 0, mPoorIntervals = 0; + size_t mIntervals = 0, mPoorIntervals = 0, mUncertainIntervals = 0; }; bool get_result(result& r, size_t last_milliseconds = 0); @@ -171,6 +177,7 @@ public: // Combines update & get_result calls bool singleshot(result& r, const void* pcm_buffer, size_t pcm_length); + bool singleshot_file(result& r, const std::string& path); }; } // end of namespace diff --git a/src/libs/pvqa/include/pvqa.h b/src/libs/pvqa/include/pvqa.h index ef9df4ab..35465208 100644 --- a/src/libs/pvqa/include/pvqa.h +++ b/src/libs/pvqa/include/pvqa.h @@ -29,6 +29,7 @@ typedef struct long dNumPoorIntervals; long dNumTotalIntervals; + long dNumUncertainIntervals; double dTimeShift; } TPVQA_Results; @@ -38,7 +39,7 @@ typedef struct { long dSampleRate; // Sample rate of signal long dNChannels; // Number of sound channels in audio - short * pSamples; // Pointer to the samples of signal + const short * pSamples; // Pointer to the samples of signal long dNSamples; // Number of samples } TPVQA_AudioItem; @@ -82,7 +83,7 @@ PVQA_API int PVQA_AudioQualityAnalyzerCreateDelayLine(void * aPVQA_ID, long aSam PVQA_API int PVQA_StartRecordingWave(void * aPVQA_ID, const char * aPWavFName, long aSampleRate, long aNChannels); // Performs audio file quality estimation -PVQA_API int PVQA_OnTestAudioFile(void * aPVQA_ID, const char * aPFileName); +PVQA_API int PVQA_OnTestAudioFile(void * aPVQA_ID, const char * aPFileName, double offset_begin, double offset_end); // Process loaded in memory audio data PVQA_API int PVQA_OnTestAudioData(void * aPVQA_ID, TPVQA_AudioItem * aPVQA_PAudio); @@ -95,7 +96,6 @@ PVQA_API int PVQA_OnStartStreamData(void * aPVQA_ID); // Process streaming Audio data PVQA_API int PVQA_OnAddStreamAudioData(void * aPVQA_ID, TPVQA_AudioItem * aPVQA_PAudio); -PVQA_API int PVQA_OnAddStreamAudioDataHex(void * aPVQA_ID, int rate, int channels, const char* samples); // Updates quality results data PVQA_API int PVQA_OnUpdateStreamQualityResults(void * aPVQA_ID, int rate, int millisecondsFromEnd); @@ -104,7 +104,6 @@ PVQA_API int PVQA_OnUpdateStreamQualityResults(void * aPVQA_ID, int rate, int mi PVQA_API int PVQA_OnFinalizeStream(void * aPVQA_ID, long aSampleRate); - // -------------------------------------------------------------------------------------- // Displaying audio quality testing results // -------------------------------------------------------------------------------------- @@ -129,7 +128,10 @@ PVQA_API const char ** PVQA_GetProcessorValuesNamesList(void * aPVQA_ID, const c typedef struct { + // number of columns and rows int columns, rows; + + // data itself float* data; } PVQA_Array2D; @@ -137,6 +139,7 @@ typedef struct // Returned value has to be released via PVQA_ReleaseArray2D PVQA_API PVQA_Array2D* PVQA_GetProcessorValuesList(void * aPVQA_ID, const char * aPDetectorName, long aStartTime, long aStopTime, const char * aStatType, int * errCode); + // Release allocated 2D array PVQA_API void PVQA_ReleaseArray2D(PVQA_Array2D* array);