mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-07 17:40:57 +08:00
parse config一处判断无效value
This commit is contained in:
@@ -13,10 +13,11 @@ import (
|
||||
)
|
||||
|
||||
func SplitAnnexB[T ~[]byte](frame T, process func(T), delimiter []byte) {
|
||||
for found, after := true, frame; len(frame) > 0 && found; frame = after {
|
||||
frame, after, found = bytes.Cut(frame, delimiter)
|
||||
for after := frame; len(frame) > 0; frame = after {
|
||||
if frame, after, _ = bytes.Cut(frame, delimiter); len(frame) > 0 {
|
||||
process(frame)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type RTPFrame struct {
|
||||
|
@@ -143,10 +143,12 @@ func (config Config) Unmarshal(s any) {
|
||||
}
|
||||
fv.Set(s)
|
||||
default:
|
||||
if value.IsValid() {
|
||||
fv.Set(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 覆盖配置
|
||||
|
@@ -32,6 +32,7 @@ func (p *流速控制) 控制流速(绝对时间戳 uint32) {
|
||||
// }
|
||||
// 如果收到的帧的时间戳超过实际消耗的时间100ms就休息一下,100ms作为一个弹性区间防止频繁调用sleep
|
||||
if 过快 := (数据时间差 - 实际时间差); 过快 > 100*time.Millisecond {
|
||||
// fmt.Println("过快毫秒", 过快.Milliseconds())
|
||||
// println("过快毫秒", p.name, 过快.Milliseconds())
|
||||
if 过快 > p.等待上限 {
|
||||
time.Sleep(p.等待上限)
|
||||
@@ -224,6 +225,7 @@ func (av *Media) Flush() {
|
||||
// av.Stream.Error("sub ring overflow", zap.Int("size", av.AVRing.Size), zap.String("name", av.Name))
|
||||
// }
|
||||
}
|
||||
|
||||
if av.起始时间.IsZero() {
|
||||
curValue.DeltaTime = 0
|
||||
av.重置(curValue.AbsTime)
|
||||
@@ -233,6 +235,7 @@ func (av *Media) Flush() {
|
||||
} else {
|
||||
curValue.DeltaTime = curValue.AbsTime - preValue.AbsTime
|
||||
}
|
||||
// fmt.Println(av.Name,curValue.DTS, curValue.AbsTime, curValue.DeltaTime)
|
||||
if curValue.AUList.Length > 0 {
|
||||
// 补完RTP
|
||||
if config.Global.EnableRTP && curValue.RTP.Length == 0 {
|
||||
|
@@ -93,7 +93,6 @@ func (vt *Video) writeAnnexBSlice(nalu []byte) {
|
||||
}
|
||||
|
||||
func (vt *Video) WriteAnnexB(pts uint32, dts uint32, frame []byte) {
|
||||
// println("write annexb", len(frame), pts, dts)
|
||||
if dts == 0 {
|
||||
vt.generateTimestamp(pts)
|
||||
} else {
|
||||
|
@@ -2,12 +2,23 @@ package util
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"math"
|
||||
"net"
|
||||
)
|
||||
|
||||
type Buffer []byte
|
||||
|
||||
func (b *Buffer) Read(buf []byte) (n int, err error) {
|
||||
if !b.CanReadN(len(buf)) {
|
||||
copy(buf, *b)
|
||||
return b.Len(), io.EOF
|
||||
}
|
||||
ret := b.ReadN(len(buf))
|
||||
copy(buf, ret)
|
||||
return len(ret), err
|
||||
}
|
||||
|
||||
func (b *Buffer) ReadN(n int) Buffer {
|
||||
l := b.Len()
|
||||
r := (*b)[:n]
|
||||
|
Reference in New Issue
Block a user