[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",
"conf_version": "v0.3.5",
"conf_version": "v0.4.0",
"rtmp": {
"enable": true,
"addr": ":1935",
@ -9,7 +9,9 @@
"rtmps_cert_file": "./conf/cert.pem",
"rtmps_key_file": "./conf/key.pem",
"gop_num": 0,
"merge_write_size": 0,
"merge_write_size": 0
},
"in_session": {
"add_dummy_audio_enable": false,
"add_dummy_audio_wait_audio_ms": 150
},

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

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

@ -31,6 +31,7 @@ const (
type Config struct {
ConfVersion string `json:"conf_version"`
RtmpConfig RtmpConfig `json:"rtmp"`
InSessionConfig InSessionConfig `json:"in_session"`
DefaultHttpConfig DefaultHttpConfig `json:"default_http"`
HttpflvConfig HttpflvConfig `json:"httpflv"`
HlsConfig HlsConfig `json:"hls"`
@ -50,16 +51,19 @@ 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
MergeWriteSize int `json:"merge_write_size"`
AddDummyAudioEnable bool `json:"add_dummy_audio_enable"`
AddDummyAudioWaitAudioMs int `json:"add_dummy_audio_wait_audio_ms"`
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
MergeWriteSize int `json:"merge_write_size"`
}
type InSessionConfig struct {
AddDummyAudioEnable bool `json:"add_dummy_audio_enable"`
AddDummyAudioWaitAudioMs int `json:"add_dummy_audio_wait_audio_ms"`
}
type DefaultHttpConfig struct {

@ -30,6 +30,8 @@ func (group *Group) AddCustomizePubSession(streamName string) (ICustomizePubSess
}
group.customizePubSession = NewCustomizePubSessionContext(streamName)
Log.Debugf("[%s] [%s] add customize pub session into group.", group.UniqueKey, group.customizePubSession.UniqueKey())
group.addIn()
if group.shouldStartRtspRemuxer() {
@ -293,7 +295,7 @@ func (group *Group) delPsPubSession(session *gb28181.PubSession) {
if session != group.psPubSession {
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
}
@ -301,10 +303,10 @@ func (group *Group) delPsPubSession(session *gb28181.PubSession) {
}
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 {
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)
return
}
@ -352,10 +354,11 @@ func (group *Group) addIn() {
if group.shouldStartMpegtsRemuxer() {
group.rtmp2MpegtsRemuxer = remux.NewRtmp2MpegtsRemuxer(group)
nazalog.Debugf("[%s] [%s] NewRtmp2MpegtsRemuxer in group.", group.UniqueKey, group.rtmp2MpegtsRemuxer.UniqueKey())
}
if group.config.RtmpConfig.AddDummyAudioEnable {
group.dummyAudioFilter = remux.NewDummyAudioFilter(group.UniqueKey, group.config.RtmpConfig.AddDummyAudioWaitAudioMs, group.broadcastByRtmpMsg)
if group.config.InSessionConfig.AddDummyAudioEnable {
group.dummyAudioFilter = remux.NewDummyAudioFilter(group.UniqueKey, group.config.InSessionConfig.AddDummyAudioWaitAudioMs, group.broadcastByRtmpMsg)
}
group.startPushIfNeeded()

Loading…
Cancel
Save