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 <vector>
15 
16 #include "modules/rtp_rtcp/source/rtcp_packet/psfb.h"
17 
18 namespace webrtc {
19 namespace rtcp {
20 class CommonHeader;
21 // Full intra request (FIR) (RFC 5104).
22 class Fir : public Psfb {
23  public:
24   static constexpr uint8_t kFeedbackMessageType = 4;
25   struct Request {
RequestRequest26     Request() : ssrc(0), seq_nr(0) {}
RequestRequest27     Request(uint32_t ssrc, uint8_t seq_nr) : ssrc(ssrc), seq_nr(seq_nr) {}
28     uint32_t ssrc;
29     uint8_t seq_nr;
30   };
31 
32   Fir();
33   Fir(const Fir& fir);
34   ~Fir() override;
35 
36   // Parse assumes header is already parsed and validated.
37   bool Parse(const CommonHeader& packet);
38 
AddRequestTo(uint32_t ssrc,uint8_t seq_num)39   void AddRequestTo(uint32_t ssrc, uint8_t seq_num) {
40     items_.emplace_back(ssrc, seq_num);
41   }
requests()42   const std::vector<Request>& requests() const { return items_; }
43 
44   size_t BlockLength() const override;
45 
46   bool Create(uint8_t* packet,
47               size_t* index,
48               size_t max_length,
49               PacketReadyCallback callback) const override;
50 
51  private:
52   static constexpr size_t kFciLength = 8;
53 
54   // SSRC of media source is not used in FIR packet. Shadow base functions.
55   void SetMediaSsrc(uint32_t ssrc);
56   uint32_t media_ssrc() const;
57 
58   std::vector<Request> items_;
59 };
60 }  // namespace rtcp
61 }  // namespace webrtc
62 #endif  // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_
63