mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 15:16:51 +08:00
handle hex session id
This commit is contained in:
@@ -99,9 +99,12 @@ func (s *SessionDescription) unmarshalOrigin(value string) error {
|
||||
|
||||
var sessionID uint64
|
||||
var err error
|
||||
if strings.HasPrefix(fields[1], "0x") {
|
||||
sessionID, err = strconv.ParseUint(fields[1][len("0x"):], 16, 64)
|
||||
} else {
|
||||
switch {
|
||||
case strings.HasPrefix(fields[1], "0x") || strings.HasPrefix(fields[1], "0X"):
|
||||
sessionID, err = strconv.ParseUint(fields[1][2:], 16, 64)
|
||||
case strings.ContainsAny(fields[1], "abcdefABCDEF"):
|
||||
sessionID, err = strconv.ParseUint(fields[1], 16, 64)
|
||||
default:
|
||||
sessionID, err = strconv.ParseUint(fields[1], 10, 64)
|
||||
}
|
||||
if err != nil {
|
||||
|
@@ -1382,6 +1382,68 @@ var cases = []struct {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"hex session id for 0XAC4EC96E",
|
||||
[]byte("v=0\r\n" +
|
||||
"o=jdoe 0XAC4EC96E 2890842807 IN IP4 10.47.16.5\r\n" +
|
||||
"s=SDP Seminar\r\n" +
|
||||
"i=A Seminar on the session description protocol\r\n" +
|
||||
"t=3034423619 3042462419\r\n"),
|
||||
[]byte("v=0\r\n" +
|
||||
"o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r\n" +
|
||||
"s=SDP Seminar\r\n" +
|
||||
"i=A Seminar on the session description protocol\r\n" +
|
||||
"t=3034423619 3042462419\r\n"),
|
||||
SessionDescription{
|
||||
Origin: psdp.Origin{
|
||||
Username: "jdoe",
|
||||
SessionID: 2890844526,
|
||||
SessionVersion: 2890842807,
|
||||
NetworkType: "IN",
|
||||
AddressType: "IP4",
|
||||
UnicastAddress: "10.47.16.5",
|
||||
},
|
||||
SessionName: "SDP Seminar",
|
||||
SessionInformation: func() *psdp.Information {
|
||||
v := psdp.Information("A Seminar on the session description protocol")
|
||||
return &v
|
||||
}(),
|
||||
TimeDescriptions: []psdp.TimeDescription{
|
||||
{psdp.Timing{3034423619, 3042462419}, nil},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"hex session id for 103bdb6f",
|
||||
[]byte("v=0\r\n" +
|
||||
"o=jdoe 103bdb6f 2890842807 IN IP4 10.47.16.5\r\n" +
|
||||
"s=SDP Seminar\r\n" +
|
||||
"i=A Seminar on the session description protocol\r\n" +
|
||||
"t=3034423619 3042462419\r\n"),
|
||||
[]byte("v=0\r\n" +
|
||||
"o=jdoe 272358255 2890842807 IN IP4 10.47.16.5\r\n" +
|
||||
"s=SDP Seminar\r\n" +
|
||||
"i=A Seminar on the session description protocol\r\n" +
|
||||
"t=3034423619 3042462419\r\n"),
|
||||
SessionDescription{
|
||||
Origin: psdp.Origin{
|
||||
Username: "jdoe",
|
||||
SessionID: 272358255,
|
||||
SessionVersion: 2890842807,
|
||||
NetworkType: "IN",
|
||||
AddressType: "IP4",
|
||||
UnicastAddress: "10.47.16.5",
|
||||
},
|
||||
SessionName: "SDP Seminar",
|
||||
SessionInformation: func() *psdp.Information {
|
||||
v := psdp.Information("A Seminar on the session description protocol")
|
||||
return &v
|
||||
}(),
|
||||
TimeDescriptions: []psdp.TimeDescription{
|
||||
{psdp.Timing{3034423619, 3042462419}, nil},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestUnmarshal(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user