mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 19:16:15 +00:00
res_rtp_asterisk: Asterisk Media Experience Score (MES)
----------------- This commit reinstates MES with some casting fixes to the functions in time.h that convert between doubles and timeval structures. The casting issues were causing incorrect timestamps to be calculated which caused transcoding from/to G722 to produce bad or no audio. ASTERISK-30391 ----------------- This module has been updated to provide additional quality statistics in the form of an Asterisk Media Experience Score. The score is avilable using the same mechanisms you'd use to retrieve jitter, loss, and rtt statistics. For more information about the score and how to retrieve it, see https://wiki.asterisk.org/wiki/display/AST/Media+Experience+Score * Updated chan_pjsip to set quality channel variables when a call ends. * Updated channels/pjsip/dialplan_functions.c to add the ability to retrieve the MES along with the existing rtcp stats when using the CHANNEL dialplan function. * Added the ast_debug_rtp_is_allowed and ast_debug_rtcp_is_allowed checks for debugging purposes. * Added several function to time.h for manipulating time-in-samples and times represented as double seconds. * Updated rtp_engine.c to pass through the MES when stats are requested. Also debug output that dumps the stats when an rtp instance is destroyed. * Updated res_rtp_asterisk.c to implement the calculation of the MES. In the process, also had to update the calculation of jitter. Many debugging statements were also changed to be more informative. * Added a unit test for internal testing. The test should not be run during normal operation and is disabled by default. Change-Id: I4fce265965e68c3fdfeca55e614371ee69c65038
This commit is contained in:
@@ -174,6 +174,8 @@ enum ast_rtp_instance_stat_field {
|
||||
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_LOSS,
|
||||
/*! Retrieve quality information about round trip time */
|
||||
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_RTT,
|
||||
/*! Retrieve quality information about Media Experience Score */
|
||||
AST_RTP_INSTANCE_STAT_FIELD_QUALITY_MES,
|
||||
};
|
||||
|
||||
/*! Statistics that can be retrieved from an RTP instance */
|
||||
@@ -250,6 +252,29 @@ enum ast_rtp_instance_stat {
|
||||
AST_RTP_INSTANCE_STAT_TXOCTETCOUNT,
|
||||
/*! Retrieve number of octets received */
|
||||
AST_RTP_INSTANCE_STAT_RXOCTETCOUNT,
|
||||
|
||||
/*! Retrieve ALL statistics relating to Media Experience Score */
|
||||
AST_RTP_INSTANCE_STAT_COMBINED_MES,
|
||||
/*! Retrieve MES on transmitted packets */
|
||||
AST_RTP_INSTANCE_STAT_TXMES,
|
||||
/*! Retrieve MES on received packets */
|
||||
AST_RTP_INSTANCE_STAT_RXMES,
|
||||
/*! Retrieve maximum MES on remote side */
|
||||
AST_RTP_INSTANCE_STAT_REMOTE_MAXMES,
|
||||
/*! Retrieve minimum MES on remote side */
|
||||
AST_RTP_INSTANCE_STAT_REMOTE_MINMES,
|
||||
/*! Retrieve average MES on remote side */
|
||||
AST_RTP_INSTANCE_STAT_REMOTE_NORMDEVMES,
|
||||
/*! Retrieve standard deviation MES on remote side */
|
||||
AST_RTP_INSTANCE_STAT_REMOTE_STDEVMES,
|
||||
/*! Retrieve maximum MES on local side */
|
||||
AST_RTP_INSTANCE_STAT_LOCAL_MAXMES,
|
||||
/*! Retrieve minimum MES on local side */
|
||||
AST_RTP_INSTANCE_STAT_LOCAL_MINMES,
|
||||
/*! Retrieve average MES on local side */
|
||||
AST_RTP_INSTANCE_STAT_LOCAL_NORMDEVMES,
|
||||
/*! Retrieve standard deviation MES on local side */
|
||||
AST_RTP_INSTANCE_STAT_LOCAL_STDEVMES,
|
||||
};
|
||||
|
||||
enum ast_rtp_instance_rtcp {
|
||||
@@ -428,6 +453,27 @@ struct ast_rtp_instance_stats {
|
||||
unsigned int txoctetcount;
|
||||
/*! Number of octets received */
|
||||
unsigned int rxoctetcount;
|
||||
|
||||
/*! Media Experience Score on transmitted packets */
|
||||
double txmes;
|
||||
/*! Media Experience Score on received packets */
|
||||
double rxmes;
|
||||
/*! Maximum MES on remote side */
|
||||
double remote_maxmes;
|
||||
/*! Minimum MES on remote side */
|
||||
double remote_minmes;
|
||||
/*! Average MES on remote side */
|
||||
double remote_normdevmes;
|
||||
/*! Standard deviation MES on remote side */
|
||||
double remote_stdevmes;
|
||||
/*! Maximum MES on local side */
|
||||
double local_maxmes;
|
||||
/*! Minimum MES on local side */
|
||||
double local_minmes;
|
||||
/*! Average MES on local side */
|
||||
double local_normdevmes;
|
||||
/*! Standard deviation MES on local side */
|
||||
double local_stdevmes;
|
||||
};
|
||||
|
||||
#define AST_RTP_STAT_SET(current_stat, combined, placement, value) \
|
||||
@@ -2860,6 +2906,10 @@ uintmax_t ast_debug_category_ice_id(void);
|
||||
#define ast_debug_rtp(sublevel, ...) \
|
||||
ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTP, __VA_ARGS__)
|
||||
|
||||
/* Allow logging of RTP? */
|
||||
#define ast_debug_rtp_is_allowed \
|
||||
ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP)
|
||||
|
||||
/* Allow logging of RTP packets? */
|
||||
#define ast_debug_rtp_packet_is_allowed \
|
||||
ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTP_PACKET)
|
||||
@@ -2873,6 +2923,10 @@ uintmax_t ast_debug_category_ice_id(void);
|
||||
#define ast_debug_rtcp(sublevel, ...) \
|
||||
ast_debug_category(sublevel, AST_DEBUG_CATEGORY_RTCP, __VA_ARGS__)
|
||||
|
||||
/* Allow logging of RTCP? */
|
||||
#define ast_debug_rtcp_is_allowed \
|
||||
ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP)
|
||||
|
||||
/* Allow logging of RTCP packets? */
|
||||
#define ast_debug_rtcp_packet_is_allowed \
|
||||
ast_debug_category_is_allowed(AST_LOG_CATEGORY_ENABLED, AST_DEBUG_CATEGORY_RTCP_PACKET)
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "asterisk/inline_api.h"
|
||||
|
||||
/* A time_t can be represented as an unsigned long long (or uint64_t).
|
||||
@@ -232,6 +234,41 @@ struct timeval ast_tv(ast_time_t sec, ast_suseconds_t usec),
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Returns a timeval structure corresponding to the
|
||||
* number of seconds in the double _td.
|
||||
*
|
||||
* \param _td The number of seconds.
|
||||
* \returns A timeval structure containing the number of seconds.
|
||||
*
|
||||
* This is the inverse of ast_tv2double().
|
||||
*/
|
||||
AST_INLINE_API(
|
||||
struct timeval ast_double2tv(double _td),
|
||||
{
|
||||
struct timeval t;
|
||||
t.tv_sec = (typeof(t.tv_sec))floor(_td);
|
||||
t.tv_usec = (typeof(t.tv_usec)) ((_td - t.tv_sec) * 1000000.0);
|
||||
return t;
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Returns a double corresponding to the number of seconds
|
||||
* in the timeval _tv.
|
||||
*
|
||||
* \param _tv A pointer to a timeval structure.
|
||||
* \returns A double containing the number of seconds.
|
||||
*
|
||||
* This is the inverse of ast_double2tv().
|
||||
*/
|
||||
AST_INLINE_API(
|
||||
double ast_tv2double(const struct timeval *tv),
|
||||
{
|
||||
return (((double)tv->tv_sec) + (((double)tv->tv_usec) / 1000000.0));
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Returns a timeval corresponding to the duration of n samples at rate r.
|
||||
* Useful to convert samples to timevals, or even milliseconds to timevals
|
||||
@@ -244,6 +281,57 @@ struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate),
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Returns the number of samples at rate _rate in the
|
||||
* duration specified by _tv.
|
||||
*
|
||||
* \param _tv A pointer to a timeval structure.
|
||||
* \param _rate The sample rate in Hz.
|
||||
* \returns A time_t containing the number of samples.
|
||||
*
|
||||
* This is the inverse of ast_samp2tv().
|
||||
*/
|
||||
AST_INLINE_API(
|
||||
time_t ast_tv2samp(const struct timeval *_tv, int _rate),
|
||||
{
|
||||
return (time_t)(ast_tv2double(_tv) * (double)_rate);
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Returns the duration in seconds of _nsamp samples
|
||||
* at rate _rate.
|
||||
*
|
||||
* \param _nsamp The number of samples
|
||||
* \param _rate The sample rate in Hz.
|
||||
* \returns A double containing the number of seconds.
|
||||
*
|
||||
* This is the inverse of ast_sec2samp().
|
||||
*/
|
||||
AST_INLINE_API(
|
||||
double ast_samp2sec(unsigned int _nsamp, unsigned int _rate),
|
||||
{
|
||||
return ((double)_nsamp) / ((double)_rate);
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Returns the number of samples at _rate in the duration
|
||||
* in _seconds.
|
||||
*
|
||||
* \param _seconds The time interval in seconds.
|
||||
* \param _rate The sample rate in Hz.
|
||||
* \returns The number of samples.
|
||||
*
|
||||
* This is the inverse of ast_samp2sec().
|
||||
*/
|
||||
AST_INLINE_API(
|
||||
unsigned int ast_sec2samp(double _seconds, int _rate),
|
||||
{
|
||||
return (unsigned int)(_seconds * _rate);
|
||||
}
|
||||
)
|
||||
|
||||
/*!
|
||||
* \brief Time units enumeration.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user