Repository: pion/rtp
Pull request #67 (2020-05-19 10:13:47)

Fix TransportLayerCC
Fix TransportLayerCC

#### Description
Fix ID and len

#### Reference issue
Fixes #...


codecov[bot]: # [Codecov](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=h1) Report
> Merging [#67](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=desc) into [master](https://codecov.io/gh/pion/rtp/commit/c23812f8c9034d180c05430d71babea3d4e2db26&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/pion/rtp/pull/67/graphs/tree.svg?width=650&height=150&src=pr&token=4KrbiBsspj)](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
- Coverage   90.86%   90.83%   -0.03%     
==========================================
  Files          13       13              
  Lines         635      633       -2     
==========================================
- Hits          577      575       -2     
  Misses         41       41              
  Partials       17       17              
```

| Flag | Coverage Δ | |
|---|---|---|
| #go | `90.83% <100.00%> (-0.03%)` | :arrow_down: |
| #wasm | `90.83% <100.00%> (-0.03%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [transportccextension.go](https://codecov.io/gh/pion/rtp/pull/67/diff?src=pr&el=tree#diff-dHJhbnNwb3J0Y2NleHRlbnNpb24uZ28=) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=footer). Last update [c23812f...1c26947](https://codecov.io/gh/pion/rtp/pull/67?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/transportccextension.go b/transportccextension.go
index fd585c5..5dcf5b3 100644
--- a/transportccextension.go
+++ b/transportccextension.go
@@ -6,7 +6,8 @@ import (
 )
 
 const (
-	transportCCExtensionSize = 4
+	// transport-wide sequence
+	transportCCExtensionSize = 2
 )
 
 var (
@@ -23,15 +24,13 @@ var (
 // |  ID   | L=1   |transport-wide sequence number | zero padding  |
 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 type TransportCCExtension struct {
-	ID                uint8
 	TransportSequence uint16
 }
 
 // Marshal serializes the members to buffer
 func (t *TransportCCExtension) Marshal() ([]byte, error) {
 	buf := make([]byte, transportCCExtensionSize)
-	buf[0] = t.ID<<4&0xf0 + 1
-	binary.BigEndian.PutUint16(buf[1:3], t.TransportSequence)
+	binary.BigEndian.PutUint16(buf[0:2], t.TransportSequence)
 	return buf, nil
 }
 
@@ -40,7 +39,6 @@ func (t *TransportCCExtension) Unmarshal(rawData []byte) error {
 	if len(rawData) < transportCCExtensionSize {
 		return errTooSmall
 	}
-	t.ID = rawData[0] >> 4
-	t.TransportSequence = binary.BigEndian.Uint16(rawData[1:3])
+	t.TransportSequence = binary.BigEndian.Uint16(rawData[0:2])
 	return nil
 }


Test patch:
diff --git a/transportccextension_test.go b/transportccextension_test.go
index 2164430..11ed9df 100644
--- a/transportccextension_test.go
+++ b/transportccextension_test.go
@@ -19,7 +19,7 @@ func TestTransportCCExtension(t *testing.T) {
 	t1 := TransportCCExtension{}
 
 	rawData := []byte{
-		0x31, 0x00, 0x02, 0x00,
+		0x00, 0x02,
 	}
 
 	if err := t1.Unmarshal(rawData); err != nil {
@@ -27,7 +27,6 @@ func TestTransportCCExtension(t *testing.T) {
 	}
 
 	t2 := TransportCCExtension{
-		ID:                3,
 		TransportSequence: 2,
 	}
 
@@ -45,7 +44,7 @@ func TestTransportCCExtensionExtraBytes(t *testing.T) {
 	t1 := TransportCCExtension{}
 
 	rawData := []byte{
-		0x31, 0x00, 0x02, 0x00, 0xff, 0xff,
+		0x00, 0x02, 0x00, 0xff, 0xff,
 	}
 
 	if err := t1.Unmarshal(rawData); err != nil {
@@ -53,7 +52,6 @@ func TestTransportCCExtensionExtraBytes(t *testing.T) {
 	}
 
 	t2 := TransportCCExtension{
-		ID:                3,
 		TransportSequence: 2,
 	}