mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-07 17:21:34 +08:00
Fix wrong SDP for MERCURY camera #708
This commit is contained in:
@@ -38,9 +38,8 @@ func UnmarshalSDP(rawSDP []byte) ([]*core.Media, error) {
|
||||
|
||||
// Fix invalid media type (errSDPInvalidValue) caused by
|
||||
// some TP-LINK IP camera, e.g. TL-IPC44GW
|
||||
rawSDP = bytes.ReplaceAll(rawSDP, []byte("m=application/TP-LINK "), []byte("m=application "))
|
||||
// more tplink ipcams
|
||||
rawSDP = bytes.ReplaceAll(rawSDP, []byte("m=application/tp-link "), []byte("m=application "))
|
||||
m := regexp.MustCompile("m=application/[^ ]+")
|
||||
rawSDP = m.ReplaceAll(rawSDP, []byte("m=application"))
|
||||
|
||||
if err == io.EOF {
|
||||
rawSDP = append(rawSDP, '\n')
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package rtsp
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestURLParse(t *testing.T) {
|
||||
@@ -107,3 +108,27 @@ a=sendonly`
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, medias, 3)
|
||||
}
|
||||
|
||||
func TestBugSDP4(t *testing.T) {
|
||||
s := `v=0
|
||||
o=- 14665860 31787219 1 IN IP4 10.0.0.94
|
||||
s=Session streamed by "MERCURY RTSP Server"
|
||||
t=0 0
|
||||
m=video 0 RTP/AVP 96
|
||||
c=IN IP4 0.0.0.0
|
||||
b=AS:4096
|
||||
a=range:npt=0-
|
||||
a=control:track1
|
||||
a=rtpmap:96 H264/90000
|
||||
a=fmtp:96 packetization-mode=1; profile-level-id=640016; sprop-parameter-sets=Z2QAFqzGoCgPaEAAAAMAQAAAB6E=,aOqPLA==
|
||||
m=audio 0 RTP/AVP 8
|
||||
a=rtpmap:8 PCMA/8000
|
||||
a=control:track2
|
||||
m=application/MERCURY 0 RTP/AVP smart/1/90000
|
||||
a=rtpmap:95 MERCURY/90000
|
||||
a=control:track3
|
||||
`
|
||||
medias, err := UnmarshalSDP([]byte(s))
|
||||
assert.Nil(t, err)
|
||||
assert.Len(t, medias, 3)
|
||||
}
|
||||
|
Reference in New Issue
Block a user