Browse Source

TT#12800 records stats average not just for MOS but all values

Change-Id: I1c641a654623022df617da98c4a53ed34decb211
changes/97/12697/7
Richard Fuchs 9 years ago
parent
commit
9108b14b80
4 changed files with 45 additions and 24 deletions
  1. +7
    -6
      daemon/call.c
  2. +17
    -6
      daemon/call_interfaces.c
  3. +10
    -2
      daemon/ssrc.c
  4. +11
    -10
      daemon/ssrc.h

+ 7
- 6
daemon/call.c View File

@ -1914,16 +1914,17 @@ void call_destroy(struct call *c) {
continue;
ilog(LOG_INFO, "--- SSRC %" PRIu32 "", se->ssrc);
ilog(LOG_INFO, "------ Average MOS %i.%i, lowest MOS %i.%i (at %u:%02u), "
"highest MOS %i.%i (at %u:%02u)",
(int) (se->mos_sum / se->stats_blocks.length / 10),
abs(se->mos_sum / se->stats_blocks.length % 10),
ilog(LOG_INFO, "------ Average MOS %" PRIu64 ".%" PRIu64 ", "
"lowest MOS %" PRIu64 ".%" PRIu64 " (at %u:%02u), "
"highest MOS %" PRIu64 ".%" PRIu64 " (at %u:%02u)",
se->average_mos.mos / se->stats_blocks.length / 10,
se->average_mos.mos / se->stats_blocks.length % 10,
se->lowest_mos->mos / 10,
abs(se->lowest_mos->mos % 10),
se->lowest_mos->mos % 10,
(unsigned int) (timeval_diff(&se->lowest_mos->reported, &c->created) / 1000000) / 60,
(unsigned int) (timeval_diff(&se->lowest_mos->reported, &c->created) / 1000000) % 60,
se->highest_mos->mos / 10,
abs(se->highest_mos->mos % 10),
se->highest_mos->mos % 10,
(unsigned int) (timeval_diff(&se->highest_mos->reported, &c->created) / 1000000) / 60,
(unsigned int) (timeval_diff(&se->highest_mos->reported, &c->created) / 1000000) % 60);
}


+ 17
- 6
daemon/call_interfaces.c View File

@ -1012,18 +1012,29 @@ stats:
}
}
static void ng_stats_ssrc_mos_entry_common(bencode_item_t *subent, struct ssrc_stats_block *sb,
unsigned int div)
{
bencode_dictionary_add_integer(subent, "MOS", sb->mos / div);
bencode_dictionary_add_integer(subent, "round-trip time", sb->rtt / div);
bencode_dictionary_add_integer(subent, "jitter", sb->jitter / div);
bencode_dictionary_add_integer(subent, "packet loss", sb->packetloss / div);
}
static void ng_stats_ssrc_mos_entry(bencode_item_t *subent, struct ssrc_stats_block *sb) {
bencode_dictionary_add_integer(subent, "MOS", sb->mos);
ng_stats_ssrc_mos_entry_common(subent, sb, 1);
bencode_dictionary_add_integer(subent, "reported at", sb->reported.tv_sec);
bencode_dictionary_add_integer(subent, "round-trip time", sb->rtt);
bencode_dictionary_add_integer(subent, "jitter", sb->jitter);
bencode_dictionary_add_integer(subent, "packet loss", sb->packetloss);
}
static void ng_stats_ssrc_mos_entry_dict(bencode_item_t *ent, const char *label, struct ssrc_stats_block *sb) {
bencode_item_t *subent = bencode_dictionary_add_dictionary(ent, label);
ng_stats_ssrc_mos_entry(subent, sb);
}
static void ng_stats_ssrc_mos_entry_dict_avg(bencode_item_t *ent, const char *label, struct ssrc_stats_block *sb,
unsigned int div)
{
bencode_item_t *subent = bencode_dictionary_add_dictionary(ent, label);
ng_stats_ssrc_mos_entry_common(subent, sb, div);
bencode_dictionary_add_integer(subent, "samples", div);
}
static void ng_stats_ssrc(bencode_item_t *dict, struct ssrc_hash *ht) {
GList *ll = g_hash_table_get_values(ht->ht);
@ -1037,7 +1048,7 @@ static void ng_stats_ssrc(bencode_item_t *dict, struct ssrc_hash *ht) {
if (!se->stats_blocks.length || !se->lowest_mos || !se->highest_mos)
continue;
bencode_dictionary_add_integer(ent, "average MOS", se->mos_sum / se->stats_blocks.length);
ng_stats_ssrc_mos_entry_dict_avg(ent, "average MOS", &se->average_mos, se->stats_blocks.length);
ng_stats_ssrc_mos_entry_dict(ent, "lowest MOS", se->lowest_mos);
ng_stats_ssrc_mos_entry_dict(ent, "highest MOS", se->highest_mos);


+ 10
- 2
daemon/ssrc.c View File

@ -45,7 +45,10 @@ static void mos_calc(struct ssrc_stats_block *ssb) {
r = 93.2 - (eff_rtt - 120) / 40.0;
r = r - (ssb->packetloss * 2.5);
double mos = 1.0 + (0.035) * r + (.000007) * r * (r-60) * (100-r);
ssb->mos = mos * 10;
int64_t intmos = mos * 10.0;
if (intmos < 0)
intmos = 0;
ssb->mos = intmos;
}
struct ssrc_entry *find_ssrc(u_int32_t ssrc, struct ssrc_hash *ht) {
@ -243,7 +246,12 @@ found:
other_e->lowest_mos = ssb;
if (G_UNLIKELY(!other_e->highest_mos) || ssb->mos > other_e->highest_mos->mos)
other_e->highest_mos = ssb;
other_e->mos_sum += ssb->mos;
// running tally
other_e->average_mos.jitter += ssb->jitter;
other_e->average_mos.rtt += ssb->rtt;
other_e->average_mos.packetloss += ssb->packetloss;
other_e->average_mos.mos += ssb->mos;
goto out_ul_oe;


+ 11
- 10
daemon/ssrc.h View File

@ -30,6 +30,15 @@ struct ssrc_ctx {
srtcp_index;
// XXX move entire crypto context in here?
};
struct ssrc_stats_block {
struct timeval reported;
u_int64_t jitter; // ms
u_int64_t rtt; // us - combined from both sides
u_int64_t packetloss; // percent
u_int64_t mos; // nominal range of 10 - 50 for MOS values 1.0 to 5.0
};
struct ssrc_entry {
mutex_t lock;
u_int32_t ssrc;
@ -38,8 +47,8 @@ struct ssrc_entry {
GQueue sender_reports; // as received via RTCP
GQueue stats_blocks; // calculated
struct ssrc_stats_block *lowest_mos,
*highest_mos;
u_int64_t mos_sum;
*highest_mos,
average_mos; // contains a running tally of all stats blocks
int payload_type; // to determine the clock rate for jitter calculations
unsigned int last_rtt; // last calculated raw rtt without rtt from opposide side
};
@ -48,14 +57,6 @@ enum ssrc_dir { // these values must not be used externally
SSRC_DIR_OUTPUT = G_STRUCT_OFFSET(struct ssrc_entry, output_ctx),
};
struct ssrc_stats_block {
struct timeval reported;
unsigned int jitter; // ms
unsigned int rtt; // us - combined from both sides
unsigned int packetloss; // percent
int mos; // nominal range of 10 - 50 for MOS values 1.0 to 5.0
};
struct ssrc_sender_report {
u_int32_t ssrc;
u_int32_t ntp_msw;


Loading…
Cancel
Save