Debian Codegraph @

reception_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 "encoding/binaryscip-go gomod github.com/golang/go/src go1.24.0 `encoding/binary`/"
7
8 // A ReceptionReport block conveys statistics on the reception of RTP packets
9 // from a single synchronization source.
10 type ReceptionReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport# struct {
11 // The SSRC identifier of the source to which the information in this
12 // reception report block pertains.
13 SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#SSRC. uint32
14 // The fraction of RTP data packets from source SSRC lost since the
15 // previous SR or RR packet was sent, expressed as a fixed point
16 // number with the binary point at the left edge of the field.
17 FractionLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#FractionLost. uint8
18 // The total number of RTP data packets from source SSRC that have
19 // been lost since the beginning of reception.
20 TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost. uint32
21 // The low 16 bits contain the highest sequence number received in an
22 // RTP data packet from source SSRC, and the most significant 16
23 // bits extend that sequence number with the corresponding count of
24 // sequence number cycles.
25 LastSequenceNumberscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSequenceNumber. uint32
26 // An estimate of the statistical variance of the RTP data packet
27 // interarrival time, measured in timestamp units and expressed as an
28 // unsigned integer.
29 Jitterscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Jitter. uint32
30 // The middle 32 bits out of 64 in the NTP timestamp received as part of
31 // the most recent RTCP sender report (SR) packet from source SSRC. If no
32 // SR has been received yet, the field is set to zero.
33 LastSenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSenderReport. uint32
34 // The delay, expressed in units of 1/65536 seconds, between receiving the
35 // last SR packet from source SSRC and sending this reception report block.
36 // If no SR packet has been received yet from SSRC, the field is set to zero.
37 Delayscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Delay. uint32
38 }
39
40 const (
41 receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength. = 24
42 fractionLostOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/fractionLostOffset. = 4
43 totalLostOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/totalLostOffset. = 5
44 lastSeqOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/lastSeqOffset. = 8
45 jitterOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/jitterOffset. = 12
46 lastSROffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/lastSROffset. = 16
47 delayOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/delayOffset. = 20
48 )
49
50 // Marshal encodes the ReceptionReport in binary.
51 func (r ReceptionReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#) Marshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Marshal().() ([]byte, error) {
52 /*
53 * 0 1 2 3
54 * 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
55 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
56 * | SSRC |
57 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 * | fraction lost | cumulative number of packets lost |
59 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
60 * | extended highest sequence number received |
61 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 * | interarrival jitter |
63 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 * | last SR (LSR) |
65 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 * | delay since last SR (DLSR) |
67 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
68 */
69
70 rawPacket := make([]byte, receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength.)
71
72 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().(rawPacket, r.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#SSRC.)
73
74 rawPacket[fractionLostOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/fractionLostOffset.] = r.FractionLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#FractionLost.
75
76 // pack TotalLost into 24 bits
77 if r.TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost. >= (1 << 25) {
78 return nil, errInvalidTotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errInvalidTotalLost.
79 }
80 tlBytes := rawPacket[totalLostOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/totalLostOffset.:]
81 tlBytes[0] = byte(r.TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost. >> 16) //nolint:gosec // rawPacket is created with length receptionReportLength (24)
82 tlBytes[1] = byte(r.TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost. >> 8) //nolint:gosec // rawPacket is created with length receptionReportLength (24)
83 tlBytes[2] = byte(r.TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost.) //nolint:gosec // rawPacket is created with length receptionReportLength (24)
84
85 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().(rawPacket[lastSeqOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/lastSeqOffset.:], r.LastSequenceNumberscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSequenceNumber.)
86 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().(rawPacket[jitterOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/jitterOffset.:], r.Jitterscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Jitter.)
87 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().(rawPacket[lastSROffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/lastSROffset.:], r.LastSenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSenderReport.)
88 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().(rawPacket[delayOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/delayOffset.:], r.Delayscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Delay.)
89
90 return rawPacket, nil
91 }
92
93 // Unmarshal decodes the ReceptionReport from binary.
94 func (r *ReceptionReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#) Unmarshalscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Unmarshal().(rawPacket []byte) error {
95 if len(rawPacket) < receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength. {
96 return errPacketTooShortscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/errPacketTooShort.
97 }
98
99 /*
100 * 0 1 2 3
101 * 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
102 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
103 * | SSRC |
104 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
105 * | fraction lost | cumulative number of packets lost |
106 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
107 * | extended highest sequence number received |
108 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
109 * | interarrival jitter |
110 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
111 * | last SR (LSR) |
112 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
113 * | delay since last SR (DLSR) |
114 * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
115 */
116
117 r.SSRCscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#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().(rawPacket)
118 r.FractionLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#FractionLost. = rawPacket[fractionLostOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/fractionLostOffset.]
119
120 tlBytes := rawPacket[totalLostOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/totalLostOffset.:]
121 r.TotalLostscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#TotalLost. = uint32(tlBytes[2]) | uint32(tlBytes[1])<<8 | uint32(tlBytes[0])<<16
122
123 r.LastSequenceNumberscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSequenceNumber. = 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().(rawPacket[lastSeqOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/lastSeqOffset.:])
124 r.Jitterscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Jitter. = 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().(rawPacket[jitterOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/jitterOffset.:])
125 r.LastSenderReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#LastSenderReport. = 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().(rawPacket[lastSROffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/lastSROffset.:])
126 r.Delayscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#Delay. = 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().(rawPacket[delayOffsetscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/delayOffset.:])
127
128 return nil
129 }
130
131 func (r *ReceptionReportscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#) lenscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/ReceptionReport#len().() int {
132 return receptionReportLengthscip-go gomod github.com/pion/rtcp . `github.com/pion/rtcp`/receptionReportLength.
133 }