diff --git a/pkg/headers/rtpinfo.go b/pkg/headers/rtpinfo.go index 8633accc..4e128d4b 100644 --- a/pkg/headers/rtpinfo.go +++ b/pkg/headers/rtpinfo.go @@ -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) diff --git a/pkg/headers/rtpinfo_test.go b/pkg/headers/rtpinfo_test.go index 2bd53a41..c127dff7 100644 --- a/pkg/headers/rtpinfo_test.go +++ b/pkg/headers/rtpinfo_test.go @@ -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) {