Set up audio config in audio level module when config is updated. (#4290)

* Set up audio config in audio level module when config is updated.

It is possible to get audio config after bind (bind is where the audio
level module is created) for remote tracks. So, split out setting audio
level config in audio level module and invoke it when config is updated.

* coderabbit review

* prevent divide-by-0

* not active before config
This commit is contained in:
Raja Subramanian
2026-02-05 09:35:26 +05:30
committed by GitHub
parent f3e9b68854
commit 370e0a4d52
3 changed files with 40 additions and 20 deletions
+5 -2
View File
@@ -331,9 +331,9 @@ func (b *BufferBase) BindLocked(rtpParameters webrtc.RTPParameters, codec webrtc
case sdp.AudioLevelURI:
b.audioLevelExtID = uint8(ext.ID)
b.audioLevel = audio.NewAudioLevel(audio.AudioLevelParams{
Config: b.audioLevelConfig,
ClockRate: b.clockRate,
})
b.audioLevel.SetConfig(b.audioLevelConfig)
case act.AbsCaptureTimeURI:
b.absCaptureTimeExtID = uint8(ext.ID)
@@ -434,6 +434,9 @@ func (b *BufferBase) SetAudioLevelConfig(audioLevelConfig audio.AudioLevelConfig
defer b.Unlock()
b.audioLevelConfig = audioLevelConfig
if b.audioLevel != nil {
b.audioLevel.SetConfig(b.audioLevelConfig)
}
}
func (b *BufferBase) SetStreamRestartDetection(enable bool) {
@@ -512,9 +515,9 @@ func (b *BufferBase) restartStreamLocked(reason string, isDetected bool) {
if b.audioLevel != nil {
b.audioLevel = audio.NewAudioLevel(audio.AudioLevelParams{
Config: b.audioLevelConfig,
ClockRate: b.clockRate,
})
b.audioLevel.SetConfig(b.audioLevelConfig)
}
if b.ddExtID != 0 {