Skip to content

Commit 6b005a6

Browse files
committed
Fix yet another broken SDP from CN cameras #1426
1 parent 1d1bcb0 commit 6b005a6

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

pkg/rtsp/helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ func UnmarshalSDP(rawSDP []byte) ([]*core.Media, error) {
3030
// fix multiple `s=` https://github.com/AlexxIT/WebRTC/issues/417
3131
rawSDP = regexp.MustCompile("\ns=[^\n]+").ReplaceAll(rawSDP, nil)
3232

33+
// fix broken `c=` https://github.com/AlexxIT/go2rtc/issues/1426
34+
rawSDP = regexp.MustCompile("\nc=[^\n]+").ReplaceAll(rawSDP, nil)
35+
3336
// fix SDP header for some cameras
3437
if i := bytes.Index(rawSDP, []byte("\nm=")); i > 0 {
3538
rawSDP = append([]byte(sdpHeader), rawSDP[i:]...)

pkg/rtsp/rtsp_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,40 @@ a=control:track5
203203
assert.Len(t, medias, 4)
204204
}
205205

206+
func TestBugSDP7(t *testing.T) {
207+
// https://github.com/AlexxIT/go2rtc/issues/1426
208+
s := `v=0
209+
o=- 1001 1 IN
210+
s=VCP IPC Realtime stream
211+
m=video 0 RTP/AVP 105
212+
c=IN
213+
a=control:rtsp://1.0.1.113/media/video2/video
214+
a=rtpmap:105 H264/90000
215+
a=fmtp:105 profile-level-id=640016; packetization-mode=1; sprop-parameter-sets=Z2QAFqw7UFAX/LCAAAH0AABOIEI=,aOqPLA==
216+
a=recvonly
217+
m=audio 0 RTP/AVP 0
218+
c=IN
219+
a=fmtp:0 RTCP=0
220+
a=control:rtsp://1.0.1.113/media/video2/audio1
221+
a=recvonly
222+
m=audio 0 RTP/AVP 0
223+
c=IN
224+
a=control:rtsp://1.0.1.113/media/video2/backchannel
225+
a=rtpmap:0 PCMA/8000
226+
a=rtpmap:0 PCMU/8000
227+
a=sendonly
228+
m=application 0 RTP/AVP 107
229+
c=IN
230+
a=control:rtsp://1.0.1.113/media/video2/metadata
231+
a=rtpmap:107 vnd.onvif.metadata/90000
232+
a=fmtp:107 DecoderTag=h3c-v3 RTCP=0
233+
a=recvonly
234+
`
235+
medias, err := UnmarshalSDP([]byte(s))
236+
assert.Nil(t, err)
237+
assert.Len(t, medias, 4)
238+
}
239+
206240
func TestHikvisionPCM(t *testing.T) {
207241
s := `v=0
208242
o=- 1721969533379665 1721969533379665 IN IP4 192.168.1.12

0 commit comments

Comments
 (0)