Skip to content

Fix audio eMOS calculation and display#10

Merged
Mupati merged 1 commit into
peermetrics:masterfrom
Mupati:fix/audio-emos-rating-display
Apr 1, 2026
Merged

Fix audio eMOS calculation and display#10
Mupati merged 1 commit into
peermetrics:masterfrom
Mupati:fix/audio-emos-rating-display

Conversation

@Mupati
Copy link
Copy Markdown
Collaborator

@Mupati Mupati commented Mar 31, 2026

Summary

  • Fix v1_summary to extract inline audio inbound tracks from main events — inbound audio tracks were embedded inline on main stat events but never iterated over, so compute_emos was never called for them. Added build_track_data helper and loop over inline tracks per snapshot.
  • Fix compute_emos packet loss fallback — previously required remote-outbound-rtp data (which many browsers don't send) for packetsSent. Now falls back to packetsLost / (packetsLost + packetsReceived) from local inbound-rtp stats when remote data is unavailable.
  • Fix compute_emos RTT source — changed RTT lookup from remote.audio.outbound (which never carries roundTripTime) to remote.audio.inbound.
  • Fix compute_emos one-way delay — changed delay = RTT to delay = RTT / 2 per E-model specification.
  • Fix compute_emos guards — added bitrate 0 guard before math.log, packets_sent 0 and total_packets == 0 guards, and fixed operator precedence in auxiliary delay (0.1 * (delay - 150)).
  • Fix check_emos_score shared mutable state — replaced shared issue_template dict with a make_issue_template() factory function to prevent cross-participant corruption.
  • Fix check_emos_score running average — replaced incorrect (avg + score) / 2 with Welford's online mean.
  • Fix event ordering — added ORDER BY created_at ASC, id ASC to get_stats_events and removed events.reverse().
  • Add pending track buffer — per-track events that arrive before their connection's main event are queued and flushed when the snapshot is created.
  • Add @staticmethod to get_stats_events.

Test plan

  • Verified eMOS scores computed for Chrome and Edge participants across multiple test calls
  • Verified packet loss fallback produces correct scores when remote-outbound-rtp is absent
  • Verified zero errors in API logs during summary building
  • Verified check_emos_score correctly accumulates per-participant averages

Summary
- **Fix `v1_summary` to extract inline audio inbound tracks from main events** — inbound audio tracks were embedded inline on main stat events but never iterated over, so `compute_emos` was never called for them. Added `build_track_data` helper and loop over inline tracks per snapshot.
- **Fix `compute_emos` packet loss fallback** — previously required `remote-outbound-rtp` data (which many browsers don't send) for `packetsSent`. Now falls back to `packetsLost / (packetsLost + packetsReceived)` from local `inbound-rtp` stats when remote data is unavailable.
- **Fix `compute_emos` RTT source** — changed RTT lookup from `remote.audio.outbound` (which never carries `roundTripTime`) to `remote.audio.inbound`.
- **Fix `compute_emos` one-way delay** — changed `delay = RTT` to `delay = RTT / 2` per E-model specification.
- **Fix `compute_emos` guards** — added `bitrate 0` guard before `math.log`, `packets_sent 0` and `total_packets == 0` guards, and fixed operator precedence in auxiliary delay (`0.1 * (delay - 150)`).
- **Fix `check_emos_score` shared mutable state** — replaced shared `issue_template` dict with a `make_issue_template()` factory function to prevent cross-participant corruption.
- **Fix `check_emos_score` running average** — replaced incorrect `(avg + score) / 2` with Welford's online mean.
- **Fix event ordering** — added `ORDER BY created_at ASC, id ASC` to `get_stats_events` and removed `events.reverse()`.
- **Add pending track buffer** — per-track events that arrive before their connection's main event are queued and flushed when the snapshot is created.
- **Add `@staticmethod` to `get_stats_events`**.

Test plan
- [x] Verified eMOS scores computed for Chrome and Edge participants across multiple test calls
- [x] Verified packet loss fallback produces correct scores when `remote-outbound-rtp` is absent
- [x] Verified zero errors in API logs during summary building
- [x] Verified `check_emos_score` correctly accumulates per-participant averages
@Mupati Mupati merged commit b267fa4 into peermetrics:master Apr 1, 2026
@Mupati Mupati deleted the fix/audio-emos-rating-display branch April 1, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants