mirror of
https://github.com/Monibuca/engine.git
synced 2026-04-22 15:57:03 +08:00
feat(publish): make media ring initial size configurable via ringsize
This commit is contained in:
+17
-1
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@@ -44,7 +45,22 @@ type Publish struct {
|
|||||||
Key string `desc:"发布鉴权key"` // 发布鉴权key
|
Key string `desc:"发布鉴权key"` // 发布鉴权key
|
||||||
SecretArgName string `default:"secret" desc:"发布鉴权参数名"` // 发布鉴权参数名
|
SecretArgName string `default:"secret" desc:"发布鉴权参数名"` // 发布鉴权参数名
|
||||||
ExpireArgName string `default:"expire" desc:"发布鉴权失效时间参数名"` // 发布鉴权失效时间参数名
|
ExpireArgName string `default:"expire" desc:"发布鉴权失效时间参数名"` // 发布鉴权失效时间参数名
|
||||||
RingSize string `default:"256-1024" desc:"缓冲范围"` // 初始缓冲区大小
|
RingSize string `default:"256-1024" desc:"缓冲范围,取连字符前一段为轨道环形缓冲初始容量"` // 如 "512-1024" 表示初始 512;后缀预留
|
||||||
|
}
|
||||||
|
|
||||||
|
// InitialRingSize 解析 RingSize(首段为整数);非法或为空时返回 256。
|
||||||
|
func (c *Publish) InitialRingSize() int {
|
||||||
|
s := strings.TrimSpace(c.RingSize)
|
||||||
|
if s == "" {
|
||||||
|
return 256
|
||||||
|
}
|
||||||
|
head, _, _ := strings.Cut(s, "-")
|
||||||
|
head = strings.TrimSpace(head)
|
||||||
|
n, err := strconv.Atoi(head)
|
||||||
|
if err != nil || n <= 0 {
|
||||||
|
return 256
|
||||||
|
}
|
||||||
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Publish) GetPublishConfig() Publish {
|
func (c Publish) GetPublishConfig() Publish {
|
||||||
|
|||||||
+1
-1
@@ -158,7 +158,7 @@ func (av *Media) SetStuff(stuff ...any) {
|
|||||||
pubConf := v.GetConfig()
|
pubConf := v.GetConfig()
|
||||||
av.BufferTime = pubConf.BufferTime
|
av.BufferTime = pubConf.BufferTime
|
||||||
av.Base.SetStuff(v)
|
av.Base.SetStuff(v)
|
||||||
av.Init(256, NewAVFrame)
|
av.Init(pubConf.InitialRingSize(), NewAVFrame)
|
||||||
av.SSRC = uint32(uintptr(unsafe.Pointer(av)))
|
av.SSRC = uint32(uintptr(unsafe.Pointer(av)))
|
||||||
av.等待上限 = pubConf.SpeedLimit
|
av.等待上限 = pubConf.SpeedLimit
|
||||||
case uint32:
|
case uint32:
|
||||||
|
|||||||
Reference in New Issue
Block a user