diff --git a/pkg/rtsp/helpers.go b/pkg/rtsp/helpers.go index 2d619364..6b07342d 100644 --- a/pkg/rtsp/helpers.go +++ b/pkg/rtsp/helpers.go @@ -30,6 +30,9 @@ func UnmarshalSDP(rawSDP []byte) ([]*core.Media, error) { // fix multiple `s=` https://github.com/AlexxIT/WebRTC/issues/417 rawSDP = regexp.MustCompile("\ns=[^\n]+").ReplaceAll(rawSDP, nil) + // fix broken `c=` https://github.com/AlexxIT/go2rtc/issues/1426 + rawSDP = regexp.MustCompile("\nc=[^\n]+").ReplaceAll(rawSDP, nil) + // fix SDP header for some cameras if i := bytes.Index(rawSDP, []byte("\nm=")); i > 0 { rawSDP = append([]byte(sdpHeader), rawSDP[i:]...) diff --git a/pkg/rtsp/rtsp_test.go b/pkg/rtsp/rtsp_test.go index 43248ba6..14c99803 100644 --- a/pkg/rtsp/rtsp_test.go +++ b/pkg/rtsp/rtsp_test.go @@ -203,6 +203,40 @@ a=control:track5 assert.Len(t, medias, 4) } +func TestBugSDP7(t *testing.T) { + // https://github.com/AlexxIT/go2rtc/issues/1426 + s := `v=0 +o=- 1001 1 IN +s=VCP IPC Realtime stream +m=video 0 RTP/AVP 105 +c=IN +a=control:rtsp://1.0.1.113/media/video2/video +a=rtpmap:105 H264/90000 +a=fmtp:105 profile-level-id=640016; packetization-mode=1; sprop-parameter-sets=Z2QAFqw7UFAX/LCAAAH0AABOIEI=,aOqPLA== +a=recvonly +m=audio 0 RTP/AVP 0 +c=IN +a=fmtp:0 RTCP=0 +a=control:rtsp://1.0.1.113/media/video2/audio1 +a=recvonly +m=audio 0 RTP/AVP 0 +c=IN +a=control:rtsp://1.0.1.113/media/video2/backchannel +a=rtpmap:0 PCMA/8000 +a=rtpmap:0 PCMU/8000 +a=sendonly +m=application 0 RTP/AVP 107 +c=IN +a=control:rtsp://1.0.1.113/media/video2/metadata +a=rtpmap:107 vnd.onvif.metadata/90000 +a=fmtp:107 DecoderTag=h3c-v3 RTCP=0 +a=recvonly +` + medias, err := UnmarshalSDP([]byte(s)) + assert.Nil(t, err) + assert.Len(t, medias, 4) +} + func TestHikvisionPCM(t *testing.T) { s := `v=0 o=- 1721969533379665 1721969533379665 IN IP4 192.168.1.12