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