Skip to content

Commit

Permalink
Merge branch 'master' into 52-fixes-padding-in-transport-cc
Browse files Browse the repository at this point in the history
  • Loading branch information
adwpc committed May 24, 2020
2 parents ebd045f + a4af353 commit e45d1a9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu
* [Atsushi Watanabe](https://github.com/at-wat)
* [Juliusz Chroboczek](https://github.com/jech)
* [Gabor Pongracz](https://github.com/pongraczgabor87)
* [Simone Gotti](https://github.com/sgotti)
* [lllf](https://github.com/LittleLightLittleFire)


### License
MIT License - see [LICENSE](LICENSE) for full text
2 changes: 1 addition & 1 deletion transport_layer_cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func (r *RecvDelta) Unmarshal(rawPacket []byte) error {
}

r.Type = TypeTCCPacketReceivedLargeDelta
r.Delta = TypeTCCDeltaScaleFactor * int64(binary.BigEndian.Uint16(rawPacket))
r.Delta = TypeTCCDeltaScaleFactor * int64(int16(binary.BigEndian.Uint16(rawPacket)))
return nil
}

Expand Down
32 changes: 28 additions & 4 deletions transport_layer_cc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ func TestTransportLayerCC_RecvDeltaUnmarshal(t *testing.T) {
Name: "small delta 63.75ms",
Data: []byte{0xFF},
Want: RecvDelta{
Type: TypeTCCPacketReceivedSmallDelta,
Type: TypeTCCPacketReceivedSmallDelta,
// 255 * 250
Delta: 63750,
},
WantError: nil,
Expand All @@ -184,11 +185,22 @@ func TestTransportLayerCC_RecvDeltaUnmarshal(t *testing.T) {
Name: "big delta 8191.75ms",
Data: []byte{0x7F, 0xFF},
Want: RecvDelta{
Type: TypeTCCPacketReceivedLargeDelta,
Type: TypeTCCPacketReceivedLargeDelta,
// 32767 * 250
Delta: 8191750,
},
WantError: nil,
},
{
Name: "big delta -8192ms",
Data: []byte{0x80, 0x00},
Want: RecvDelta{
Type: TypeTCCPacketReceivedLargeDelta,
// -32768 * 250
Delta: -8192000,
},
WantError: nil,
},
} {
var chunk RecvDelta
err := chunk.Unmarshal(test.Data)
Expand All @@ -212,7 +224,8 @@ func TestTransportLayerCC_RecvDeltaMarshal(t *testing.T) {
{
Name: "small delta 63.75ms",
Data: RecvDelta{
Type: TypeTCCPacketReceivedSmallDelta,
Type: TypeTCCPacketReceivedSmallDelta,
// 255 * 250
Delta: 63750,
},
Want: []byte{0xFF},
Expand All @@ -221,12 +234,23 @@ func TestTransportLayerCC_RecvDeltaMarshal(t *testing.T) {
{
Name: "big delta 8191.75ms",
Data: RecvDelta{
Type: TypeTCCPacketReceivedLargeDelta,
Type: TypeTCCPacketReceivedLargeDelta,
// 32767 * 250
Delta: 8191750,
},
Want: []byte{0x7F, 0xFF},
WantError: nil,
},
{
Name: "big delta -8192ms",
Data: RecvDelta{
Type: TypeTCCPacketReceivedLargeDelta,
// -32768 * 250
Delta: -8192000,
},
Want: []byte{0x80, 0x00},
WantError: nil,
},
} {
chunk := test.Data
data, _ := chunk.Marshal()
Expand Down

0 comments on commit e45d1a9

Please sign in to comment.