| 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# = (*RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#)(nil) // assert is a Packet |
| 13 | |
| 14 | func TestRapidResynchronizationRequestUnmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestRapidResynchronizationRequestUnmarshal().(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 RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest# |
| 19 | WantError error |
| 20 | }{ |
| 21 | { |
| 22 | Name: "valid", |
| 23 | Data: []byte{ |
| 24 | // RapidResynchronizationRequest |
| 25 | 0x85, 0xcd, 0x0, 0x2, |
| 26 | // sender=0x902f9e2e |
| 27 | 0x90, 0x2f, 0x9e, 0x2e, |
| 28 | // media=0x902f9e2e |
| 29 | 0x90, 0x2f, 0x9e, 0x2e, |
| 30 | }, |
| 31 | Want: RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#{ |
| 32 | SenderSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#SenderSSRC.: 0x902f9e2e, |
| 33 | MediaSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#MediaSSRC.: 0x902f9e2e, |
| 34 | }, |
| 35 | }, |
| 36 | { |
| 37 | Name: "short report", |
| 38 | Data: []byte{ |
| 39 | 0x85, 0xcd, 0x0, 0x2, |
| 40 | // ssrc=0x902f9e2e |
| 41 | 0x90, 0x2f, 0x9e, 0x2e, |
| 42 | // report ends early |
| 43 | }, |
| 44 | WantError: errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort., |
| 45 | }, |
| 46 | { |
| 47 | Name: "wrong type", |
| 48 | Data: []byte{ |
| 49 | // v=2, p=0, count=1, SR, len=7 |
| 50 | 0x81, 0xc8, 0x0, 0x7, |
| 51 | // ssrc=0x902f9e2e |
| 52 | 0x90, 0x2f, 0x9e, 0x2e, |
| 53 | // ssrc=0xbc5e9a40 |
| 54 | 0xbc, 0x5e, 0x9a, 0x40, |
| 55 | // fracLost=0, totalLost=0 |
| 56 | 0x0, 0x0, 0x0, 0x0, |
| 57 | // lastSeq=0x46e1 |
| 58 | 0x0, 0x0, 0x46, 0xe1, |
| 59 | // jitter=273 |
| 60 | 0x0, 0x0, 0x1, 0x11, |
| 61 | // lsr=0x9f36432 |
| 62 | 0x9, 0xf3, 0x64, 0x32, |
| 63 | // delay=150137 |
| 64 | 0x0, 0x2, 0x4a, 0x79, |
| 65 | }, |
| 66 | WantError: errWrongTypescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errWrongType., |
| 67 | }, |
| 68 | { |
| 69 | Name: "nil", |
| 70 | Data: nil, |
| 71 | WantError: errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort., |
| 72 | }, |
| 73 | } { |
| 74 | var rrr RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest# |
| 75 | err := rrr.Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#Unmarshal().(test.Data) |
| 76 | 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) |
| 77 | if err != nil { |
| 78 | continue |
| 79 | } |
| 80 | 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, rrr, "Unmarshal %q", test.Name) |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | func TestRapidResynchronizationRequestRoundTripscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TestRapidResynchronizationRequestRoundTrip().(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#) { |
| 85 | for _, test := range []struct { |
| 86 | Name string |
| 87 | Report RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest# |
| 88 | WantError error |
| 89 | }{ |
| 90 | { |
| 91 | Name: "valid", |
| 92 | Report: RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#{ |
| 93 | SenderSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#SenderSSRC.: 0x902f9e2e, |
| 94 | MediaSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#MediaSSRC.: 0x902f9e2e, |
| 95 | }, |
| 96 | }, |
| 97 | } { |
| 98 | data, err := test.Report.Marshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest#Marshal().() |
| 99 | 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) |
| 100 | if err != nil { |
| 101 | continue |
| 102 | } |
| 103 | |
| 104 | var decoded RapidResynchronizationRequestscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/RapidResynchronizationRequest# |
| 105 | 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`/RapidResynchronizationRequest#Unmarshal().(data), "Unmarshal %q", test.Name) |
| 106 | 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 round trip", test.Name) |
| 107 | } |
| 108 | } |