Skip to content

Commit

Permalink
Merge pull request q191201771#142 from suizg/dev
Browse files Browse the repository at this point in the history
[opt] rtsp: lalserver增加配置项rtsp->out_wait_key_frame_flag,用于控制发送rtsp数据时,是否等待关键帧再发送
  • Loading branch information
q191201771 authored Apr 10, 2022
2 parents c096613 + cc7326e commit 3fc508b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
10 changes: 8 additions & 2 deletions conf/ConfigBrief.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@
"gop_num": 0 //. 见rtmp.gop_num
},
"rtsp": {
"enable": true, //. 是否开启rtsp服务的监听,目前只支持rtsp推流
"addr": ":5544" //. rtsp推流地址
"enable": true, //. 是否开启rtsp服务的监听,目前只支持rtsp推流
"addr": ":5544", //. rtsp推流地址
"out_wait_key_frame_flag": true //. rtsp出包时是否等待视频关键帧
// 音频和视频需要同时出,如果音频先出,而视频等待关键帧会导致音画不同步问题,两种情况:
// 1. 不等待视频关键帧,音视频包到了就转发
//
// 2. 等待视频关键帧,视频关键帧到达之前,丢弃音频数据。
// (存在音视频头,但是音频先到,视频晚到的场景等待关键帧会导致超时问题)
},
"record": {
"enable_flv": true, //. 是否开启flv录制
Expand Down
3 changes: 2 additions & 1 deletion conf/lalserver.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
},
"rtsp": {
"enable": true,
"addr": ":5544"
"addr": ":5544",
"out_wait_key_frame_flag": true
},
"record": {
"enable_flv": false,
Expand Down
5 changes: 3 additions & 2 deletions pkg/logic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ type HlsConfig struct {
}

type RtspConfig struct {
Enable bool `json:"enable"`
Addr string `json:"addr"`
Enable bool `json:"enable"`
Addr string `json:"addr"`
OutWaitKeyFrameFlag bool `json:"out_wait_key_frame_flag"`
}

type RecordConfig struct {
Expand Down
4 changes: 2 additions & 2 deletions pkg/logic/group__core_streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ func (group *Group) broadcastByRtmpMsg(msg base.RtmpMsg) {
// ---------------------------------------------------------------------------------------------------------------------

func (group *Group) feedRtpPacket(pkt rtprtcp.RtpPacket) {
// 音频直接发送
if group.sdpCtx.IsAudioPayloadTypeOrigin(int(pkt.Header.PacketType)) {
// 出包时不等待视频关键帧
if !group.config.RtspConfig.OutWaitKeyFrameFlag {
for s := range group.rtspSubSessionSet {
s.WriteRtpPacket(pkt)
}
Expand Down

0 comments on commit 3fc508b

Please sign in to comment.