mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-06 17:16:55 +08:00
23 lines
542 B
Plaintext
23 lines
542 B
Plaintext
package engine
|
|
|
|
import (
|
|
"github.com/Monibuca/utils/v3/go2"
|
|
)
|
|
type TrackPack interface {
|
|
type VideoPack,AudioPack
|
|
}
|
|
type Track[T TrackPack] struct {
|
|
Buffer *go2.Ring[T]
|
|
PacketCount int
|
|
CodecID byte
|
|
BPS int
|
|
lastIndex byte
|
|
}
|
|
|
|
func (t *Track[T]) GetBPS(payloadLen int){
|
|
t.PacketCount++
|
|
if lastTimestamp := t.Buffer.GetAt(t.lastIndex).Timestamp;lastTimestamp > 0 && lastTimestamp != t.Buffer.Current.Timestamp {
|
|
t.BPS = payloadLen * 1000 / int(t.Buffer.Current.Timestamp-lastTimestamp)
|
|
}
|
|
t.lastIndex = t.Buffer.Index
|
|
} |