This commit is contained in:
Dmytro Bogovych 2019-06-28 17:05:15 +03:00
parent 0114b91917
commit ac17680e9a
10 changed files with 41 additions and 19 deletions

View File

@ -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<float>(stat.mRttDelay.getCurrent() * 1000);
if (stat.mRttDelay.is_initialized())
info[SessionInfo_Rtt] = static_cast<float>(stat.mRttDelay * 1000);
#if defined(USE_AMR_CODEC)
info[SessionInfo_BitrateSwitchCounter] = stat.mBitrateSwitchCounter;
#endif

View File

@ -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()

View File

@ -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());

View File

@ -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);

View File

@ -390,7 +390,7 @@ bool AudioReceiver::add(std::shared_ptr<jrtplib::RTPPacket> p, Codec** codec)
// Process jitter
mJitterStats.process(p.get(), codecIter->second->samplerate());
mStat.mJitter = static_cast<float>(mJitterStats.get().getCurrent());
mStat.mJitter = static_cast<float>(mJitterStats.get());
// Check if packet is CNG
if (payloadLength >= 1 && payloadLength <= 6 && (ptype == 0 || ptype == 8))

View File

@ -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<Codec>(create());

View File

@ -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<int, PCodec > CodecMap;
virtual void create(CodecMap& codecs);
virtual void updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction);

View File

@ -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"

View File

@ -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;

View File

@ -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<typename T, int minimum = 100000, int maximum = 0>
template<typename T, int minimum = 100000, int maximum = 0, int default_value = 0>
struct TestResult
{
T mMin = minimum;
T mMax = maximum;
Average<T> 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<T>& operator = (T value)
{
process(value);
return *this;
}
operator T()
{
return mCurrent;
}
};