Fix audio eMOS calculation and display#10
Merged
Conversation
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
Boanerges1996
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v1_summaryto extract inline audio inbound tracks from main events — inbound audio tracks were embedded inline on main stat events but never iterated over, socompute_emoswas never called for them. Addedbuild_track_datahelper and loop over inline tracks per snapshot.compute_emospacket loss fallback — previously requiredremote-outbound-rtpdata (which many browsers don't send) forpacketsSent. Now falls back topacketsLost / (packetsLost + packetsReceived)from localinbound-rtpstats when remote data is unavailable.compute_emosRTT source — changed RTT lookup fromremote.audio.outbound(which never carriesroundTripTime) toremote.audio.inbound.compute_emosone-way delay — changeddelay = RTTtodelay = RTT / 2per E-model specification.compute_emosguards — addedbitrate 0guard beforemath.log,packets_sent 0andtotal_packets == 0guards, and fixed operator precedence in auxiliary delay (0.1 * (delay - 150)).check_emos_scoreshared mutable state — replaced sharedissue_templatedict with amake_issue_template()factory function to prevent cross-participant corruption.check_emos_scorerunning average — replaced incorrect(avg + score) / 2with Welford's online mean.ORDER BY created_at ASC, id ASCtoget_stats_eventsand removedevents.reverse().@staticmethodtoget_stats_events.Test plan
remote-outbound-rtpis absentcheck_emos_scorecorrectly accumulates per-participant averages