Skip to content

Commit

Permalink
headers: support SSRCs with missing zeros (bluenviron/mediamtx#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 29, 2021
1 parent 150c03a commit 4f595a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/headers/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func (h *Transport) Read(v base.HeaderValue) error {
h.ServerPorts = ports

case "ssrc":
if (len(v) % 2) != 0 {
v = "0" + v
}
tmp, err := hex.DecodeString(v)
if err != nil {
return err
Expand Down
22 changes: 22 additions & 0 deletions pkg/headers/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ var casesTransport = []struct {
}(),
},
},
{
"ssrc odd",
base.HeaderValue{`RTP/AVP/UDP;unicast;server_port=8052;client_port=14186;ssrc=B6020AD;mode=PLAY`},
base.HeaderValue{`RTP/AVP;unicast;client_port=14186-14187;server_port=8052-8053;ssrc=0B6020AD;mode=play`},
Transport{
Protocol: base.StreamProtocolUDP,
Delivery: func() *base.StreamDelivery {
v := base.StreamDeliveryUnicast
return &v
}(),
Mode: func() *TransportMode {
v := TransportModePlay
return &v
}(),
ClientPorts: &[2]int{14186, 14187},
ServerPorts: &[2]int{8052, 8053},
SSRC: func() *uint32 {
v := uint32(0x0B6020AD)
return &v
}(),
},
},
}

func TestTransportRead(t *testing.T) {
Expand Down

0 comments on commit 4f595a1

Please sign in to comment.