From 7d08e06922b22652877694313e54b83c27e47b1f Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Sun, 21 Aug 2022 14:49:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9sdp=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=8C=85=E5=90=ABsps=E5=92=8Cpps=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publisher.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/publisher.go b/publisher.go index 8b95973..8357cb8 100644 --- a/publisher.go +++ b/publisher.go @@ -63,8 +63,12 @@ func (p *RTSPPublisher) SetTracks() error { } p.Tracks[trackId] = vt t := track.(*gortsplib.TrackH264) - vt.WriteSlice(common.NALUSlice{t.SPS}) - vt.WriteSlice(common.NALUSlice{t.PPS}) + if len(t.SPS) > 0 { + vt.WriteSlice(common.NALUSlice{t.SPS}) + } + if len(t.PPS) > 0 { + vt.WriteSlice(common.NALUSlice{t.PPS}) + } case "h265", "hevc": vt := NewH265(p.Stream) if payloadType, err := strconv.Atoi(vals[0]); err == nil {