mirror of
https://github.com/aler9/gortsplib
synced 2025-10-07 08:01:14 +08:00
headers: support RTP-Infos with spaces (https://github.com/aler9/rtsp-simple-server/issues/333)
This commit is contained in:
@@ -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)
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user