diff --git a/src/engine/endpoint/EP_Session.cpp b/src/engine/endpoint/EP_Session.cpp index 0f23ee65..aa53ad57 100644 --- a/src/engine/endpoint/EP_Session.cpp +++ b/src/engine/endpoint/EP_Session.cpp @@ -492,8 +492,8 @@ void Session::getSessionInfo(Session::InfoOptions options, VariantMap& info) info[SessionInfo_AudioPeer] = mIceStack->remoteAddress(media->iceInfo().mStreamId, media->iceInfo().mComponentId.mRtp).toStdString(); info[SessionInfo_Jitter] = stat.mJitter; - if (stat.mRttDelay.isInitialized()) - info[SessionInfo_Rtt] = static_cast(stat.mRttDelay.getCurrent() * 1000); + if (stat.mRttDelay.is_initialized()) + info[SessionInfo_Rtt] = static_cast(stat.mRttDelay * 1000); #if defined(USE_AMR_CODEC) info[SessionInfo_BitrateSwitchCounter] = stat.mBitrateSwitchCounter; #endif diff --git a/src/engine/media/CMakeLists.txt b/src/engine/media/CMakeLists.txt index f113e8ca..c0ff0a5d 100644 --- a/src/engine/media/CMakeLists.txt +++ b/src/engine/media/CMakeLists.txt @@ -7,7 +7,7 @@ set (CMAKE_CXX_STANDARD_REQUIRED ON) # Produce PIC code always set (CMAKE_POSITION_INDEPENDENT_CODE ON) -set (USE_RESIP_INTEGRATION CACHE BOOL FALSE "Integrate with resip structures") +#set (USE_RESIP_INTEGRATION CACHE BOOL OFF "Integrate with resip structures") file(GLOB MEDIA_LIB_SOURCES "*.cpp" "*.h") if(CMAKE_SYSTEM MATCHES "Linux*") @@ -38,6 +38,7 @@ target_include_directories(media_lib ) if (USE_RESIP_INTEGRATION) + message("USE_RESIP_INTEGRATION is turned on!") target_compile_definitions(media_lib PUBLIC -DUSE_RESIP_INTEGRATION) endif() diff --git a/src/engine/media/MT_AudioCodec.cpp b/src/engine/media/MT_AudioCodec.cpp index a9c38b1b..52c62a7f 100644 --- a/src/engine/media/MT_AudioCodec.cpp +++ b/src/engine/media/MT_AudioCodec.cpp @@ -646,7 +646,7 @@ PCodec IlbcCodec::IlbcFactory::create() return PCodec(new IlbcCodec(mPtime)); } -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) void IlbcCodec::IlbcFactory::create(CodecMap& codecs) { codecs[mPType20ms] = PCodec(create()); diff --git a/src/engine/media/MT_AudioCodec.h b/src/engine/media/MT_AudioCodec.h index d23f8aaf..9e256851 100644 --- a/src/engine/media/MT_AudioCodec.h +++ b/src/engine/media/MT_AudioCodec.h @@ -141,7 +141,7 @@ namespace MT const char* name(); int samplerate(); int payloadType(); -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) void updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction); int processSdp(const resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction); void create(CodecMap& codecs); diff --git a/src/engine/media/MT_AudioReceiver.cpp b/src/engine/media/MT_AudioReceiver.cpp index 4a7a8d05..2ae67e11 100644 --- a/src/engine/media/MT_AudioReceiver.cpp +++ b/src/engine/media/MT_AudioReceiver.cpp @@ -390,7 +390,7 @@ bool AudioReceiver::add(std::shared_ptr p, Codec** codec) // Process jitter mJitterStats.process(p.get(), codecIter->second->samplerate()); - mStat.mJitter = static_cast(mJitterStats.get().getCurrent()); + mStat.mJitter = static_cast(mJitterStats.get()); // Check if packet is CNG if (payloadLength >= 1 && payloadLength <= 6 && (ptype == 0 || ptype == 8)) diff --git a/src/engine/media/MT_Codec.cpp b/src/engine/media/MT_Codec.cpp index a561cfa9..1a08a42b 100644 --- a/src/engine/media/MT_Codec.cpp +++ b/src/engine/media/MT_Codec.cpp @@ -12,7 +12,7 @@ int Codec::Factory::channels() return 1; } -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) void Codec::Factory::create(CodecMap& codecs) { codecs[payloadType()] = std::shared_ptr(create()); diff --git a/src/engine/media/MT_Codec.h b/src/engine/media/MT_Codec.h index 61014de7..dd608ae6 100644 --- a/src/engine/media/MT_Codec.h +++ b/src/engine/media/MT_Codec.h @@ -6,7 +6,7 @@ #ifndef __MT_CODEC_H #define __MT_CODEC_H -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) # include "resiprocate/resip/stack/SdpContents.hxx" #endif #include "../helper/HL_Types.h" @@ -36,7 +36,7 @@ namespace MT virtual PCodec create() = 0; virtual int channels(); -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) typedef std::map CodecMap; virtual void create(CodecMap& codecs); virtual void updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction); diff --git a/src/engine/media/MT_CodecList.h b/src/engine/media/MT_CodecList.h index 6aec5427..5a81b439 100644 --- a/src/engine/media/MT_CodecList.h +++ b/src/engine/media/MT_CodecList.h @@ -7,7 +7,7 @@ #define __MT_CODEC_LIST_H #include "../config.h" -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) # include "resiprocate/resip/stack/SdpContents.hxx" #endif #include "MT_Codec.h" diff --git a/src/engine/media/MT_EvsCodec.h b/src/engine/media/MT_EvsCodec.h index 8c3af2d9..a40fee62 100644 --- a/src/engine/media/MT_EvsCodec.h +++ b/src/engine/media/MT_EvsCodec.h @@ -36,7 +36,7 @@ namespace MT int samplerate() override; int payloadType() override; -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) void updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction) override; int processSdp(const resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction) override; void create(CodecMap& codecs) override; @@ -81,7 +81,7 @@ namespace MT int samplerate() override; int payloadType() override; -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) void updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction) override; int processSdp(const resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction) override; void create(CodecMap& codecs) override; @@ -123,7 +123,7 @@ namespace MT int samplerate() override; int payloadType() override; -#ifdef USE_RESIP_INTEGRATION +#if defined(USE_RESIP_INTEGRATION) void updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction) override; int processSdp(const resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction) override; void create(CodecMap& codecs) override; diff --git a/src/engine/media/MT_Statistics.h b/src/engine/media/MT_Statistics.h index 0c80bc08..c8ea709c 100644 --- a/src/engine/media/MT_Statistics.h +++ b/src/engine/media/MT_Statistics.h @@ -18,13 +18,18 @@ struct Average { int mCount = 0; T mSum = 0; - T getAverage() const + T average() const { if (!mCount) return 0; return mSum / mCount; } + T value() const + { + return average(); + } + void process(T value) { mCount++; @@ -32,13 +37,13 @@ struct Average } }; -template +template struct TestResult { T mMin = minimum; T mMax = maximum; Average mAverage; - T mCurrent = minimum; + T mCurrent = default_value; void process(T value) { @@ -50,18 +55,34 @@ struct TestResult mAverage.process(value); } - bool isInitialized() const + bool is_initialized() const { return mAverage.mCount > 0; } - T getCurrent() const + T current() const { - if (isInitialized()) + if (is_initialized()) return mCurrent; else return 0; } + + T value() const + { + return current(); + } + + TestResult& operator = (T value) + { + process(value); + return *this; + } + + operator T() + { + return mCurrent; + } };