fir.h 1.8 KB

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