Skip to content

Conversation

@milos-lk
Copy link
Contributor

@milos-lk milos-lk commented Sep 8, 2025

Adding opuseparse element before the opus decoder in order to be able to determine buffer durations before the decoder and have ability to signal gaps should it result in smaller (up to 5 frames) gaps. In order to make the PLC logic effective a gap event needs to be signaled to the decoder in addition to enabling its plc property.
A periodic poll of opus decoder stats is also added and exposed as an element message used to update audio qos metrics.

Copy link
Contributor

@boks1971 boks1971 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! once again, I understand only 25% :-) , but lgtm!

if lastDur > 0 {
dur = lastDur
} else {
dur = 20 * time.Millisecond
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:nit: maybe make a const for default opus duration?

func parseStatsString(s string) (OpusDecStats, error) {
var st OpusDecStats

getU64 := func(k string) (uint64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these useful as some util in a utils package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting idea - a generic set of functions for finding an integer in a given regex might be interesting to have somewhere available - is there already a utils package you could recommend for this or you maybe referred to creating a utils package in this project?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We put a lot of utils in protocol repo. Would be good to put it there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to extract it here: livekit/protocol#1195

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


opusPlcMaxFrames = 5
opusDecStatsPollInterval = time.Second * 5
opusDecPlcMaxJitter = 3 * time.Millisecond
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 3ms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semi arbitrary chosen value :)
The case I had in mind was - if the gap is almost one frame (e.g., 18–19 ms when the true frame is 20 ms) still count it as a loss. That probably won't happen as long as we lose full packets. Added for the cases when wall-clock PTS adjustment kicks in (even then it's going to be extremely rare).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants