Skip to content

Commit

Permalink
Fix yet another broken SDP from CN cameras #1426
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Nov 1, 2024
1 parent 1d1bcb0 commit 6b005a6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/rtsp/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:]...)
Expand Down
34 changes: 34 additions & 0 deletions pkg/rtsp/rtsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b005a6

Please sign in to comment.