/* * Copyright (c) 2024 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #include "modules/rtp_rtcp/source/rtcp_packet/congestion_control_feedback.h" #include <cstddef> #include <cstdint> #include <utility> #include <vector> #include "api/array_view.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" #include "modules/rtp_rtcp/source/byte_io.h" #include "rtc_base/network/ecn_marking.h" namespace webrtc { namespace rtcp { /* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |V=2|P| FMT=11 | PT = 205 | length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SSRC of RTCP packet sender | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SSRC of 1st RTP Stream | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | begin_seq | num_reports | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R|ECN| Arrival time offset | ... . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ . . . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SSRC of nth RTP Stream | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | begin_seq | num_reports | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |R|ECN| Arrival time offset | ... | . . . . +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Report Timestamp (32 bits) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ namespace { constexpr size_t kSenderSsrcLength = …; constexpr size_t kHeaderPerMediaSssrcLength = …; constexpr size_t kTimestampLength = …; // RFC-3168, Section 5 constexpr uint16_t kEcnEct1 = …; constexpr uint16_t kEcnEct0 = …; constexpr uint16_t kEcnCe = …; // Arrival time offset (ATO, 13 bits): // The arrival time of the RTP packet at the receiver, as an offset before the // time represented by the Report Timestamp (RTS) field of this RTCP congestion // control feedback report. The ATO field is in units of 1/1024 seconds (this // unit is chosen to give exact offsets from the RTS field) so, for example, an // ATO value of 512 indicates that the corresponding RTP packet arrived exactly // half a second before the time instant represented by the RTS field. If the // measured value is greater than 8189/1024 seconds (the value that would be // coded as 0x1FFD), the value 0x1FFE MUST be reported to indicate an over-range // measurement. If the measurement is unavailable or if the arrival time of the // RTP packet is after the time represented by the RTS field, then an ATO value // of 0x1FFF MUST be reported for the packet. uint16_t To13bitAto(TimeDelta arrival_time_offset) { … } TimeDelta AtoToTimeDelta(uint16_t receive_info) { … } uint16_t To2BitEcn(rtc::EcnMarking ecn_marking) { … } rtc::EcnMarking ToEcnMarking(uint16_t receive_info) { … } } // namespace CongestionControlFeedback ::CongestionControlFeedback( std::vector<PacketInfo> packets, uint32_t compact_ntp_timestamp) : … { … } bool CongestionControlFeedback::Create(uint8_t* buffer, size_t* position, size_t max_length, PacketReadyCallback callback) const { … } size_t CongestionControlFeedback::BlockLength() const { … } bool CongestionControlFeedback::Parse(const rtcp::CommonHeader& packet) { … } } // namespace rtcp } // namespace webrtc