Debian Codegraph @

sender_report.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 "encoding/binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/"
8 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
9 "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/"
10 )
11
12 // A SenderReport (SR) packet provides reception quality feedback for an RTP stream.
13 type SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport# struct {
14 // The synchronization source identifier for the originator of this SR packet.
15 SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#SSRC. uint32
16 // The wallclock time when this report was sent so that it may be used in
17 // combination with timestamps returned in reception reports from other
18 // receivers to measure round-trip propagation to those receivers.
19 NTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#NTPTime. uint64
20 // Corresponds to the same time as the NTP timestamp (above), but in
21 // the same units and with the same random offset as the RTP
22 // timestamps in data packets. This correspondence may be used for
23 // intra- and inter-media synchronization for sources whose NTP
24 // timestamps are synchronized, and may be used by media-independent
25 // receivers to estimate the nominal RTP clock frequency.
26 RTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#RTPTime. uint32
27 // The total number of RTP data packets transmitted by the sender
28 // since starting transmission up until the time this SR packet was
29 // generated.
30 PacketCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#PacketCount. uint32
31 // The total number of payload octets (i.e., not including header or
32 // padding) transmitted in RTP data packets by the sender since
33 // starting transmission up until the time this SR packet was
34 // generated.
35 OctetCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#OctetCount. uint32
36 // Zero or more reception report blocks depending on the number of other
37 // sources heard by this sender since the last report. Each reception report
38 // block conveys statistics on the reception of RTP packets from a
39 // single synchronization source.
40 Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports. []ReceptionReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#
41 // ProfileExtensions contains additional, payload-specific information that needs to
42 // be reported regularly about the sender.
43 ProfileExtensionsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#ProfileExtensions. []byte
44 }
45
46 const (
47 srHeaderLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srHeaderLength. = 24
48 srSSRCOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srSSRCOffset. = 0
49 srNTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srNTPOffset. = srSSRCOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srSSRCOffset. + ssrcLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ssrcLength.
50 ntpTimeLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ntpTimeLength. = 8
51 srRTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srRTPOffset. = srNTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srNTPOffset. + ntpTimeLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ntpTimeLength.
52 rtpTimeLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/rtpTimeLength. = 4
53 srPacketCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srPacketCountOffset. = srRTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srRTPOffset. + rtpTimeLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/rtpTimeLength.
54 srPacketCountLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srPacketCountLength. = 4
55 srOctetCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srOctetCountOffset. = srPacketCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srPacketCountOffset. + srPacketCountLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srPacketCountLength.
56 srOctetCountLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srOctetCountLength. = 4
57 srReportOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srReportOffset. = srOctetCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srOctetCountOffset. + srOctetCountLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srOctetCountLength.
58 )
59
60 // Marshal encodes the SenderReport in binary.
61 func (r SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#) Marshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Marshal().() ([]byte, error) {
62 /*
63 * 0 1 2 3
64 * 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
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 * header |V=2|P| RC | PT=SR=200 | length |
67 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
68 * | SSRC of sender |
69 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
70 * sender | NTP timestamp, most significant word |
71 * info +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 * | NTP timestamp, least significant word |
73 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 * | RTP timestamp |
75 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 * | sender's packet count |
77 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 * | sender's octet count |
79 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
80 * report | SSRC_1 (SSRC of first source) |
81 * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82 * 1 | fraction lost | cumulative number of packets lost |
83 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 * | extended highest sequence number received |
85 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
86 * | interarrival jitter |
87 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88 * | last SR (LSR) |
89 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 * | delay since last SR (DLSR) |
91 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
92 * report | SSRC_2 (SSRC of second source) |
93 * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
94 * 2 : ... :
95 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
96 * | profile-specific extensions |
97 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
98 */
99
100 rawPacket := make([]byte, r.MarshalSizescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#MarshalSize().())
101 packetBody := rawPacket[headerLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/headerLength.:]
102
103 binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..PutUint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#PutUint32().(packetBody[srSSRCOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srSSRCOffset.:], r.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#SSRC.)
104 binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..PutUint64scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#PutUint64().(packetBody[srNTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srNTPOffset.:], r.NTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#NTPTime.)
105 binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..PutUint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#PutUint32().(packetBody[srRTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srRTPOffset.:], r.RTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#RTPTime.)
106 binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..PutUint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#PutUint32().(packetBody[srPacketCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srPacketCountOffset.:], r.PacketCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#PacketCount.)
107 binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..PutUint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#PutUint32().(packetBody[srOctetCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srOctetCountOffset.:], r.OctetCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#OctetCount.)
108
109 offset := srHeaderLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srHeaderLength.
110 for _, rp := range r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports. {
111 data, err := rp.Marshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Marshal().()
112 if err != nil {
113 return nil, err
114 }
115 copy(packetBody[offset:], data)
116 offset += receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength.
117 }
118
119 if len(r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports.) > countMaxscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/countMax. {
120 return nil, errTooManyReportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errTooManyReports.
121 }
122
123 copy(packetBody[offset:], r.ProfileExtensionsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#ProfileExtensions.)
124
125 hData, err := r.Headerscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Header().().Marshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Marshal().()
126 if err != nil {
127 return nil, err
128 }
129 copy(rawPacket, hData)
130
131 return rawPacket, nil
132 }
133
134 // Unmarshal decodes the SenderReport from binary.
135 func (r *SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#) Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Unmarshal().(rawPacket []byte) error {
136 /*
137 * 0 1 2 3
138 * 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
139 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 * header |V=2|P| RC | PT=SR=200 | length |
141 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
142 * | SSRC of sender |
143 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
144 * sender | NTP timestamp, most significant word |
145 * info +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
146 * | NTP timestamp, least significant word |
147 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
148 * | RTP timestamp |
149 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150 * | sender's packet count |
151 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 * | sender's octet count |
153 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
154 * report | SSRC_1 (SSRC of first source) |
155 * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
156 * 1 | fraction lost | cumulative number of packets lost |
157 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
158 * | extended highest sequence number received |
159 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
160 * | interarrival jitter |
161 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
162 * | last SR (LSR) |
163 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
164 * | delay since last SR (DLSR) |
165 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
166 * report | SSRC_2 (SSRC of second source) |
167 * block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
168 * 2 : ... :
169 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
170 * | profile-specific extensions |
171 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
172 */
173
174 if len(rawPacket) < (headerLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/headerLength. + srHeaderLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srHeaderLength.) {
175 return errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort.
176 }
177
178 var header Headerscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#
179 if err := header.Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Unmarshal().(rawPacket); err != nil {
180 return err
181 }
182
183 if header.Typescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Type. != TypeSenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TypeSenderReport. {
184 return errWrongTypescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errWrongType.
185 }
186
187 packetBody := rawPacket[headerLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/headerLength.:]
188
189 r.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#SSRC. = binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..Uint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#Uint32().(packetBody[srSSRCOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srSSRCOffset.:])
190 r.NTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#NTPTime. = binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..Uint64scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#Uint64().(packetBody[srNTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srNTPOffset.:])
191 r.RTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#RTPTime. = binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..Uint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#Uint32().(packetBody[srRTPOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srRTPOffset.:])
192 r.PacketCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#PacketCount. = binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..Uint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#Uint32().(packetBody[srPacketCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srPacketCountOffset.:])
193 r.OctetCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#OctetCount. = binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/.BigEndianscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/BigEndian..Uint32scip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/bigEndian#Uint32().(packetBody[srOctetCountOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srOctetCountOffset.:])
194
195 offset := srReportOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srReportOffset.
196 for i := 0; i < int(header.Countscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Count.); i++ {
197 rrEnd := offset + receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength.
198 if rrEnd > len(packetBody) {
199 return errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort.
200 }
201 rrBody := packetBody[offset : offset+receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength.]
202 offset = rrEnd
203
204 var rr ReceptionReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#
205 if err := rr.Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Unmarshal().(rrBody); err != nil {
206 return err
207 }
208 r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports. = append(r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports., rr)
209 }
210
211 if offset < len(packetBody) {
212 r.ProfileExtensionsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#ProfileExtensions. = packetBody[offset:]
213 }
214
215 if uint8(len(r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports.)) != header.Countscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Count. { //nolint:gosec // G115
216 return errInvalidHeaderscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errInvalidHeader.
217 }
218
219 return nil
220 }
221
222 // DestinationSSRC returns an array of SSRC values that this packet refers to.
223 func (r *SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#) DestinationSSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#DestinationSSRC().() []uint32 {
224 out := make([]uint32, len(r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports.)+1)
225 for i, v := range r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports. {
226 out[i] = v.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#SSRC.
227 }
228 out[len(r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports.)] = r.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#SSRC.
229
230 return out
231 }
232
233 // MarshalSize returns the size of the packet once marshaled.
234 func (r *SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#) MarshalSizescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#MarshalSize().() int {
235 repsLength := 0
236 for _, rep := range r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports. {
237 repsLength += rep.lenscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#len().()
238 }
239
240 return headerLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/headerLength. + srHeaderLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/srHeaderLength. + repsLength + len(r.ProfileExtensionsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#ProfileExtensions.)
241 }
242
243 // Header returns the Header associated with this packet.
244 func (r *SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#) Headerscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Header().() Headerscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header# {
245 return Headerscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#{
246 Countscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Count.: uint8(len(r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports.)), //nolint:gosec // G115
247 Typescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Type.: TypeSenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/TypeSenderReport.,
248 Lengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/Header#Length.: uint16((r.MarshalSizescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#MarshalSize().() / 4) - 1), //nolint:gosec // G115
249 }
250 }
251
252 func (r SenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#) Stringscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#String().() string {
253 var out stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Builderscip-go gomod github.com/golang/go/src go1.24.0 strings/Builder#
254 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "SenderReport from %x\n", r.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#SSRC.)
255 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "\tNTPTime:\t%d\n", r.NTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#NTPTime.)
256 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "\tRTPTIme:\t%d\n", r.RTPTimescip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#RTPTime.)
257 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "\tPacketCount:\t%d\n", r.PacketCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#PacketCount.)
258 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "\tOctetCount:\t%d\n", r.OctetCountscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#OctetCount.)
259
260 out.WriteStringscip-go gomod github.com/golang/go/src go1.24.0 strings/Builder#WriteString().("\tSSRC \tLost\tLastSequence\n")
261 for _, i := range r.Reportsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#Reports. {
262 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "\t%x\t%d/%d\t%d\n", i.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#SSRC., i.FractionLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#FractionLost., i.TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost., i.LastSequenceNumberscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSequenceNumber.)
263 }
264 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Fprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Fprintf().(&out, "\tProfile Extension Data: %v\n", r.ProfileExtensionsscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/SenderReport#ProfileExtensions.)
265
266 return out.Stringscip-go gomod github.com/golang/go/src go1.24.0 strings/Builder#String().()
267 }