Fix yet another broken SDP from CN cameras #1426

This commit is contained in:
Alex X
2024-11-01 12:09:44 +03:00
parent 1d1bcb0a63
commit 6b005a666e
2 changed files with 37 additions and 0 deletions

View File

@@ -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:]...)

View File

@@ -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