Declare audio inactive if stale. (#2229)

* Declare audio inactive if stale.

Stale samples were used to declare audio active.
Maintain last update time and declare inactive if samples are stale.

* correct comment

* spelling

* check level in test
This commit is contained in:
Raja Subramanian
2023-11-08 11:13:39 +05:30
committed by GitHub
parent 57643a42ed
commit 440f00bcac
3 changed files with 90 additions and 34 deletions
+2 -2
View File
@@ -583,7 +583,7 @@ func (b *Buffer) processHeaderExtensions(p *rtp.Packet, arrivalTime time.Time) {
if (p.Timestamp - b.latestTSForAudioLevel) < (1 << 31) {
duration := (int64(p.Timestamp) - int64(b.latestTSForAudioLevel)) * 1e3 / int64(b.clockRate)
if duration > 0 {
b.audioLevel.Observe(ext.Level, uint32(duration))
b.audioLevel.Observe(ext.Level, uint32(duration), arrivalTime)
}
b.latestTSForAudioLevel = p.Timestamp
@@ -842,7 +842,7 @@ func (b *Buffer) GetAudioLevel() (float64, bool) {
return 0, false
}
return b.audioLevel.GetLevel()
return b.audioLevel.GetLevel(time.Now())
}
func (b *Buffer) OnFpsChanged(f func()) {