| 1 | // SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly> |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | |
| 4 | package rtcp |
| 5 | |
| 6 | import ( |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/stretchr/testify/assert" |
| 10 | ) |
| 11 | |
| 12 | var _ Packet = (*TransportLayerCC)(nil) // assert is a Packet |
| 13 | |
| 14 | func TestTransportLayerCC_RunLengthChunkUnmarshal(t *testing.T) { |
| 15 | for _, test := range []struct { |
| 16 | Name string |
| 17 | Data []byte |
| 18 | Want RunLengthChunk |
| 19 | WantError error |
| 20 | }{ |
| 21 | { |
| 22 | // 3.1.3 example1: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 23 | Name: "example1", |
| 24 | Data: []byte{0, 0xDD}, |
| 25 | Want: RunLengthChunk{ |
| 26 | Type: TypeTCCRunLengthChunk, |
| 27 | PacketStatusSymbol: TypeTCCPacketNotReceived, |
| 28 | RunLength: 221, |
| 29 | }, |
| 30 | WantError: nil, |
| 31 | }, |
| 32 | { |
| 33 | // 3.1.3 example2: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 34 | Name: "example2", |
| 35 | Data: []byte{0x60, 0x18}, |
| 36 | Want: RunLengthChunk{ |
| 37 | Type: TypeTCCRunLengthChunk, |
| 38 | PacketStatusSymbol: TypeTCCPacketReceivedWithoutDelta, |
| 39 | RunLength: 24, |
| 40 | }, |
| 41 | WantError: nil, |
| 42 | }, |
| 43 | } { |
| 44 | var chunk RunLengthChunk |
| 45 | assert.NoError(t, chunk.Unmarshal(test.Data)) |
| 46 | assert.Equalf(t, test.Want, chunk, "Unmarshal %q", test.Name) |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | func TestTransportLayerCCUnmarshalMaxLength(t *testing.T) { |
| 51 | rawPacket := make([]byte, 4*(0xFFFF+1)) |
| 52 | rawPacket[0] = 0x8f |
| 53 | rawPacket[1] = 0xcd |
| 54 | rawPacket[2] = 0xff |
| 55 | rawPacket[3] = 0xff |
| 56 | |
| 57 | var packet TransportLayerCC |
| 58 | err := packet.Unmarshal(rawPacket) |
| 59 | assert.NoError(t, err) |
| 60 | assert.Equal(t, uint16(0xFFFF), packet.Header.Length) |
| 61 | assert.Zero(t, packet.PacketStatusCount) |
| 62 | } |
| 63 | |
| 64 | func TestTransportLayerCC_RunLengthChunkMarshal(t *testing.T) { |
| 65 | for _, test := range []struct { |
| 66 | Name string |
| 67 | Data RunLengthChunk |
| 68 | Want []byte |
| 69 | WantError error |
| 70 | }{ |
| 71 | { |
| 72 | // 3.1.3 example1: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 73 | Name: "example1", |
| 74 | Data: RunLengthChunk{ |
| 75 | Type: TypeTCCRunLengthChunk, |
| 76 | PacketStatusSymbol: TypeTCCPacketNotReceived, |
| 77 | RunLength: 221, |
| 78 | }, |
| 79 | Want: []byte{0, 0xDD}, |
| 80 | WantError: nil, |
| 81 | }, |
| 82 | { |
| 83 | // 3.1.3 example2: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 84 | Name: "example2", |
| 85 | Data: RunLengthChunk{ |
| 86 | Type: TypeTCCRunLengthChunk, |
| 87 | PacketStatusSymbol: TypeTCCPacketReceivedWithoutDelta, |
| 88 | RunLength: 24, |
| 89 | }, |
| 90 | Want: []byte{0x60, 0x18}, |
| 91 | WantError: nil, |
| 92 | }, |
| 93 | } { |
| 94 | chunk := test.Data |
| 95 | data, _ := chunk.Marshal() |
| 96 | assert.Equalf(t, test.Want, data, "Marshal %q", test.Name) |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | func TestTransportLayerCC_StatusVectorChunkUnmarshal(t *testing.T) { |
| 101 | for _, test := range []struct { |
| 102 | Name string |
| 103 | Data []byte |
| 104 | Want StatusVectorChunk |
| 105 | WantError error |
| 106 | }{ |
| 107 | { |
| 108 | // 3.1.4 example1: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 109 | Name: "example1", |
| 110 | Data: []byte{0x9F, 0x1C}, |
| 111 | Want: StatusVectorChunk{ |
| 112 | Type: TypeTCCStatusVectorChunk, |
| 113 | SymbolSize: TypeTCCSymbolSizeOneBit, |
| 114 | SymbolList: []uint16{ |
| 115 | TypeTCCPacketNotReceived, |
| 116 | TypeTCCPacketReceivedSmallDelta, |
| 117 | TypeTCCPacketReceivedSmallDelta, |
| 118 | TypeTCCPacketReceivedSmallDelta, |
| 119 | TypeTCCPacketReceivedSmallDelta, |
| 120 | TypeTCCPacketReceivedSmallDelta, |
| 121 | TypeTCCPacketNotReceived, |
| 122 | TypeTCCPacketNotReceived, |
| 123 | TypeTCCPacketNotReceived, |
| 124 | TypeTCCPacketReceivedSmallDelta, |
| 125 | TypeTCCPacketReceivedSmallDelta, |
| 126 | TypeTCCPacketReceivedSmallDelta, |
| 127 | TypeTCCPacketNotReceived, |
| 128 | TypeTCCPacketNotReceived, |
| 129 | }, |
| 130 | }, |
| 131 | WantError: nil, |
| 132 | }, |
| 133 | { |
| 134 | // 3.1.4 example2: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 135 | Name: "example2", |
| 136 | Data: []byte{0xCD, 0x50}, |
| 137 | Want: StatusVectorChunk{ |
| 138 | Type: TypeTCCStatusVectorChunk, |
| 139 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 140 | SymbolList: []uint16{ |
| 141 | TypeTCCPacketNotReceived, |
| 142 | TypeTCCPacketReceivedWithoutDelta, |
| 143 | TypeTCCPacketReceivedSmallDelta, |
| 144 | TypeTCCPacketReceivedSmallDelta, |
| 145 | TypeTCCPacketReceivedSmallDelta, |
| 146 | TypeTCCPacketNotReceived, |
| 147 | TypeTCCPacketNotReceived, |
| 148 | }, |
| 149 | }, |
| 150 | WantError: nil, |
| 151 | }, |
| 152 | } { |
| 153 | var chunk StatusVectorChunk |
| 154 | assert.NoErrorf(t, chunk.Unmarshal(test.Data), "Unmarshal %q", test.Name) |
| 155 | assert.Equalf(t, test.Want.Type, chunk.Type, "Unmarshal %q", test.Name) |
| 156 | assert.Equalf(t, test.Want.SymbolSize, chunk.SymbolSize, "Unmarshal %q", test.Name) |
| 157 | assert.Equalf(t, test.Want.SymbolList, chunk.SymbolList, "Unmarshal %q", test.Name) |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | func TestTransportLayerCC_StatusVectorChunkMarshal(t *testing.T) { |
| 162 | for _, test := range []struct { |
| 163 | Name string |
| 164 | Data StatusVectorChunk |
| 165 | Want []byte |
| 166 | WantError error |
| 167 | }{ |
| 168 | { |
| 169 | // 3.1.4 example1: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 170 | Name: "example1", |
| 171 | Data: StatusVectorChunk{ |
| 172 | Type: TypeTCCStatusVectorChunk, |
| 173 | SymbolSize: TypeTCCSymbolSizeOneBit, |
| 174 | SymbolList: []uint16{ |
| 175 | TypeTCCPacketNotReceived, |
| 176 | TypeTCCPacketReceivedSmallDelta, |
| 177 | TypeTCCPacketReceivedSmallDelta, |
| 178 | TypeTCCPacketReceivedSmallDelta, |
| 179 | TypeTCCPacketReceivedSmallDelta, |
| 180 | TypeTCCPacketReceivedSmallDelta, |
| 181 | TypeTCCPacketNotReceived, |
| 182 | TypeTCCPacketNotReceived, |
| 183 | TypeTCCPacketNotReceived, |
| 184 | TypeTCCPacketReceivedSmallDelta, |
| 185 | TypeTCCPacketReceivedSmallDelta, |
| 186 | TypeTCCPacketReceivedSmallDelta, |
| 187 | TypeTCCPacketNotReceived, |
| 188 | TypeTCCPacketNotReceived, |
| 189 | }, |
| 190 | }, |
| 191 | Want: []byte{0x9F, 0x1C}, |
| 192 | WantError: nil, |
| 193 | }, |
| 194 | { |
| 195 | // 3.1.4 example2: https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions-01#page-7 |
| 196 | Name: "example2", |
| 197 | Data: StatusVectorChunk{ |
| 198 | Type: TypeTCCStatusVectorChunk, |
| 199 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 200 | SymbolList: []uint16{ |
| 201 | TypeTCCPacketNotReceived, |
| 202 | TypeTCCPacketReceivedWithoutDelta, |
| 203 | TypeTCCPacketReceivedSmallDelta, |
| 204 | TypeTCCPacketReceivedSmallDelta, |
| 205 | TypeTCCPacketReceivedSmallDelta, |
| 206 | TypeTCCPacketNotReceived, |
| 207 | TypeTCCPacketNotReceived, |
| 208 | }, |
| 209 | }, |
| 210 | Want: []byte{0xCD, 0x50}, |
| 211 | WantError: nil, |
| 212 | }, |
| 213 | } { |
| 214 | chunk := test.Data |
| 215 | data, _ := chunk.Marshal() |
| 216 | assert.Equal(t, test.Want, data, "Unmarshal %q", test.Name) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func TestTransportLayerCC_RecvDeltaUnmarshal(t *testing.T) { |
| 221 | for _, test := range []struct { |
| 222 | Name string |
| 223 | Data []byte |
| 224 | Want RecvDelta |
| 225 | WantError error |
| 226 | }{ |
| 227 | { |
| 228 | Name: "small delta 63.75ms", |
| 229 | Data: []byte{0xFF}, |
| 230 | Want: RecvDelta{ |
| 231 | Type: TypeTCCPacketReceivedSmallDelta, |
| 232 | // 255 * 250 |
| 233 | Delta: 63750, |
| 234 | }, |
| 235 | WantError: nil, |
| 236 | }, |
| 237 | { |
| 238 | Name: "big delta 8191.75ms", |
| 239 | Data: []byte{0x7F, 0xFF}, |
| 240 | Want: RecvDelta{ |
| 241 | Type: TypeTCCPacketReceivedLargeDelta, |
| 242 | // 32767 * 250 |
| 243 | Delta: 8191750, |
| 244 | }, |
| 245 | WantError: nil, |
| 246 | }, |
| 247 | { |
| 248 | Name: "big delta -8192ms", |
| 249 | Data: []byte{0x80, 0x00}, |
| 250 | Want: RecvDelta{ |
| 251 | Type: TypeTCCPacketReceivedLargeDelta, |
| 252 | // -32768 * 250 |
| 253 | Delta: -8192000, |
| 254 | }, |
| 255 | WantError: nil, |
| 256 | }, |
| 257 | } { |
| 258 | var chunk RecvDelta |
| 259 | assert.NoErrorf(t, chunk.Unmarshal(test.Data), "Unmarshal %q", test.Name) |
| 260 | assert.Equalf(t, test.Want, chunk, "Unmarshal %q", test.Name) |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | func TestTransportLayerCC_RecvDeltaMarshal(t *testing.T) { |
| 265 | for _, test := range []struct { |
| 266 | Name string |
| 267 | Data RecvDelta |
| 268 | Want []byte |
| 269 | WantError error |
| 270 | }{ |
| 271 | { |
| 272 | Name: "small delta 63.75ms", |
| 273 | Data: RecvDelta{ |
| 274 | Type: TypeTCCPacketReceivedSmallDelta, |
| 275 | // 255 * 250 |
| 276 | Delta: 63750, |
| 277 | }, |
| 278 | Want: []byte{0xFF}, |
| 279 | WantError: nil, |
| 280 | }, |
| 281 | { |
| 282 | Name: "big delta 8191.75ms", |
| 283 | Data: RecvDelta{ |
| 284 | Type: TypeTCCPacketReceivedLargeDelta, |
| 285 | // 32767 * 250 |
| 286 | Delta: 8191750, |
| 287 | }, |
| 288 | Want: []byte{0x7F, 0xFF}, |
| 289 | WantError: nil, |
| 290 | }, |
| 291 | { |
| 292 | Name: "big delta -8192ms", |
| 293 | Data: RecvDelta{ |
| 294 | Type: TypeTCCPacketReceivedLargeDelta, |
| 295 | // -32768 * 250 |
| 296 | Delta: -8192000, |
| 297 | }, |
| 298 | Want: []byte{0x80, 0x00}, |
| 299 | WantError: nil, |
| 300 | }, |
| 301 | } { |
| 302 | chunk := test.Data |
| 303 | data, _ := chunk.Marshal() |
| 304 | assert.Equalf(t, test.Want, data, "Unmarshal %q", test.Name) |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | // 0 1 2 3 |
| 309 | // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
| 310 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 311 | // |V=2|P| FMT=15 | PT=205 | length | |
| 312 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 313 | // | SSRC of packet sender | |
| 314 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 315 | // | SSRC of media source | |
| 316 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 317 | // | base sequence number | packet status count | |
| 318 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 319 | // | reference time | fb pkt. count | |
| 320 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 321 | // | packet chunk | recv delta | recv delta | |
| 322 | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 323 | // 0b10101111,0b11001101,0b00000000,0b00000101, |
| 324 | // 0b11111010,0b00010111,0b11111010,0b00010111, |
| 325 | // 0b01000011,0b00000011,0b00101111,0b10100000, |
| 326 | // 0b00000000,0b10011001,0b00000000,0b00000001, |
| 327 | // 0b00111101,0b11101000,0b00000010,0b00010111, |
| 328 | // 0b00100000,0b00000001,0b10010100,0b00000001, |
| 329 | // . |
| 330 | // |
| 331 | //nolint:maintidx |
| 332 | func TestTransportLayerCC_Unmarshal(t *testing.T) { |
| 333 | for _, test := range []struct { |
| 334 | Name string |
| 335 | Data []byte |
| 336 | Want TransportLayerCC |
| 337 | WantError error |
| 338 | }{ |
| 339 | { |
| 340 | Name: "example1", |
| 341 | Data: []byte{ |
| 342 | 0xaf, 0xcd, 0x0, 0x5, |
| 343 | 0xfa, 0x17, 0xfa, 0x17, |
| 344 | 0x43, 0x3, 0x2f, 0xa0, |
| 345 | 0x0, 0x99, 0x0, 0x1, |
| 346 | 0x3d, 0xe8, 0x2, 0x17, |
| 347 | 0x20, 0x1, 0x94, 0x1, |
| 348 | }, |
| 349 | Want: TransportLayerCC{ |
| 350 | Header: Header{ |
| 351 | Padding: true, |
| 352 | Count: FormatTCC, |
| 353 | Type: TypeTransportSpecificFeedback, |
| 354 | Length: 5, |
| 355 | }, |
| 356 | SenderSSRC: 4195875351, |
| 357 | MediaSSRC: 1124282272, |
| 358 | BaseSequenceNumber: 153, |
| 359 | PacketStatusCount: 1, |
| 360 | ReferenceTime: 4057090, |
| 361 | FbPktCount: 23, |
| 362 | // 0b00100000, 0b00000001 |
| 363 | PacketChunks: []PacketStatusChunk{ |
| 364 | &RunLengthChunk{ |
| 365 | Type: TypeTCCRunLengthChunk, |
| 366 | PacketStatusSymbol: TypeTCCPacketReceivedSmallDelta, |
| 367 | RunLength: 1, |
| 368 | }, |
| 369 | }, |
| 370 | // 0b10010100 |
| 371 | RecvDeltas: []*RecvDelta{ |
| 372 | { |
| 373 | Type: TypeTCCPacketReceivedSmallDelta, |
| 374 | Delta: 37000, |
| 375 | }, |
| 376 | }, |
| 377 | }, |
| 378 | WantError: nil, |
| 379 | }, |
| 380 | { |
| 381 | Name: "example2", |
| 382 | Data: []byte{ |
| 383 | 0xaf, 0xcd, 0x0, 0x6, |
| 384 | 0xfa, 0x17, 0xfa, 0x17, |
| 385 | 0x19, 0x3d, 0xd8, 0xbb, |
| 386 | 0x1, 0x74, 0x0, 0xe, |
| 387 | 0x45, 0xb1, 0x5a, 0x40, |
| 388 | 0xd8, 0x0, 0xf0, 0xff, |
| 389 | 0xd0, 0x0, 0x0, 0x3, |
| 390 | }, |
| 391 | Want: TransportLayerCC{ |
| 392 | Header: Header{ |
| 393 | Padding: true, |
| 394 | Count: FormatTCC, |
| 395 | Type: TypeTransportSpecificFeedback, |
| 396 | Length: 6, |
| 397 | }, |
| 398 | SenderSSRC: 4195875351, |
| 399 | MediaSSRC: 423483579, |
| 400 | BaseSequenceNumber: 372, |
| 401 | PacketStatusCount: 14, |
| 402 | ReferenceTime: 4567386, |
| 403 | FbPktCount: 64, |
| 404 | PacketChunks: []PacketStatusChunk{ |
| 405 | &StatusVectorChunk{ |
| 406 | Type: TypeTCCStatusVectorChunk, |
| 407 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 408 | SymbolList: []uint16{ |
| 409 | TypeTCCPacketReceivedSmallDelta, |
| 410 | TypeTCCPacketReceivedLargeDelta, |
| 411 | TypeTCCPacketNotReceived, |
| 412 | TypeTCCPacketNotReceived, |
| 413 | TypeTCCPacketNotReceived, |
| 414 | TypeTCCPacketNotReceived, |
| 415 | TypeTCCPacketNotReceived, |
| 416 | }, |
| 417 | }, |
| 418 | &StatusVectorChunk{ |
| 419 | Type: TypeTCCStatusVectorChunk, |
| 420 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 421 | SymbolList: []uint16{ |
| 422 | TypeTCCPacketReceivedWithoutDelta, |
| 423 | TypeTCCPacketNotReceived, |
| 424 | TypeTCCPacketNotReceived, |
| 425 | TypeTCCPacketReceivedWithoutDelta, |
| 426 | TypeTCCPacketReceivedWithoutDelta, |
| 427 | TypeTCCPacketReceivedWithoutDelta, |
| 428 | TypeTCCPacketReceivedWithoutDelta, |
| 429 | }, |
| 430 | }, |
| 431 | }, |
| 432 | // 0b10010100 |
| 433 | RecvDeltas: []*RecvDelta{ |
| 434 | { |
| 435 | Type: TypeTCCPacketReceivedSmallDelta, |
| 436 | Delta: 52000, |
| 437 | }, |
| 438 | { |
| 439 | Type: TypeTCCPacketReceivedLargeDelta, |
| 440 | Delta: 0, |
| 441 | }, |
| 442 | }, |
| 443 | }, |
| 444 | WantError: nil, |
| 445 | }, |
| 446 | { |
| 447 | Name: "example3", |
| 448 | Data: []byte{ |
| 449 | 0xaf, 0xcd, 0x0, 0x7, |
| 450 | 0xfa, 0x17, 0xfa, 0x17, |
| 451 | 0x19, 0x3d, 0xd8, 0xbb, |
| 452 | 0x1, 0x74, 0x0, 0x6, |
| 453 | 0x45, 0xb1, 0x5a, 0x40, |
| 454 | 0x40, 0x2, 0x20, 0x04, |
| 455 | 0x1f, 0xfe, 0x1f, 0x9a, |
| 456 | 0xd0, 0x0, 0xd0, 0x0, |
| 457 | }, |
| 458 | Want: TransportLayerCC{ |
| 459 | Header: Header{ |
| 460 | Padding: true, |
| 461 | Count: FormatTCC, |
| 462 | Type: TypeTransportSpecificFeedback, |
| 463 | Length: 7, |
| 464 | }, |
| 465 | SenderSSRC: 4195875351, |
| 466 | MediaSSRC: 423483579, |
| 467 | BaseSequenceNumber: 372, |
| 468 | PacketStatusCount: 6, |
| 469 | ReferenceTime: 4567386, |
| 470 | FbPktCount: 64, |
| 471 | PacketChunks: []PacketStatusChunk{ |
| 472 | &RunLengthChunk{ |
| 473 | Type: TypeTCCRunLengthChunk, |
| 474 | PacketStatusSymbol: TypeTCCPacketReceivedLargeDelta, |
| 475 | RunLength: 2, |
| 476 | }, |
| 477 | &RunLengthChunk{ |
| 478 | Type: TypeTCCRunLengthChunk, |
| 479 | PacketStatusSymbol: TypeTCCPacketReceivedSmallDelta, |
| 480 | RunLength: 4, |
| 481 | }, |
| 482 | }, |
| 483 | RecvDeltas: []*RecvDelta{ |
| 484 | { |
| 485 | Type: TypeTCCPacketReceivedLargeDelta, |
| 486 | Delta: 2047500, |
| 487 | }, |
| 488 | { |
| 489 | Type: TypeTCCPacketReceivedLargeDelta, |
| 490 | Delta: 2022500, |
| 491 | }, |
| 492 | { |
| 493 | Type: TypeTCCPacketReceivedSmallDelta, |
| 494 | Delta: 52000, |
| 495 | }, |
| 496 | { |
| 497 | Type: TypeTCCPacketReceivedSmallDelta, |
| 498 | Delta: 0, |
| 499 | }, |
| 500 | { |
| 501 | Type: TypeTCCPacketReceivedSmallDelta, |
| 502 | Delta: 52000, |
| 503 | }, |
| 504 | { |
| 505 | Type: TypeTCCPacketReceivedSmallDelta, |
| 506 | Delta: 0, |
| 507 | }, |
| 508 | }, |
| 509 | }, |
| 510 | WantError: nil, |
| 511 | }, |
| 512 | { |
| 513 | Name: "example4", |
| 514 | Data: []byte{ |
| 515 | 0xaf, 0xcd, 0x0, 0x7, |
| 516 | 0xfa, 0x17, 0xfa, 0x17, |
| 517 | 0x19, 0x3d, 0xd8, 0xbb, |
| 518 | 0x0, 0x4, 0x0, 0x7, |
| 519 | 0x10, 0x63, 0x6e, 0x1, |
| 520 | 0x20, 0x7, 0x4c, 0x24, |
| 521 | 0x24, 0x10, 0xc, 0xc, |
| 522 | 0x10, 0x0, 0x0, 0x3, |
| 523 | }, |
| 524 | Want: TransportLayerCC{ |
| 525 | Header: Header{ |
| 526 | Padding: true, |
| 527 | Count: FormatTCC, |
| 528 | Type: TypeTransportSpecificFeedback, |
| 529 | Length: 7, |
| 530 | }, |
| 531 | SenderSSRC: 4195875351, |
| 532 | MediaSSRC: 423483579, |
| 533 | BaseSequenceNumber: 4, |
| 534 | PacketStatusCount: 7, |
| 535 | ReferenceTime: 1074030, |
| 536 | FbPktCount: 1, |
| 537 | PacketChunks: []PacketStatusChunk{ |
| 538 | &RunLengthChunk{ |
| 539 | Type: TypeTCCRunLengthChunk, |
| 540 | PacketStatusSymbol: TypeTCCPacketReceivedSmallDelta, |
| 541 | RunLength: 7, |
| 542 | }, |
| 543 | }, |
| 544 | RecvDeltas: []*RecvDelta{ |
| 545 | { |
| 546 | Type: TypeTCCPacketReceivedSmallDelta, |
| 547 | Delta: 19000, |
| 548 | }, |
| 549 | { |
| 550 | Type: TypeTCCPacketReceivedSmallDelta, |
| 551 | Delta: 9000, |
| 552 | }, |
| 553 | { |
| 554 | Type: TypeTCCPacketReceivedSmallDelta, |
| 555 | Delta: 9000, |
| 556 | }, |
| 557 | { |
| 558 | Type: TypeTCCPacketReceivedSmallDelta, |
| 559 | Delta: 4000, |
| 560 | }, |
| 561 | { |
| 562 | Type: TypeTCCPacketReceivedSmallDelta, |
| 563 | Delta: 3000, |
| 564 | }, |
| 565 | { |
| 566 | Type: TypeTCCPacketReceivedSmallDelta, |
| 567 | Delta: 3000, |
| 568 | }, |
| 569 | { |
| 570 | Type: TypeTCCPacketReceivedSmallDelta, |
| 571 | Delta: 4000, |
| 572 | }, |
| 573 | }, |
| 574 | }, |
| 575 | WantError: nil, |
| 576 | }, |
| 577 | { |
| 578 | Name: "example5", |
| 579 | Data: []byte{ |
| 580 | 0xaf, 0xcd, 0x0, 0x6, |
| 581 | 0xfa, 0x17, 0xfa, 0x17, |
| 582 | 0x19, 0x3d, 0xd8, 0xbb, |
| 583 | 0x0, 0x1, 0x0, 0xe, |
| 584 | 0x10, 0x63, 0x6d, 0x0, |
| 585 | 0xba, 0x0, 0x10, 0xc, |
| 586 | 0xc, 0x10, 0x0, 0x3, |
| 587 | }, |
| 588 | Want: TransportLayerCC{ |
| 589 | Header: Header{ |
| 590 | Padding: true, |
| 591 | Count: FormatTCC, |
| 592 | Type: TypeTransportSpecificFeedback, |
| 593 | Length: 6, |
| 594 | }, |
| 595 | SenderSSRC: 4195875351, |
| 596 | MediaSSRC: 423483579, |
| 597 | BaseSequenceNumber: 1, |
| 598 | PacketStatusCount: 14, |
| 599 | ReferenceTime: 1074029, |
| 600 | FbPktCount: 0, |
| 601 | PacketChunks: []PacketStatusChunk{ |
| 602 | &StatusVectorChunk{ |
| 603 | Type: TypeTCCStatusVectorChunk, |
| 604 | SymbolSize: 0, |
| 605 | SymbolList: []uint16{ |
| 606 | TypeTCCPacketReceivedSmallDelta, |
| 607 | TypeTCCPacketReceivedSmallDelta, |
| 608 | TypeTCCPacketReceivedSmallDelta, |
| 609 | TypeTCCPacketNotReceived, |
| 610 | TypeTCCPacketReceivedSmallDelta, |
| 611 | TypeTCCPacketNotReceived, |
| 612 | TypeTCCPacketNotReceived, |
| 613 | TypeTCCPacketNotReceived, |
| 614 | TypeTCCPacketNotReceived, |
| 615 | TypeTCCPacketNotReceived, |
| 616 | TypeTCCPacketNotReceived, |
| 617 | TypeTCCPacketNotReceived, |
| 618 | TypeTCCPacketNotReceived, |
| 619 | TypeTCCPacketNotReceived, |
| 620 | }, |
| 621 | }, |
| 622 | }, |
| 623 | RecvDeltas: []*RecvDelta{ |
| 624 | { |
| 625 | Type: TypeTCCPacketReceivedSmallDelta, |
| 626 | Delta: 4000, |
| 627 | }, |
| 628 | { |
| 629 | Type: TypeTCCPacketReceivedSmallDelta, |
| 630 | Delta: 3000, |
| 631 | }, |
| 632 | { |
| 633 | Type: TypeTCCPacketReceivedSmallDelta, |
| 634 | Delta: 3000, |
| 635 | }, |
| 636 | { |
| 637 | Type: TypeTCCPacketReceivedSmallDelta, |
| 638 | Delta: 4000, |
| 639 | }, |
| 640 | }, |
| 641 | }, |
| 642 | WantError: nil, |
| 643 | }, |
| 644 | { |
| 645 | Name: "example6", |
| 646 | Data: []byte{ |
| 647 | 0xaf, 0xcd, 0x0, 0x7, |
| 648 | 0x9b, 0x74, 0xf6, 0x1f, |
| 649 | 0x93, 0x71, 0xdc, 0xbc, |
| 650 | 0x85, 0x3c, 0x0, 0x9, |
| 651 | 0x63, 0xf9, 0x16, 0xb3, |
| 652 | 0xd5, 0x52, 0x0, 0x30, |
| 653 | 0x9b, 0xaa, 0x6a, 0xaa, |
| 654 | 0x7b, 0x1, 0x9, 0x1, |
| 655 | }, |
| 656 | Want: TransportLayerCC{ |
| 657 | Header: Header{ |
| 658 | Padding: true, |
| 659 | Count: FormatTCC, |
| 660 | Type: TypeTransportSpecificFeedback, |
| 661 | Length: 7, |
| 662 | }, |
| 663 | SenderSSRC: 2608133663, |
| 664 | MediaSSRC: 2473712828, |
| 665 | BaseSequenceNumber: 34108, |
| 666 | PacketStatusCount: 9, |
| 667 | ReferenceTime: 6551830, |
| 668 | FbPktCount: 179, |
| 669 | PacketChunks: []PacketStatusChunk{ |
| 670 | &StatusVectorChunk{ |
| 671 | Type: TypeTCCStatusVectorChunk, |
| 672 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 673 | SymbolList: []uint16{ |
| 674 | TypeTCCPacketReceivedSmallDelta, |
| 675 | TypeTCCPacketReceivedSmallDelta, |
| 676 | TypeTCCPacketReceivedSmallDelta, |
| 677 | TypeTCCPacketReceivedSmallDelta, |
| 678 | TypeTCCPacketReceivedSmallDelta, |
| 679 | TypeTCCPacketNotReceived, |
| 680 | TypeTCCPacketReceivedLargeDelta, |
| 681 | }, |
| 682 | }, |
| 683 | &RunLengthChunk{ |
| 684 | Type: TypeTCCRunLengthChunk, |
| 685 | PacketStatusSymbol: TypeTCCPacketNotReceived, |
| 686 | RunLength: 48, |
| 687 | }, |
| 688 | }, |
| 689 | RecvDeltas: []*RecvDelta{ |
| 690 | { |
| 691 | Type: TypeTCCPacketReceivedSmallDelta, |
| 692 | Delta: 38750, |
| 693 | }, |
| 694 | { |
| 695 | Type: TypeTCCPacketReceivedSmallDelta, |
| 696 | Delta: 42500, |
| 697 | }, |
| 698 | { |
| 699 | Type: TypeTCCPacketReceivedSmallDelta, |
| 700 | Delta: 26500, |
| 701 | }, |
| 702 | { |
| 703 | Type: TypeTCCPacketReceivedSmallDelta, |
| 704 | Delta: 42500, |
| 705 | }, |
| 706 | { |
| 707 | Type: TypeTCCPacketReceivedSmallDelta, |
| 708 | Delta: 30750, |
| 709 | }, |
| 710 | { |
| 711 | Type: TypeTCCPacketReceivedLargeDelta, |
| 712 | Delta: 66250, |
| 713 | }, |
| 714 | }, |
| 715 | }, |
| 716 | WantError: nil, |
| 717 | }, |
| 718 | { |
| 719 | Name: "example7", |
| 720 | Data: []byte{ |
| 721 | 0x8f, 0xcd, 0x0, 0x4, |
| 722 | 0x9a, 0xcb, 0x4, 0x42, |
| 723 | 0x0, 0x0, 0x0, 0x0, |
| 724 | 0x0, 0x0, 0x0, 0x0, |
| 725 | 0x0, 0x0, 0x0, 0x0, |
| 726 | }, |
| 727 | Want: TransportLayerCC{ |
| 728 | Header: Header{ |
| 729 | Padding: false, |
| 730 | Count: FormatTCC, |
| 731 | Type: TypeTransportSpecificFeedback, |
| 732 | Length: 4, |
| 733 | }, |
| 734 | SenderSSRC: 2596996162, |
| 735 | MediaSSRC: 0, |
| 736 | BaseSequenceNumber: 0, |
| 737 | PacketStatusCount: 0, |
| 738 | ReferenceTime: 0, |
| 739 | FbPktCount: 0, |
| 740 | }, |
| 741 | WantError: nil, |
| 742 | }, |
| 743 | { |
| 744 | Name: "example8", |
| 745 | Data: []byte{ |
| 746 | 0xaf, 0xcd, 0x0, 0x5, |
| 747 | 0xfa, 0x17, 0xfa, 0x17, |
| 748 | 0x43, 0x3, 0x2f, 0xa0, |
| 749 | 0x0, 0x99, 0x0, 0x3, |
| 750 | 0x3d, 0xe8, 0x2, 0x17, |
| 751 | 0x20, 0x3, 0x94, 0x1, |
| 752 | }, |
| 753 | Want: TransportLayerCC{}, |
| 754 | WantError: errPacketTooShort, |
| 755 | }, |
| 756 | { |
| 757 | Name: "example9", |
| 758 | Data: []byte{ |
| 759 | 0xaf, 0xcd, 0x0, 0x5, |
| 760 | 0xfa, 0x17, 0xfa, 0x17, |
| 761 | 0x43, 0x3, 0x2f, 0xa0, |
| 762 | 0x0, 0x99, 0x0, 0x2, |
| 763 | 0x3d, 0xe8, 0x2, 0x17, |
| 764 | 0x40, 0x2, 0x94, 0x1, |
| 765 | }, |
| 766 | Want: TransportLayerCC{}, |
| 767 | WantError: errPacketTooShort, |
| 768 | }, |
| 769 | } { |
| 770 | t.Run(test.Name, func(t *testing.T) { |
| 771 | var chunk TransportLayerCC |
| 772 | err := chunk.Unmarshal(test.Data) |
| 773 | assert.ErrorIsf(t, err, test.WantError, "Unmarshal %q", test.Name) |
| 774 | if err != nil { |
| 775 | return |
| 776 | } |
| 777 | assert.Equalf(t, test.Want, chunk, "Unmarshal %q", test.Name) |
| 778 | }) |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | //nolint:maintidx |
| 783 | func TestTransportLayerCC_Marshal(t *testing.T) { |
| 784 | for _, test := range []struct { |
| 785 | Name string |
| 786 | Data TransportLayerCC |
| 787 | Want []byte |
| 788 | WantError error |
| 789 | }{ |
| 790 | { |
| 791 | Name: "example1", |
| 792 | Data: TransportLayerCC{ |
| 793 | Header: Header{ |
| 794 | Padding: true, |
| 795 | Count: FormatTCC, |
| 796 | Type: TypeTransportSpecificFeedback, |
| 797 | Length: 5, |
| 798 | }, |
| 799 | SenderSSRC: 4195875351, |
| 800 | MediaSSRC: 1124282272, |
| 801 | BaseSequenceNumber: 153, |
| 802 | PacketStatusCount: 1, |
| 803 | ReferenceTime: 4057090, |
| 804 | FbPktCount: 23, |
| 805 | // 0b00100000, 0b00000001 |
| 806 | PacketChunks: []PacketStatusChunk{ |
| 807 | &RunLengthChunk{ |
| 808 | Type: TypeTCCRunLengthChunk, |
| 809 | PacketStatusSymbol: TypeTCCPacketReceivedSmallDelta, |
| 810 | RunLength: 1, |
| 811 | }, |
| 812 | }, |
| 813 | // 0b10010100 |
| 814 | RecvDeltas: []*RecvDelta{ |
| 815 | { |
| 816 | Type: TypeTCCPacketReceivedSmallDelta, |
| 817 | Delta: 37000, |
| 818 | }, |
| 819 | }, |
| 820 | }, |
| 821 | Want: []byte{ |
| 822 | 0xaf, 0xcd, 0x0, 0x5, |
| 823 | 0xfa, 0x17, 0xfa, 0x17, |
| 824 | 0x43, 0x3, 0x2f, 0xa0, |
| 825 | 0x0, 0x99, 0x0, 0x1, |
| 826 | 0x3d, 0xe8, 0x2, 0x17, |
| 827 | 0x20, 0x1, 0x94, 0x1, |
| 828 | }, |
| 829 | WantError: nil, |
| 830 | }, |
| 831 | { |
| 832 | Name: "example2", |
| 833 | Data: TransportLayerCC{ |
| 834 | Header: Header{ |
| 835 | Padding: true, |
| 836 | Count: FormatTCC, |
| 837 | Type: TypeTransportSpecificFeedback, |
| 838 | Length: 6, |
| 839 | }, |
| 840 | SenderSSRC: 4195875351, |
| 841 | MediaSSRC: 423483579, |
| 842 | BaseSequenceNumber: 372, |
| 843 | PacketStatusCount: 2, |
| 844 | ReferenceTime: 4567386, |
| 845 | FbPktCount: 64, |
| 846 | PacketChunks: []PacketStatusChunk{ |
| 847 | &StatusVectorChunk{ |
| 848 | Type: TypeTCCStatusVectorChunk, |
| 849 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 850 | SymbolList: []uint16{ |
| 851 | TypeTCCPacketReceivedSmallDelta, |
| 852 | TypeTCCPacketReceivedLargeDelta, |
| 853 | TypeTCCPacketNotReceived, |
| 854 | TypeTCCPacketNotReceived, |
| 855 | TypeTCCPacketNotReceived, |
| 856 | TypeTCCPacketNotReceived, |
| 857 | TypeTCCPacketNotReceived, |
| 858 | }, |
| 859 | }, |
| 860 | &StatusVectorChunk{ |
| 861 | Type: TypeTCCStatusVectorChunk, |
| 862 | SymbolSize: TypeTCCSymbolSizeTwoBit, |
| 863 | SymbolList: []uint16{ |
| 864 | TypeTCCPacketReceivedWithoutDelta, |
| 865 | TypeTCCPacketNotReceived, |
| 866 | TypeTCCPacketNotReceived, |
| 867 | TypeTCCPacketReceivedWithoutDelta, |
| 868 | TypeTCCPacketReceivedWithoutDelta, |
| 869 | TypeTCCPacketReceivedWithoutDelta, |
| 870 | TypeTCCPacketReceivedWithoutDelta, |
| 871 | }, |
| 872 | }, |
| 873 | }, |
| 874 | // 0b10010100 |
| 875 | RecvDeltas: []*RecvDelta{ |
| 876 | { |
| 877 | Type: TypeTCCPacketReceivedSmallDelta, |
| 878 | Delta: 52000, |
| 879 | }, |
| 880 | { |
| 881 | Type: TypeTCCPacketReceivedLargeDelta, |
| 882 | Delta: 0, |
| 883 | }, |
| 884 | }, |
| 885 | }, |
| 886 | Want: []byte{ |
| 887 | 0xaf, 0xcd, 0x0, 0x6, |
| 888 | 0xfa, 0x17, 0xfa, 0x17, |
| 889 | 0x19, 0x3d, 0xd8, 0xbb, |
| 890 | 0x1, 0x74, 0x0, 0x2, |
| 891 | 0x45, 0xb1, 0x5a, 0x40, |
| 892 | 0xd8, 0x0, 0xf0, 0xff, |
| 893 | 0xd0, 0x0, 0x0, 0x1, |
| 894 | }, |
| 895 | WantError: nil, |
| 896 | }, |
| 897 | { |
| 898 | Name: "example3", |
| 899 | Data: TransportLayerCC{ |
| 900 | Header: Header{ |
| 901 | Padding: true, |
| 902 | Count: FormatTCC, |
| 903 | Type: TypeTransportSpecificFeedback, |
| 904 | Length: 7, |
| 905 | }, |
| 906 | SenderSSRC: 4195875351, |
| 907 | MediaSSRC: 423483579, |
| 908 | BaseSequenceNumber: 372, |
| 909 | PacketStatusCount: 6, |
| 910 | ReferenceTime: 4567386, |
| 911 | FbPktCount: 64, |
| 912 | PacketChunks: []PacketStatusChunk{ |
| 913 | &RunLengthChunk{ |
| 914 | Type: TypeTCCRunLengthChunk, |
| 915 | PacketStatusSymbol: TypeTCCPacketReceivedLargeDelta, |
| 916 | RunLength: 2, |
| 917 | }, |
| 918 | &RunLengthChunk{ |
| 919 | Type: TypeTCCRunLengthChunk, |
| 920 | PacketStatusSymbol: TypeTCCPacketReceivedSmallDelta, |
| 921 | RunLength: 4, |
| 922 | }, |
| 923 | }, |
| 924 | RecvDeltas: []*RecvDelta{ |
| 925 | { |
| 926 | Type: TypeTCCPacketReceivedLargeDelta, |
| 927 | Delta: 2047500, |
| 928 | }, |
| 929 | { |
| 930 | Type: TypeTCCPacketReceivedLargeDelta, |
| 931 | Delta: 2022500, |
| 932 | }, |
| 933 | { |
| 934 | Type: TypeTCCPacketReceivedSmallDelta, |
| 935 | Delta: 52000, |
| 936 | }, |
| 937 | { |
| 938 | Type: TypeTCCPacketReceivedSmallDelta, |
| 939 | Delta: 0, |
| 940 | }, |
| 941 | { |
| 942 | Type: TypeTCCPacketReceivedSmallDelta, |
| 943 | Delta: 52000, |
| 944 | }, |
| 945 | { |
| 946 | Type: TypeTCCPacketReceivedSmallDelta, |
| 947 | Delta: 0, |
| 948 | }, |
| 949 | }, |
| 950 | }, |
| 951 | Want: []byte{ |
| 952 | 0xaf, 0xcd, 0x0, 0x7, |
| 953 | 0xfa, 0x17, 0xfa, 0x17, |
| 954 | 0x19, 0x3d, 0xd8, 0xbb, |
| 955 | 0x1, 0x74, 0x0, 0x6, |
| 956 | 0x45, 0xb1, 0x5a, 0x40, |
| 957 | 0x40, 0x2, 0x20, 0x04, |
| 958 | 0x1f, 0xfe, 0x1f, 0x9a, |
| 959 | 0xd0, 0x0, 0xd0, 0x0, |
| 960 | }, |
| 961 | WantError: nil, |
| 962 | }, |
| 963 | { |
| 964 | Name: "example4", |
| 965 | Data: TransportLayerCC{ |
| 966 | Header: Header{ |
| 967 | Padding: true, |
| 968 | Count: FormatTCC, |
| 969 | Type: TypeTransportSpecificFeedback, |
| 970 | Length: 7, |
| 971 | }, |
| 972 | SenderSSRC: 4195875351, |
| 973 | MediaSSRC: 423483579, |
| 974 | BaseSequenceNumber: 4, |
| 975 | PacketStatusCount: 7, |
| 976 | ReferenceTime: 1074030, |
| 977 | FbPktCount: 1, |
| 978 | PacketChunks: []PacketStatusChunk{ |
| 979 | &RunLengthChunk{ |
| 980 | Type: TypeTCCRunLengthChunk, |
| 981 | PacketStatusSymbol: TypeTCCPacketReceivedSmallDelta, |
| 982 | RunLength: 7, |
| 983 | }, |
| 984 | }, |
| 985 | RecvDeltas: []*RecvDelta{ |
| 986 | { |
| 987 | Type: TypeTCCPacketReceivedSmallDelta, |
| 988 | Delta: 19000, |
| 989 | }, |
| 990 | { |
| 991 | Type: TypeTCCPacketReceivedSmallDelta, |
| 992 | Delta: 9000, |
| 993 | }, |
| 994 | { |
| 995 | Type: TypeTCCPacketReceivedSmallDelta, |
| 996 | Delta: 9000, |
| 997 | }, |
| 998 | { |
| 999 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1000 | Delta: 4000, |
| 1001 | }, |
| 1002 | { |
| 1003 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1004 | Delta: 3000, |
| 1005 | }, |
| 1006 | { |
| 1007 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1008 | Delta: 3000, |
| 1009 | }, |
| 1010 | { |
| 1011 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1012 | Delta: 4000, |
| 1013 | }, |
| 1014 | }, |
| 1015 | }, |
| 1016 | Want: []byte{ |
| 1017 | 0xaf, 0xcd, 0x0, 0x7, |
| 1018 | 0xfa, 0x17, 0xfa, 0x17, |
| 1019 | 0x19, 0x3d, 0xd8, 0xbb, |
| 1020 | 0x0, 0x4, 0x0, 0x7, |
| 1021 | 0x10, 0x63, 0x6e, 0x1, |
| 1022 | 0x20, 0x7, 0x4c, 0x24, |
| 1023 | 0x24, 0x10, 0xc, 0xc, |
| 1024 | 0x10, 0x0, 0x0, 0x3, |
| 1025 | }, |
| 1026 | WantError: nil, |
| 1027 | }, |
| 1028 | { |
| 1029 | Name: "example5", |
| 1030 | Data: TransportLayerCC{ |
| 1031 | Header: Header{ |
| 1032 | Padding: true, |
| 1033 | Count: FormatTCC, |
| 1034 | Type: TypeTransportSpecificFeedback, |
| 1035 | Length: 6, |
| 1036 | }, |
| 1037 | SenderSSRC: 4195875351, |
| 1038 | MediaSSRC: 423483579, |
| 1039 | BaseSequenceNumber: 1, |
| 1040 | PacketStatusCount: 14, |
| 1041 | ReferenceTime: 1074029, |
| 1042 | FbPktCount: 0, |
| 1043 | PacketChunks: []PacketStatusChunk{ |
| 1044 | &StatusVectorChunk{ |
| 1045 | Type: TypeTCCStatusVectorChunk, |
| 1046 | SymbolSize: TypeTCCSymbolSizeOneBit, |
| 1047 | SymbolList: []uint16{ |
| 1048 | TypeTCCPacketReceivedSmallDelta, |
| 1049 | TypeTCCPacketReceivedSmallDelta, |
| 1050 | TypeTCCPacketReceivedSmallDelta, |
| 1051 | TypeTCCPacketNotReceived, |
| 1052 | TypeTCCPacketReceivedSmallDelta, |
| 1053 | TypeTCCPacketNotReceived, |
| 1054 | TypeTCCPacketNotReceived, |
| 1055 | TypeTCCPacketNotReceived, |
| 1056 | TypeTCCPacketNotReceived, |
| 1057 | TypeTCCPacketNotReceived, |
| 1058 | TypeTCCPacketNotReceived, |
| 1059 | TypeTCCPacketNotReceived, |
| 1060 | TypeTCCPacketNotReceived, |
| 1061 | TypeTCCPacketNotReceived, |
| 1062 | }, |
| 1063 | }, |
| 1064 | }, |
| 1065 | RecvDeltas: []*RecvDelta{ |
| 1066 | { |
| 1067 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1068 | Delta: 4000, |
| 1069 | }, |
| 1070 | { |
| 1071 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1072 | Delta: 3000, |
| 1073 | }, |
| 1074 | { |
| 1075 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1076 | Delta: 3000, |
| 1077 | }, |
| 1078 | { |
| 1079 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1080 | Delta: 4000, |
| 1081 | }, |
| 1082 | }, |
| 1083 | }, |
| 1084 | Want: []byte{ |
| 1085 | 0xaf, 0xcd, 0x0, 0x6, |
| 1086 | 0xfa, 0x17, 0xfa, 0x17, |
| 1087 | 0x19, 0x3d, 0xd8, 0xbb, |
| 1088 | 0x0, 0x1, 0x0, 0xe, |
| 1089 | 0x10, 0x63, 0x6d, 0x0, |
| 1090 | 0xba, 0x0, 0x10, 0xc, |
| 1091 | 0xc, 0x10, 0x0, 0x2, |
| 1092 | }, |
| 1093 | WantError: nil, |
| 1094 | }, |
| 1095 | { |
| 1096 | Name: "example6", |
| 1097 | Data: TransportLayerCC{ |
| 1098 | Header: Header{ |
| 1099 | Padding: true, |
| 1100 | Count: FormatTCC, |
| 1101 | Type: TypeTransportSpecificFeedback, |
| 1102 | Length: 7, |
| 1103 | }, |
| 1104 | SenderSSRC: 4195875351, |
| 1105 | MediaSSRC: 1124282272, |
| 1106 | BaseSequenceNumber: 39956, |
| 1107 | PacketStatusCount: 12, |
| 1108 | ReferenceTime: 7701536, |
| 1109 | FbPktCount: 0, |
| 1110 | PacketChunks: []PacketStatusChunk{ |
| 1111 | &StatusVectorChunk{ |
| 1112 | Type: TypeTCCStatusVectorChunk, |
| 1113 | SymbolSize: TypeTCCSymbolSizeOneBit, |
| 1114 | SymbolList: []uint16{ |
| 1115 | TypeTCCPacketReceivedSmallDelta, |
| 1116 | TypeTCCPacketReceivedSmallDelta, |
| 1117 | TypeTCCPacketReceivedSmallDelta, |
| 1118 | TypeTCCPacketReceivedSmallDelta, |
| 1119 | TypeTCCPacketReceivedSmallDelta, |
| 1120 | TypeTCCPacketNotReceived, |
| 1121 | TypeTCCPacketReceivedSmallDelta, |
| 1122 | TypeTCCPacketReceivedSmallDelta, |
| 1123 | TypeTCCPacketNotReceived, |
| 1124 | TypeTCCPacketNotReceived, |
| 1125 | TypeTCCPacketNotReceived, |
| 1126 | TypeTCCPacketNotReceived, |
| 1127 | }, |
| 1128 | }, |
| 1129 | }, |
| 1130 | RecvDeltas: []*RecvDelta{ |
| 1131 | { |
| 1132 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1133 | Delta: 48250, |
| 1134 | }, |
| 1135 | { |
| 1136 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1137 | Delta: 15750, |
| 1138 | }, |
| 1139 | { |
| 1140 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1141 | Delta: 14750, |
| 1142 | }, |
| 1143 | { |
| 1144 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1145 | Delta: 15750, |
| 1146 | }, |
| 1147 | { |
| 1148 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1149 | Delta: 20750, |
| 1150 | }, |
| 1151 | { |
| 1152 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1153 | Delta: 36000, |
| 1154 | }, |
| 1155 | { |
| 1156 | Type: TypeTCCPacketReceivedSmallDelta, |
| 1157 | Delta: 14750, |
| 1158 | }, |
| 1159 | }, |
| 1160 | }, |
| 1161 | Want: []byte{ |
| 1162 | 0xaf, 0xcd, 0x0, 0x7, |
| 1163 | 0xfa, 0x17, 0xfa, 0x17, |
| 1164 | 0x43, 0x3, 0x2f, 0xa0, |
| 1165 | 0x9c, 0x14, 0x0, 0xc, |
| 1166 | 0x75, 0x84, 0x20, 0x0, |
| 1167 | |
| 1168 | 0xbe, 0xc0, 0xc1, 0x3f, |
| 1169 | 0x3b, 0x3f, 0x53, 0x90, |
| 1170 | 0x3b, 0x0, 0x0, 0x3, |
| 1171 | }, |
| 1172 | WantError: nil, |
| 1173 | }, |
| 1174 | } { |
| 1175 | t.Run(test.Name, func(t *testing.T) { |
| 1176 | bin, err := test.Data.Marshal() |
| 1177 | assert.NoError(t, err) |
| 1178 | assert.Equalf(t, test.Want, bin, "Marshal %q", test.Name) |
| 1179 | }) |
| 1180 | } |
| 1181 | } |