[Opalvoip-svn] SF.net SVN: opalvoip:[34673] opal/trunk
Brought to you by:
csoutheren,
rjongbloed
From: <rjo...@us...> - 2016-03-09 15:44:33
|
Revision: 34673 http://sourceforge.net/p/opalvoip/code/34673 Author: rjongbloed Date: 2016-03-09 15:44:29 +0000 (Wed, 09 Mar 2016) Log Message: ----------- Added statistics for Opus (or any other) FEC. Modified Paths: -------------- opal/trunk/include/opal/mediasession.h opal/trunk/plugins/audio/Opus/OpusCodec.cpp opal/trunk/src/codec/opalpluginmgr.cxx opal/trunk/src/opal/mediasession.cxx Modified: opal/trunk/include/opal/mediasession.h =================================================================== --- opal/trunk/include/opal/mediasession.h 2016-03-09 12:16:19 UTC (rev 34672) +++ opal/trunk/include/opal/mediasession.h 2016-03-09 15:44:29 UTC (rev 34673) @@ -79,6 +79,7 @@ unsigned m_controlPacketsIn; // RTCP received for this channel unsigned m_controlPacketsOut; // RTCP sent for this channel int m_NACKs; // (-1 is N/A) + int m_FEC; // (-1 is N/A, for tx is number of FEC frame sent, for rx is number of frames recovered via FEC) int m_packetsLost; // (-1 is N/A) int m_packetsOutOfOrder; // (-1 is N/A) int m_lateOutOfOrder; // (-1 is N/A) Modified: opal/trunk/plugins/audio/Opus/OpusCodec.cpp =================================================================== --- opal/trunk/plugins/audio/Opus/OpusCodec.cpp 2016-03-09 12:16:19 UTC (rev 34672) +++ opal/trunk/plugins/audio/Opus/OpusCodec.cpp 2016-03-09 15:44:29 UTC (rev 34673) @@ -40,7 +40,12 @@ #include <vector> +#ifdef _MSC_VER +#pragma warning(disable:4505) +#define snprintf _snprintf +#endif + #define MY_CODEC Opus // Name of codec (use C variable characters) #define MY_CODEC_LOG STRINGIZE(MY_CODEC) @@ -239,12 +244,14 @@ protected: unsigned m_sampleRate; bool m_useInBandFEC; + int m_countFEC; unsigned m_channels; public: OpusPluginCodec(const PluginCodec_Definition * defn) : PluginCodec<MY_CODEC>(defn) , m_useInBandFEC(true) + , m_countFEC(0) { const OpusPluginMediaFormat *mediaFormat = reinterpret_cast<const OpusPluginMediaFormat *>(m_definition->userData); m_sampleRate = mediaFormat->m_actualSampleRate; @@ -257,6 +264,8 @@ if (strcasecmp(optionName, UseInBandFEC.m_name) == 0) { if (!SetOptionBoolean(m_useInBandFEC, optionValue)) return false; + if (!m_useInBandFEC) + m_countFEC = -1; PTRACE(4, MY_CODEC_LOG, "In band FEC set to " << std::boolalpha << m_useInBandFEC); return true; } @@ -266,6 +275,12 @@ } + virtual int GetStatistics(char * bufferPtr, unsigned bufferSize) + { + return snprintf(bufferPtr, bufferSize, "FEC=%u\n", m_countFEC); + } + + bool PacketHasFec(const opus_uint8 * payload, unsigned length) { if (payload == NULL || length == 0) @@ -303,7 +318,8 @@ int channels = opus_packet_get_nb_channels(payload); for (int n = 0; n < channels; n++) { if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) { - PTRACE(5, MY_CODEC_LOG, "FEC packet detected"); + PTRACE(6, MY_CODEC_LOG, "FEC packet detected"); + ++m_countFEC; return true; } } @@ -409,6 +425,7 @@ toLen = result; fromLen = opus_packet_get_samples_per_frame((const opus_uint8 *)toPtr, m_sampleRate) * opus_packet_get_nb_frames((const opus_uint8 *)toPtr, toLen) * m_channels * 2; + PacketHasFec((opus_uint8 *)toPtr, toLen); return true; } }; Modified: opal/trunk/src/codec/opalpluginmgr.cxx =================================================================== --- opal/trunk/src/codec/opalpluginmgr.cxx 2016-03-09 12:16:19 UTC (rev 34672) +++ opal/trunk/src/codec/opalpluginmgr.cxx 2016-03-09 15:44:29 UTC (rev 34673) @@ -744,11 +744,9 @@ if (getCodecStatistics.Call(buf, sizeof(buf), context) > 0) { PConstString str(buf); PStringOptions stats(str); -#if OPAL_VIDEO - statistics.m_videoQuality = stats.GetInteger("Quality", statistics.m_videoQuality); -#endif statistics.m_targetBitRate = stats.GetInteger("BitRate", statistics.m_targetBitRate); statistics.m_targetFrameRate = (float)stats.GetReal ("FrameRate", statistics.m_targetFrameRate); + statistics.m_FEC = stats.GetInteger("FEC", statistics.m_FEC); } } #endif // OPAL_STATISTICS Modified: opal/trunk/src/opal/mediasession.cxx =================================================================== --- opal/trunk/src/opal/mediasession.cxx 2016-03-09 12:16:19 UTC (rev 34672) +++ opal/trunk/src/opal/mediasession.cxx 2016-03-09 15:44:29 UTC (rev 34673) @@ -64,6 +64,7 @@ , m_controlPacketsIn(0) , m_controlPacketsOut(0) , m_NACKs(-1) + , m_FEC(-1) , m_packetsLost(-1) , m_packetsOutOfOrder(-1) , m_lateOutOfOrder(-1) @@ -366,7 +367,9 @@ << setw(indent) << "Maximum packet time" << " = " << m_maximumPacketTime << "ms\n" << setw(indent) << "Packets lost" << " = " << m_packetsLost << '\n' << setw(indent) << "Restored out of order" << " = " << m_packetsOutOfOrder << '\n' - << setw(indent) << "Late out of order" << " = " << m_lateOutOfOrder << '\n'; + << setw(indent) << "Late out of order" << " = " << m_lateOutOfOrder << '\n' + << setw(indent) << "NACK" << " = " << m_NACKs << '\n' + << setw(indent) << "FEC" << " = " << m_FEC << '\n'; if (m_roundTripTime >= 0) strm << setw(indent) << "Round Trip Time" << " = " << m_roundTripTime << '\n'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |