Ignore:
Timestamp:
Jan 28, 2020 6:58:45 AM (4 years ago)
Author:
ming
Message:

Closed #2143: Add AEC info to call info & statistics dump

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/echo_webrtc.c

    r6084 r6140  
    2323#include <pj/log.h> 
    2424#include <pj/pool.h> 
     25#include <pj/string.h> 
    2526 
    2627#if defined(PJMEDIA_HAS_WEBRTC_AEC) && PJMEDIA_HAS_WEBRTC_AEC != 0 
     
    5051    #define WebRtcAec_BufferFarend WebRtcAecm_BufferFarend 
    5152    #define AecConfig AecmConfig 
    52     #define SHOW_DELAY_METRICS  0 
    5353    typedef short sample; 
    5454#else 
     
    5757    typedef float sample; 
    5858 
    59     /* If SHOW_DELAY_METRICS is set to non-zero, delay metrics stats will 
    60      * be printed every SHOW_DELAY_METRICS-th call to webrtc_aec_cancel_echo(). 
    61      * For example, if ptime is 20ms, set this to 250 to print the metrics 
    62      * every 250*20/1000=5 seconds. 
    63      */ 
    64     #define SHOW_DELAY_METRICS  0 
    65      
    6659#endif 
    6760 
    6861#define BUF_LEN                 160 
     62 
     63/* Set this to 0 to disable metrics calculation. */ 
     64#define SHOW_DELAY_METRICS      1 
    6965 
    7066typedef struct webrtc_ec 
     
    8076    sample      tmp_buf[BUF_LEN]; 
    8177    sample      tmp_buf2[BUF_LEN]; 
    82 #if SHOW_DELAY_METRICS 
    83     unsigned    counter; 
    84 #endif 
    8578} webrtc_ec; 
    8679 
     
    356349    } 
    357350 
    358 #if SHOW_DELAY_METRICS 
    359     if (++echo->counter >= SHOW_DELAY_METRICS) { 
    360         int median, std; 
    361         float frac_delay; 
    362  
    363         if (WebRtcAec_GetDelayMetrics(echo->AEC_inst, &median, &std, 
    364                                       &frac_delay) == 0) 
    365         { 
    366             PJ_LOG(3, (THIS_FILE, "WebRTC delay metrics: median=%d, std=%d, " 
    367                                   "fraction of poor delays=%f", 
    368                                   median, std, frac_delay)); 
    369         } 
    370         echo->counter = 0; 
    371     } 
    372 #endif 
    373  
    374351    return PJ_SUCCESS; 
    375352} 
    376353 
    377 #endif 
     354 
     355PJ_DEF(pj_status_t) webrtc_aec_get_stat(void *state, 
     356                                        pjmedia_echo_stat *p_stat) 
     357{ 
     358    webrtc_ec *echo = (webrtc_ec*) state; 
     359 
     360    if (WebRtcAec_GetDelayMetrics(echo->AEC_inst, &p_stat->median, 
     361                                  &p_stat->std, &p_stat->frac_delay) != 0) 
     362    { 
     363        return PJ_EUNKNOWN; 
     364    } 
     365 
     366    p_stat->name = "WebRTC AEC"; 
     367    p_stat->stat_info.ptr = p_stat->buf_; 
     368    p_stat->stat_info.slen = 
     369        pj_ansi_snprintf(p_stat->buf_, sizeof(p_stat->buf_), 
     370                         "WebRTC delay metric: median=%d, std=%d, " 
     371                         "frac of poor delay=%.02f", 
     372                         p_stat->median, p_stat->std, p_stat->frac_delay); 
     373 
     374    return PJ_SUCCESS; 
     375} 
     376 
     377 
     378#endif 
Note: See TracChangeset for help on using the changeset viewer.