diff --git a/daemon/main.c b/daemon/main.c index eb1de4afb..5ef488fa8 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1036,6 +1036,10 @@ static void options(int *argc, char ***argv) { rtpe_config.mos = MOS_CQ; else if (!strcasecmp(mos, "lq")) rtpe_config.mos = MOS_LQ; +#ifdef WITH_TRANSCODING + else if (!strcasecmp(mos, "legacy")) + rtpe_config.common.mos_type = MOS_LEGACY; +#endif else die("Invalid --mos option ('%s')", mos); } diff --git a/daemon/ssrc.c b/daemon/ssrc.c index 1089adda7..bd7234460 100644 --- a/daemon/ssrc.c +++ b/daemon/ssrc.c @@ -8,6 +8,15 @@ #include "codeclib.h" #include "bufferpool.h" +typedef void mos_calc_fn(struct ssrc_stats_block *ssb); +static mos_calc_fn mos_calc_legacy; + +#ifdef WITH_TRANSCODING +static mos_calc_fn *mos_calcs[__MOS_TYPES] = { + [MOS_LEGACY] = mos_calc_legacy, +}; +#endif + static void __free_ssrc_entry_call(void *e); @@ -67,7 +76,7 @@ static void ssrc_entry_put(void *ep) { } // returned as mos * 10 (i.e. 10 - 50 for 1.0 to 5.0) -static void mos_calc(struct ssrc_stats_block *ssb) { +static void mos_calc_legacy(struct ssrc_stats_block *ssb) { uint64_t rtt = ssb->rtt; if (rtpe_config.mos == MOS_CQ && !rtt) return; // can not compute the MOS-CQ unless we have a valid RTT @@ -422,6 +431,12 @@ void ssrc_receiver_report(struct call_media *m, stream_fd *sfd, const struct ssr RTPE_SAMPLE_SFD(rtt_dsct, rtt, sfd); RTPE_SAMPLE_SFD(packetloss, ssb->packetloss, sfd); + mos_calc_fn *mos_calc = mos_calc_legacy; +#ifdef WITH_TRANSCODING + if (rpt->codec_def) + mos_calc = mos_calcs[rpt->codec_def->mos_type]; +#endif + other_e->packets_lost = rr->packets_lost; mos_calc(ssb); if (ssb->mos) { diff --git a/lib/auxlib.h b/lib/auxlib.h index 3d08bd4df..98555dab8 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -37,6 +37,7 @@ struct rtpengine_common_config { gboolean io_uring; int io_uring_buffers; int max_log_line_length; + int mos_type; // enum in codec_def_t char *evs_lib_path; char *codec_chain_lib_path; int codec_chain_runners; diff --git a/lib/codeclib.c b/lib/codeclib.c index 502868150..666545ca8 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -1652,6 +1652,9 @@ void codeclib_init(int print) { if (def->supplemental) g_queue_push_tail(&__supplemental_codecs, def); + + if (rtpe_common_config_ptr->mos_type) + def->mos_type = rtpe_common_config_ptr->mos_type; } } diff --git a/lib/codeclib.h b/lib/codeclib.h index dfb37df69..3b2b21054 100644 --- a/lib/codeclib.h +++ b/lib/codeclib.h @@ -198,6 +198,11 @@ struct codec_def_s { const int bits_per_sample; const enum media_type media_type; const str silence_pattern; + enum { + MOS_LEGACY = 0, // default + + __MOS_TYPES + } mos_type; // codec-specific callbacks format_init_f *init;