From f0893bd78b394cef8bea879d5c40dc29b66eb00d Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Thu, 27 Apr 2023 14:02:55 +0300 Subject: [PATCH] Fix bug in SDP from Annke CZ400 #384 --- pkg/mp4/muxer.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/mp4/muxer.go b/pkg/mp4/muxer.go index 485d8fc6..b1ec37f4 100644 --- a/pkg/mp4/muxer.go +++ b/pkg/mp4/muxer.go @@ -64,9 +64,11 @@ func (m *Muxer) GetInit(codecs []*core.Codec) ([]byte, error) { switch codec.Name { case core.CodecH264: sps, pps := h264.GetParameterSet(codec.FmtpLine) - if sps == nil { - // some dummy SPS and PPS not a problem + // some dummy SPS and PPS not a problem + if len(sps) == 0 { sps = []byte{0x67, 0x42, 0x00, 0x0a, 0xf8, 0x41, 0xa2} + } + if len(pps) == 0 { pps = []byte{0x68, 0xce, 0x38, 0x80} } @@ -83,10 +85,14 @@ func (m *Muxer) GetInit(codecs []*core.Codec) ([]byte, error) { case core.CodecH265: vps, sps, pps := h265.GetParameterSet(codec.FmtpLine) - if sps == nil { - // some dummy SPS and PPS not a problem + // some dummy SPS and PPS not a problem + if len(vps) == 0 { vps = []byte{0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x99, 0xac, 0x09} + } + if len(sps) == 0 { sps = []byte{0x42, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x99, 0xa0, 0x01, 0x40, 0x20, 0x05, 0xa1, 0xfe, 0x5a, 0xee, 0x46, 0xc1, 0xae, 0x55, 0x04} + } + if len(pps) == 0 { pps = []byte{0x44, 0x01, 0xc0, 0x73, 0xc0, 0x4c, 0x90} }