pull/244/head
q191201771 2 years ago
parent df33fffda4
commit fc26b1ebc7

@ -1,6 +1,6 @@
{
"# doc of config": "https://pengrl.com/lal/#/ConfigBrief",
"conf_version": "v0.4.0",
"conf_version": "v0.4.1",
"rtmp": {
"enable": true,
"addr": ":1935",

@ -1,6 +1,6 @@
{
"# doc of config": "https://pengrl.com/lal/#/ConfigBrief",
"conf_version": "v0.4.0",
"conf_version": "v0.4.1",
"rtmp": {
"enable": true,
"addr": ":1935",
@ -27,7 +27,7 @@
"enable_https": true,
"url_pattern": "/",
"gop_num": 0,
"single_gop_max_frame_num": 0,
"single_gop_max_frame_num": 0
},
"hls": {
"enable": true,
@ -45,7 +45,7 @@
"enable_https": true,
"url_pattern": "/",
"gop_num": 0,
"single_gop_max_frame_num": 0,
"single_gop_max_frame_num": 0
},
"rtsp": {
"enable": true,

@ -19,7 +19,7 @@ import "strings"
const LalVersion = "v0.32.0"
// ConfVersion lalserver的配置文件的版本号
const ConfVersion = "v0.4.0"
const ConfVersion = "v0.4.1"
// HttpApiVersion lalserver的HTTP-API功能的版本号
const HttpApiVersion = "v0.4.2"

@ -51,15 +51,15 @@ type Config struct {
}
type RtmpConfig struct {
Enable bool `json:"enable"`
Addr string `json:"addr"`
RtmpsEnable bool `json:"rtmps_enable"`
RtmpsAddr string `json:"rtmps_addr"`
RtmpsCertFile string `json:"rtmps_cert_file"`
RtmpsKeyFile string `json:"rtmps_key_file"`
GopNum int `json:"gop_num"` // TODO(chef): refactor 更名为gop_cache_num
SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"`
MergeWriteSize int `json:"merge_write_size"`
Enable bool `json:"enable"`
Addr string `json:"addr"`
RtmpsEnable bool `json:"rtmps_enable"`
RtmpsAddr string `json:"rtmps_addr"`
RtmpsCertFile string `json:"rtmps_cert_file"`
RtmpsKeyFile string `json:"rtmps_key_file"`
GopNum int `json:"gop_num"` // TODO(chef): refactor 更名为gop_cache_num
SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"`
MergeWriteSize int `json:"merge_write_size"`
}
type InSessionConfig struct {
@ -74,15 +74,15 @@ type DefaultHttpConfig struct {
type HttpflvConfig struct {
CommonHttpServerConfig
GopNum int `json:"gop_num"`
SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"`
GopNum int `json:"gop_num"`
SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"`
}
type HttptsConfig struct {
CommonHttpServerConfig
GopNum int `json:"gop_num"`
SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"`
GopNum int `json:"gop_num"`
SingleGopMaxFrameNum int `json:"single_gop_max_frame_num"`
}
type HlsConfig struct {

@ -59,10 +59,10 @@ type GopCache struct {
VideoSeqHeader []byte
AacSeqHeader []byte
gopRing []Gop
gopRingFirst int
gopRingLast int
gopSize int
gopRing []Gop
gopRingFirst int
gopRingLast int
gopSize int
singleGopMaxFrameNum int
}
@ -71,15 +71,15 @@ type GopCache struct {
// @param gopNum: gop缓存大小。
// - 如果为0则不缓存音频数据也即GOP缓存功能不生效。
// - 如果>0则缓存[0, gopNum]个GOP最多缓存 gopNum 个GOP。注意最后一个GOP可能是不完整的。
func NewGopCache(t string, uniqueKey string, gopNum int,singleGopMaxFrameNum int) *GopCache {
func NewGopCache(t string, uniqueKey string, gopNum int, singleGopMaxFrameNum int) *GopCache {
return &GopCache{
t: t,
uniqueKey: uniqueKey,
gopSize: gopNum + 1,
gopRing: make([]Gop, gopNum+1, gopNum+1),
gopRingFirst: 0,
gopRingLast: 0,
singleGopMaxFrameNum:singleGopMaxFrameNum,
t: t,
uniqueKey: uniqueKey,
gopSize: gopNum + 1,
gopRing: make([]Gop, gopNum+1, gopNum+1),
gopRingFirst: 0,
gopRingLast: 0,
singleGopMaxFrameNum: singleGopMaxFrameNum,
}
}
@ -155,8 +155,8 @@ func (gc *GopCache) Clear() {
// 注意如果GopCache为空则不缓存msg
func (gc *GopCache) feedLastGop(msg base.RtmpMsg, b []byte) {
if !gc.isGopRingEmpty() {
gopPos:=(gc.gopRingLast-1+gc.gopSize)%gc.gopSize
if gc.gopRing[gopPos].len()<=gc.singleGopMaxFrameNum ||gc.singleGopMaxFrameNum==0{
gopPos := (gc.gopRingLast - 1 + gc.gopSize) % gc.gopSize
if gc.gopRing[gopPos].len() <= gc.singleGopMaxFrameNum || gc.singleGopMaxFrameNum == 0 {
gc.gopRing[gopPos].Feed(msg, b)
}
}
@ -198,6 +198,6 @@ func (g *Gop) Feed(msg base.RtmpMsg, b []byte) {
func (g *Gop) Clear() {
g.data = g.data[:0]
}
func (g *Gop) len()int {
func (g *Gop) len() int {
return len(g.data)
}
}

@ -17,21 +17,21 @@ type GopCacheMpegts struct {
uniqueKey string
gopNum int
gopRing []GopMpegts
gopRingFirst int
gopRingLast int
gopSize int
gopRing []GopMpegts
gopRingFirst int
gopRingLast int
gopSize int
singleGopMaxFrameNum int
}
func NewGopCacheMpegts(uniqueKey string, gopNum int,singleGopMaxFrameNum int) *GopCacheMpegts {
func NewGopCacheMpegts(uniqueKey string, gopNum int, singleGopMaxFrameNum int) *GopCacheMpegts {
return &GopCacheMpegts{
uniqueKey: uniqueKey,
gopNum: gopNum,
gopSize: gopNum + 1,
gopRing: make([]GopMpegts, gopNum+1, gopNum+1),
gopRingFirst: 0,
gopRingLast: 0,
uniqueKey: uniqueKey,
gopNum: gopNum,
gopSize: gopNum + 1,
gopRing: make([]GopMpegts, gopNum+1, gopNum+1),
gopRingFirst: 0,
gopRingLast: 0,
singleGopMaxFrameNum: singleGopMaxFrameNum,
}
}
@ -74,8 +74,8 @@ func (gc *GopCacheMpegts) Clear() {
// 注意如果GopCache为空则不缓存msg
func (gc *GopCacheMpegts) feedLastGop(b []byte) {
if !gc.isGopRingEmpty() {
gopPos:=(gc.gopRingLast-1+gc.gopSize)%gc.gopSize
if gc.gopRing[gopPos].len()<=gc.singleGopMaxFrameNum ||gc.singleGopMaxFrameNum==0{
gopPos := (gc.gopRingLast - 1 + gc.gopSize) % gc.gopSize
if gc.gopRing[gopPos].len() <= gc.singleGopMaxFrameNum || gc.singleGopMaxFrameNum == 0 {
gc.gopRing[gopPos].Feed(b)
}
@ -121,6 +121,6 @@ func (g *GopMpegts) Feed(b []byte) {
func (g *GopMpegts) Clear() {
g.data = g.data[:0]
}
func (g *GopMpegts) len()int {
func (g *GopMpegts) len() int {
return len(g.data)
}
}

@ -59,7 +59,7 @@ func TestGopCache_Feed(t *testing.T) {
i4f := func() []byte { return []byte{1, 4} }
p4f := func() []byte { return []byte{0, 4} }
nc := NewGopCache("rtmp", "test", 3,0)
nc := NewGopCache("rtmp", "test", 3, 0)
assert.Equal(t, 0, nc.GetGopCount())
assert.Equal(t, nil, nc.GetGopDataAt(0))
assert.Equal(t, nil, nc.GetGopDataAt(1))

Loading…
Cancel
Save