This commit is contained in:
aler9
2021-04-02 18:12:56 +02:00
parent d706559900
commit ab6826e6a7
2 changed files with 34 additions and 2 deletions

View File

@@ -28,10 +28,13 @@ func (h *RTPInfo) Read(v base.HeaderValue) error {
return fmt.Errorf("value provided multiple times (%v)", v)
}
for _, tmp := range strings.Split(v[0], ",") {
for _, part := range strings.Split(v[0], ",") {
e := &RTPInfoEntry{}
for _, kv := range strings.Split(tmp, ";") {
// remove leading spaces
part = strings.TrimLeft(part, " ")
for _, kv := range strings.Split(part, ";") {
tmp := strings.SplitN(kv, "=", 2)
if len(tmp) != 2 {
return fmt.Errorf("unable to parse key-value (%v)", kv)

View File

@@ -107,6 +107,35 @@ var casesRTPInfo = []struct {
},
},
},
{
"with space",
base.HeaderValue{`url=rtsp://10.13.146.53/axis-media/media.amp/trackID=1;seq=58477;rtptime=1020884293, url=rtsp://10.13.146.53/axis-media/media.amp/trackID=2;seq=15727;rtptime=1171661503`},
base.HeaderValue{`url=rtsp://10.13.146.53/axis-media/media.amp/trackID=1;seq=58477;rtptime=1020884293,url=rtsp://10.13.146.53/axis-media/media.amp/trackID=2;seq=15727;rtptime=1171661503`},
RTPInfo{
{
URL: "rtsp://10.13.146.53/axis-media/media.amp/trackID=1",
SequenceNumber: func() *uint16 {
v := uint16(58477)
return &v
}(),
Timestamp: func() *uint32 {
v := uint32(1020884293)
return &v
}(),
},
{
URL: "rtsp://10.13.146.53/axis-media/media.amp/trackID=2",
SequenceNumber: func() *uint16 {
v := uint16(15727)
return &v
}(),
Timestamp: func() *uint32 {
v := uint32(1171661503)
return &v
}(),
},
},
},
}
func TestRTPInfoRead(t *testing.T) {