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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user