mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-09 02:20:07 +08:00
VideoFrame和AudioFrame增加track的指针方便访问track,rtp写入采用内存复用机制
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
package util
|
||||
|
||||
type CloneType[T any] interface {
|
||||
Clone() T
|
||||
comparable
|
||||
}
|
||||
|
||||
var RTPReorderBufferLen uint16 = 50
|
||||
|
||||
// RTPReorder RTP包乱序重排
|
||||
type RTPReorder[T CloneType[T]] struct {
|
||||
type RTPReorder[T comparable] struct {
|
||||
lastSeq uint16 //最新收到的rtp包序号
|
||||
queue []T // 缓存队列,0号元素位置代表lastReq+1,永远保持为空
|
||||
Total uint32 // 总共收到的包数量
|
||||
Drop uint32 // 丢弃的包数量
|
||||
Total uint32 // 总共收到的包数量
|
||||
Drop uint32 // 丢弃的包数量
|
||||
}
|
||||
|
||||
func (p *RTPReorder[T]) Push(seq uint16, v T) (result T) {
|
||||
@@ -48,7 +43,7 @@ func (p *RTPReorder[T]) Push(seq uint16, v T) (result T) {
|
||||
head := p.pop()
|
||||
// 可以放得进去了
|
||||
if delta == RTPReorderBufferLen {
|
||||
p.queue[RTPReorderBufferLen-1] = v.Clone()
|
||||
p.queue[RTPReorderBufferLen-1] = v
|
||||
p.queue[0] = result
|
||||
return head
|
||||
} else if head != result {
|
||||
@@ -57,7 +52,7 @@ func (p *RTPReorder[T]) Push(seq uint16, v T) (result T) {
|
||||
}
|
||||
} else {
|
||||
// 出现后面的包先到达,缓存起来
|
||||
p.queue[delta-1] = v.Clone()
|
||||
p.queue[delta-1] = v
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user