Skip to content

Commit

Permalink
fix SDP error with AXIS 221 (bluenviron/mediamtx#2708)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Apr 16, 2024
1 parent 721eb88 commit 7023291
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 69 deletions.
9 changes: 6 additions & 3 deletions pkg/sdp/sdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,13 @@ func (s *SessionDescription) unmarshalOrigin(value string) error {
s.Origin.SessionID, err = strconv.ParseUint(tmp[2:], 16, 64)
case strings.ContainsAny(tmp, "abcdefABCDEF"):
s.Origin.SessionID, err = strconv.ParseUint(tmp, 16, 64)
case strings.ContainsAny(tmp, "."):
i := strings.Index(tmp, ".")
s.Origin.SessionID, err = strconv.ParseUint(tmp[:i], 16, 64)
default:
if strings.ContainsAny(tmp, ".") {
i := strings.Index(tmp, ".")
tmp = tmp[:i]
}
tmp = strings.TrimPrefix(tmp, "-")

s.Origin.SessionID, err = strconv.ParseUint(tmp, 10, 64)
}
if err != nil {
Expand Down
119 changes: 53 additions & 66 deletions pkg/sdp/sdp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2561,7 +2561,7 @@ var cases = []struct {
"a=fmtp:96 packetization-mode=1; profile-level-id=33;" +
" sprop-parameter-sets=Z00AM4qKUDwBE/L/4AAgAC2AgA==,aO48gA==\r\n"),
[]byte("v=0\r\n" +
"o=- 97041581188 97041581188 IN IP4 46.242.10.231:12626\r\n" +
"o=- 1698210484 1698210484 IN IP4 46.242.10.231:12626\r\n" +
"s=Playout\r\n" +
"m=video 0 RTP/AVP 96\r\n" +
"a=rtpmap:96 H264/90000\r\n" +
Expand All @@ -2570,8 +2570,8 @@ var cases = []struct {
SessionDescription{
Origin: psdp.Origin{
Username: "-",
SessionID: 97041581188,
SessionVersion: 97041581188,
SessionID: 1698210484,
SessionVersion: 1698210484,
NetworkType: "IN",
AddressType: "IP4",
UnicastAddress: "46.242.10.231:12626",
Expand Down Expand Up @@ -2937,9 +2937,9 @@ var cases = []struct {
"a=control:trackID=1\r\n" +
"a=rtpmap:96 MP4V-ES/90000\r\n" +
"a=fmtp:96 profile-level-id=245; config=000001B0F5000001B509000001000000012008D48D88032514043C14440F\r\n" +
"a=mpeg4-esid:201"),
"a=mpeg4-esid:201\r\n"),
[]byte("v=0\r\n" +
"o=- -1962418793961427 -1962418793961418 IN IP4 192.168.221.104\r\n" +
"o=- 1962418793961427 1962418793961418 IN IP4 192.168.221.104\r\n" +
"s=Media Presentation\r\n" +
"e=NONE\r\n" +
"c=IN IP4 0.0.0.0\r\n" +
Expand All @@ -2954,91 +2954,78 @@ var cases = []struct {
"a=control:trackID=1\r\n" +
"a=rtpmap:96 MP4V-ES/90000\r\n" +
"a=fmtp:96 profile-level-id=245; config=000001B0F5000001B509000001000000012008D48D88032514043C14440F\r\n" +
"a=mpeg4-esid:201"),
"a=mpeg4-esid:201\r\n"),
SessionDescription{
Origin: psdp.Origin{
Username: "-",
SessionID: 1705180917694,
SessionVersion: 1705180917694,
SessionID: 1962418793961427,
SessionVersion: 1962418793961418,
NetworkType: "IN",
AddressType: "IP4",
UnicastAddress: "192.168.1.63",
UnicastAddress: "192.168.221.104",
},
SessionName: "Live",
SessionName: "Media Presentation",
EmailAddress: func() *psdp.EmailAddress {
v := psdp.EmailAddress("NONE")
return &v
}(),
ConnectionInformation: &psdp.ConnectionInformation{
NetworkType: "IN",
AddressType: "IP4",
Address: &psdp.Address{
Address: "0.0.0.0",
},
},
Bandwidth: []psdp.Bandwidth{{
Type: "AS",
Bandwidth: 8000,
}},
TimeDescriptions: []psdp.TimeDescription{{}},
MediaDescriptions: []*psdp.MediaDescription{
Attributes: []psdp.Attribute{
{
MediaName: psdp.MediaName{
Media: "audio",
Protos: []string{"RTP", "AVP"},
Formats: []string{"0"},
},
ConnectionInformation: &psdp.ConnectionInformation{
NetworkType: "IN",
AddressType: "IP4",
Address: &psdp.Address{
Address: "192.168.1.63",
},
},
Attributes: []psdp.Attribute{
{
Key: "control",
Value: "rtsp://192.168.1.63/defaultPrimary/micCfg0/trackID=9?mtu=1440&streamType=u",
},
{
Key: "recvonly",
Value: "",
},
},
Key: "control",
Value: "*",
},
{
Key: "range",
Value: "npt=now-",
},
{
Key: "mpeg4-iod",
Value: " \"data:application/mpeg4-iod;base64,AoDUAE8BAf/1AQOAbwABQFBkYXRhOmFwcGxpY2F0aW9uL21wZWc0LW9kLWF1O2Jhc2U2NCxBUjBCR3dVZkF4Y0F5U1FBWlFRTklCRUVrK0FBZWhJQUFIb1NBQVlCQkE9PQQNAQUABAAAAAAAAAAAAAYJAQAAAAAAAAAAAzoAAkA2ZGF0YTphcHBsaWNhdGlvbi9tcGVnNC1iaWZzLWF1O2Jhc2U2NCx3QkFTWVFTSVVFVUZQd0E9BBICDQAAAgAAAAAAAAAABQMAAEAGCQEAAAAAAAAAAA==\"",
},
},
MediaDescriptions: []*psdp.MediaDescription{
{
MediaName: psdp.MediaName{
Media: "audio",
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"0", "97"},
},
ConnectionInformation: &psdp.ConnectionInformation{
NetworkType: "IN",
AddressType: "IP4",
Address: &psdp.Address{
Address: "192.168.1.63",
},
Formats: []string{"96"},
},
Bandwidth: []psdp.Bandwidth{{
Type: "AS",
Bandwidth: 8000,
}},
Attributes: []psdp.Attribute{
{
Key: "control",
Value: "rtsp://192.168.1.63/defaultPrimary/spk0/trackID=2?mtu=1440&streamType=u",
Key: "framerate",
Value: "30.0",
},
{
Key: "sendonly",
Key: "control",
Value: "trackID=1",
},
{
Key: "rtpmap",
Value: "0 pcmu/8000",
Value: "96 MP4V-ES/90000",
},
{
Key: "rtpmap",
Value: "97 opus/48000/2",
},
},
},
{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"96"},
},
ConnectionInformation: &psdp.ConnectionInformation{
NetworkType: "IN",
AddressType: "IP4",
Address: &psdp.Address{
Address: "192.168.1.63",
Key: "fmtp",
Value: "96 profile-level-id=245; config=000001B0F5000001B509000001000000012008D48D88032514043C14440F",
},
},
Attributes: []psdp.Attribute{
{
Key: "control",
Value: "rtsp://192.168.1.63/defaultPr",
Key: "mpeg4-esid",
Value: "201",
},
},
},
Expand Down

0 comments on commit 7023291

Please sign in to comment.