[opt] 新增一级配置项in_session,支持控制所有输入流,比如增加静音音频

pull/241/head
q191201771 2 years ago
parent 14d175206f
commit bb1b3bc312

@ -1,6 +1,6 @@
{ {
"# doc of config": "https://pengrl.com/lal/#/ConfigBrief", "# doc of config": "https://pengrl.com/lal/#/ConfigBrief",
"conf_version": "v0.3.5", "conf_version": "v0.4.0",
"rtmp": { "rtmp": {
"enable": true, "enable": true,
"addr": ":1935", "addr": ":1935",
@ -9,7 +9,9 @@
"rtmps_cert_file": "./conf/cert.pem", "rtmps_cert_file": "./conf/cert.pem",
"rtmps_key_file": "./conf/key.pem", "rtmps_key_file": "./conf/key.pem",
"gop_num": 0, "gop_num": 0,
"merge_write_size": 0, "merge_write_size": 0
},
"in_session": {
"add_dummy_audio_enable": false, "add_dummy_audio_enable": false,
"add_dummy_audio_wait_audio_ms": 150 "add_dummy_audio_wait_audio_ms": 150
}, },

@ -1,6 +1,6 @@
{ {
"# doc of config": "https://pengrl.com/lal/#/ConfigBrief", "# doc of config": "https://pengrl.com/lal/#/ConfigBrief",
"conf_version": "v0.3.5", "conf_version": "v0.4.0",
"rtmp": { "rtmp": {
"enable": true, "enable": true,
"addr": ":1935", "addr": ":1935",
@ -9,7 +9,9 @@
"rtmps_cert_file": "./conf/cert.pem", "rtmps_cert_file": "./conf/cert.pem",
"rtmps_key_file": "./conf/key.pem", "rtmps_key_file": "./conf/key.pem",
"gop_num": 0, "gop_num": 0,
"merge_write_size": 0, "merge_write_size": 0
},
"in_session": {
"add_dummy_audio_enable": false, "add_dummy_audio_enable": false,
"add_dummy_audio_wait_audio_ms": 150 "add_dummy_audio_wait_audio_ms": 150
}, },

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

@ -31,6 +31,7 @@ const (
type Config struct { type Config struct {
ConfVersion string `json:"conf_version"` ConfVersion string `json:"conf_version"`
RtmpConfig RtmpConfig `json:"rtmp"` RtmpConfig RtmpConfig `json:"rtmp"`
InSessionConfig InSessionConfig `json:"in_session"`
DefaultHttpConfig DefaultHttpConfig `json:"default_http"` DefaultHttpConfig DefaultHttpConfig `json:"default_http"`
HttpflvConfig HttpflvConfig `json:"httpflv"` HttpflvConfig HttpflvConfig `json:"httpflv"`
HlsConfig HlsConfig `json:"hls"` HlsConfig HlsConfig `json:"hls"`
@ -50,16 +51,19 @@ type Config struct {
} }
type RtmpConfig struct { type RtmpConfig struct {
Enable bool `json:"enable"` Enable bool `json:"enable"`
Addr string `json:"addr"` Addr string `json:"addr"`
RtmpsEnable bool `json:"rtmps_enable"` RtmpsEnable bool `json:"rtmps_enable"`
RtmpsAddr string `json:"rtmps_addr"` RtmpsAddr string `json:"rtmps_addr"`
RtmpsCertFile string `json:"rtmps_cert_file"` RtmpsCertFile string `json:"rtmps_cert_file"`
RtmpsKeyFile string `json:"rtmps_key_file"` RtmpsKeyFile string `json:"rtmps_key_file"`
GopNum int `json:"gop_num"` // TODO(chef): refactor 更名为gop_cache_num GopNum int `json:"gop_num"` // TODO(chef): refactor 更名为gop_cache_num
MergeWriteSize int `json:"merge_write_size"` MergeWriteSize int `json:"merge_write_size"`
AddDummyAudioEnable bool `json:"add_dummy_audio_enable"` }
AddDummyAudioWaitAudioMs int `json:"add_dummy_audio_wait_audio_ms"`
type InSessionConfig struct {
AddDummyAudioEnable bool `json:"add_dummy_audio_enable"`
AddDummyAudioWaitAudioMs int `json:"add_dummy_audio_wait_audio_ms"`
} }
type DefaultHttpConfig struct { type DefaultHttpConfig struct {

@ -30,6 +30,8 @@ func (group *Group) AddCustomizePubSession(streamName string) (ICustomizePubSess
} }
group.customizePubSession = NewCustomizePubSessionContext(streamName) group.customizePubSession = NewCustomizePubSessionContext(streamName)
Log.Debugf("[%s] [%s] add customize pub session into group.", group.UniqueKey, group.customizePubSession.UniqueKey())
group.addIn() group.addIn()
if group.shouldStartRtspRemuxer() { if group.shouldStartRtspRemuxer() {
@ -293,7 +295,7 @@ func (group *Group) delPsPubSession(session *gb28181.PubSession) {
if session != group.psPubSession { if session != group.psPubSession {
Log.Warnf("[%s] del ps pub session but not match. del session=%s, group session=%p", Log.Warnf("[%s] del ps pub session but not match. del session=%s, group session=%p",
group.UniqueKey, session.UniqueKey(), group.customizePubSession) group.UniqueKey, session.UniqueKey(), group.psPubSession)
return return
} }
@ -301,10 +303,10 @@ func (group *Group) delPsPubSession(session *gb28181.PubSession) {
} }
func (group *Group) delCustomizePubSession(sessionCtx ICustomizePubSessionContext) { func (group *Group) delCustomizePubSession(sessionCtx ICustomizePubSessionContext) {
Log.Debugf("[%s] [%s] del rtmp PubSession from group.", group.UniqueKey, sessionCtx.UniqueKey()) Log.Debugf("[%s] [%s] del customize PubSession from group.", group.UniqueKey, sessionCtx.UniqueKey())
if sessionCtx != group.customizePubSession { if sessionCtx != group.customizePubSession {
Log.Warnf("[%s] del rtmp pub session but not match. del session=%s, group session=%p", Log.Warnf("[%s] del customize pub session but not match. del session=%s, group session=%p",
group.UniqueKey, sessionCtx.UniqueKey(), group.customizePubSession) group.UniqueKey, sessionCtx.UniqueKey(), group.customizePubSession)
return return
} }
@ -352,10 +354,11 @@ func (group *Group) addIn() {
if group.shouldStartMpegtsRemuxer() { if group.shouldStartMpegtsRemuxer() {
group.rtmp2MpegtsRemuxer = remux.NewRtmp2MpegtsRemuxer(group) group.rtmp2MpegtsRemuxer = remux.NewRtmp2MpegtsRemuxer(group)
nazalog.Debugf("[%s] [%s] NewRtmp2MpegtsRemuxer in group.", group.UniqueKey, group.rtmp2MpegtsRemuxer.UniqueKey())
} }
if group.config.RtmpConfig.AddDummyAudioEnable { if group.config.InSessionConfig.AddDummyAudioEnable {
group.dummyAudioFilter = remux.NewDummyAudioFilter(group.UniqueKey, group.config.RtmpConfig.AddDummyAudioWaitAudioMs, group.broadcastByRtmpMsg) group.dummyAudioFilter = remux.NewDummyAudioFilter(group.UniqueKey, group.config.InSessionConfig.AddDummyAudioWaitAudioMs, group.broadcastByRtmpMsg)
} }
group.startPushIfNeeded() group.startPushIfNeeded()

Loading…
Cancel
Save