fir.h (1832B)
1 /* 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ 12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <vector> 17 18 #include "modules/rtp_rtcp/source/rtcp_packet/psfb.h" 19 20 namespace webrtc { 21 namespace rtcp { 22 class CommonHeader; 23 // Full intra request (FIR) (RFC 5104). 24 class Fir : public Psfb { 25 public: 26 static constexpr uint8_t kFeedbackMessageType = 4; 27 struct Request { 28 Request() : ssrc(0), seq_nr(0) {} 29 Request(uint32_t ssrc, uint8_t seq_nr) : ssrc(ssrc), seq_nr(seq_nr) {} 30 uint32_t ssrc; 31 uint8_t seq_nr; 32 }; 33 34 Fir(); 35 Fir(const Fir& fir); 36 ~Fir() override; 37 38 // Parse assumes header is already parsed and validated. 39 bool Parse(const CommonHeader& packet); 40 41 void AddRequestTo(uint32_t ssrc, uint8_t seq_num) { 42 items_.emplace_back(ssrc, seq_num); 43 } 44 const std::vector<Request>& requests() const { return items_; } 45 46 size_t BlockLength() const override; 47 48 bool Create(uint8_t* packet, 49 size_t* index, 50 size_t max_length, 51 PacketReadyCallback callback) const override; 52 53 private: 54 static constexpr size_t kFciLength = 8; 55 56 // SSRC of media source is not used in FIR packet. Shadow base functions. 57 void SetMediaSsrc(uint32_t ssrc); 58 uint32_t media_ssrc() const; 59 60 std::vector<Request> items_; 61 }; 62 } // namespace rtcp 63 } // namespace webrtc 64 #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_