修复接续发布

This commit is contained in:
dexter
2023-02-08 14:06:14 +08:00
parent 1744587c88
commit 59b1b94524
2 changed files with 32 additions and 11 deletions

View File

@@ -40,17 +40,24 @@ ffplay -i rtmp://localhost/live/test
```yaml
rtmp:
publish:
pubaudio: true
pubvideo: true
kickexist: false
publishtimeout: 10
waitclosetimeout: 0
delayclosetimeout: 0
pubaudio: true # 是否发布音频流
pubvideo: true # 是否发布视频流
kickexist: false # 剔出已经存在的发布者,用于顶替原有发布者
publishtimeout: 10s # 发布流默认过期时间,超过该时间发布者没有恢复流将被删除
delayclosetimeout: 0 # 自动关闭触发后延迟的时间(期间内如果有新的订阅则取消触发关闭)0为关闭该功能保持连接。
waitclosetimeout: 0 # 发布者断开后等待时间超过该时间发布者没有恢复流将被删除0为关闭该功能由订阅者决定是否删除
buffertime: 0 # 缓存时间用于时光回溯0为关闭缓存
subscribe:
subaudio: true
subvideo: true
iframeonly: false
waittimeout: 10
subaudio: true # 是否订阅音频流
subvideo: true # 是否订阅视频流
subaudioargname: ats # 订阅音频轨道参数名
subvideoargname: vts # 订阅视频轨道参数名
subdataargname: dts # 订阅数据轨道参数名
subaudiotracks: [] # 订阅音频轨道名称列表
subvideotracks: [] # 订阅视频轨道名称列表
submode: 0 # 订阅模式0为跳帧追赶模式1为不追赶多用于录制2为时光回溯模式
iframeonly: false # 只订阅关键帧
waittimeout: 10s # 等待发布者的超时时间,用于订阅尚未发布的流
tcp:
listenaddr: :1935
listennum: 0
@@ -61,7 +68,7 @@ rtmp:
push:
repush: 0 # 当断开后是否自动重新推流0代表不进行重新推流-1代表无限次重新推流
pushlist: {} # 推流列表,以 streamPath为key远程地址为value
chunksize: 4096
chunksize: 65536 # rtmp chunk size
keepalive: false #保持rtmp连接默认随着stream的close而主动断开
```
:::tip 配置覆盖

View File

@@ -121,6 +121,20 @@ type RTMPReceiver struct {
NetStream
}
func (r *RTMPReceiver) OnEvent(event any) {
r.Publisher.OnEvent(event)
switch event.(type) {
case IPublisher:
r.Publisher.OnEvent(event)
if r.AudioTrack != nil {
r.AudioTrack.SetStuff(r.bytePool)
}
if r.VideoTrack != nil {
r.VideoTrack.SetStuff(r.bytePool)
}
}
}
func (r *RTMPReceiver) Response(tid uint64, code, level string) error {
m := new(ResponsePublishMessage)
m.CommandName = Response_OnStatus