Debian Codegraph @

slice_loss_indication_test.go

raw symbols SCIP
1 // SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
2 // SPDX-License-Identifier: MIT
3
4 package rtcpscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/
5
6 import (
7 "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/"
8
9 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/"
10 )
11
12 var _ Packetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Packet# = (*SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#)(nil) // assert is a Packet
13
14 func TestSliceLossIndicationUnmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestSliceLossIndicationUnmarshal().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
15 for _, test := range []struct {
16 Name string
17 Data []byte
18 Want SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#
19 WantError error
20 }{
21 {
22 Name: "valid",
23 Data: []byte{
24 // SliceLossIndication
25 0x82, 0xcd, 0x0, 0x3,
26 // sender=0x902f9e2e
27 0x90, 0x2f, 0x9e, 0x2e,
28 // media=0x902f9e2e
29 0x90, 0x2f, 0x9e, 0x2e,
30 // nack 0xAAAA, 0x5555
31 0x55, 0x50, 0x00, 0x2C,
32 },
33 Want: SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#{
34 SenderSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#SenderSSRC.: 0x902f9e2e,
35 MediaSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#MediaSSRC.: 0x902f9e2e,
36 SLIscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#SLI.: []SLIEntryscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SLIEntry#{{0xaaa, 0, 0x2C}},
37 },
38 },
39 {
40 Name: "short report",
41 Data: []byte{
42 0x81, 0xcd, 0x0, 0x2,
43 // ssrc=0x902f9e2e
44 0x90, 0x2f, 0x9e, 0x2e,
45 // report ends early
46 },
47 WantError: errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort.,
48 },
49 {
50 Name: "wrong type",
51 Data: []byte{
52 // v=2, p=0, count=1, SR, len=7
53 0x81, 0xc8, 0x0, 0x7,
54 // ssrc=0x902f9e2e
55 0x90, 0x2f, 0x9e, 0x2e,
56 // ssrc=0xbc5e9a40
57 0xbc, 0x5e, 0x9a, 0x40,
58 // fracLost=0, totalLost=0
59 0x0, 0x0, 0x0, 0x0,
60 // lastSeq=0x46e1
61 0x0, 0x0, 0x46, 0xe1,
62 // jitter=273
63 0x0, 0x0, 0x1, 0x11,
64 // lsr=0x9f36432
65 0x9, 0xf3, 0x64, 0x32,
66 // delay=150137
67 0x0, 0x2, 0x4a, 0x79,
68 },
69 WantError: errWrongTypescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errWrongType.,
70 },
71 {
72 Name: "nil",
73 Data: nil,
74 WantError: errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort.,
75 },
76 } {
77 var sli SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#
78 err := sli.Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#Unmarshal().(test.Data)
79 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.ErrorIsfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/ErrorIsf().(t, err, test.WantError, "Unmarshal %q", test.Name)
80 if err != nil {
81 continue
82 }
83
84 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equalf().(t, test.Want, sli, "Unmarshal %q rr", test.Name)
85 }
86 }
87
88 func TestSliceLossIndicationRoundTripscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestSliceLossIndicationRoundTrip().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
89 for _, test := range []struct {
90 Name string
91 Report SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#
92 WantError error
93 }{
94 {
95 Name: "valid",
96 Report: SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#{
97 SenderSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#SenderSSRC.: 0x902f9e2e,
98 MediaSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#MediaSSRC.: 0x902f9e2e,
99 SLIscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#SLI.: []SLIEntryscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SLIEntry#{{1, 0xAA, 0x1F}, {1034, 0x05, 0x6}},
100 },
101 },
102 } {
103 data, err := test.Report.Marshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#Marshal().()
104 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.ErrorIsfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/ErrorIsf().(t, err, test.WantError, "Marshal %q", test.Name)
105 if err != nil {
106 continue
107 }
108
109 var decoded SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#
110 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NoErrorfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NoErrorf().(t, decoded.Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#Unmarshal().(data), "Unmarshal %q", test.Name)
111 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalfscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equalf().(t, test.Report, decoded, "%q sli round trip mismatch", test.Name)
112 }
113 }
114
115 func TestSliceLossIndicationUnmarshalMaxLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestSliceLossIndicationUnmarshalMaxLength().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) {
116 rawPacket := make([]byte, 4*(0xFFFF+1))
117 rawPacket[0] = 0x82
118 rawPacket[1] = 0xcd
119 rawPacket[2] = 0xff
120 rawPacket[3] = 0xff
121
122 var sli SliceLossIndicationscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#
123 err := sli.Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#Unmarshal().(rawPacket)
124 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NoError().(t, err)
125 assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Lenscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Len().(t, sli.SLIscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SliceLossIndication#SLI., 0xFFFF-sliLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/sliLength.)
126 }