blob: 0f1169793d0e1d7d51575ce23a2c46d871d60d5a [file] [log] [blame]
Danil Chapovalov5679da12016-01-15 13:19:53 +01001/*
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.
Danil Chapovalov5679da12016-01-15 13:19:53 +01009 */
10
11#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_
13
Danil Chapovalov32e590e2016-01-22 11:04:56 +010014#include <vector>
15
Danil Chapovalov32e590e2016-01-22 11:04:56 +010016#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020017#include "webrtc/rtc_base/basictypes.h"
Danil Chapovalov5679da12016-01-15 13:19:53 +010018
19namespace webrtc {
20namespace rtcp {
danilchap0fc37d72016-05-31 01:36:37 -070021class CommonHeader;
Danil Chapovalov5679da12016-01-15 13:19:53 +010022// Full intra request (FIR) (RFC 5104).
Danil Chapovalov32e590e2016-01-22 11:04:56 +010023class Fir : public Psfb {
Danil Chapovalov5679da12016-01-15 13:19:53 +010024 public:
danilchap0fc37d72016-05-31 01:36:37 -070025 static constexpr uint8_t kFeedbackMessageType = 4;
Danil Chapovalov32e590e2016-01-22 11:04:56 +010026 struct Request {
27 Request() : ssrc(0), seq_nr(0) {}
28 Request(uint32_t ssrc, uint8_t seq_nr) : ssrc(ssrc), seq_nr(seq_nr) {}
29 uint32_t ssrc;
30 uint8_t seq_nr;
31 };
Danil Chapovalov5679da12016-01-15 13:19:53 +010032
eladalon8fa21c42017-06-16 07:07:47 -070033 Fir();
34 ~Fir() override;
Danil Chapovalov5679da12016-01-15 13:19:53 +010035
Danil Chapovalov32e590e2016-01-22 11:04:56 +010036 // Parse assumes header is already parsed and validated.
danilchap0fc37d72016-05-31 01:36:37 -070037 bool Parse(const CommonHeader& packet);
Danil Chapovalov32e590e2016-01-22 11:04:56 +010038
danilchap822a16f2016-09-27 09:27:47 -070039 void AddRequestTo(uint32_t ssrc, uint8_t seq_num) {
40 items_.emplace_back(ssrc, seq_num);
Danil Chapovalov5679da12016-01-15 13:19:53 +010041 }
Danil Chapovalov32e590e2016-01-22 11:04:56 +010042 const std::vector<Request>& requests() const { return items_; }
Danil Chapovalov5679da12016-01-15 13:19:53 +010043
eladalon8fa21c42017-06-16 07:07:47 -070044 size_t BlockLength() const override;
45
Danil Chapovalov5679da12016-01-15 13:19:53 +010046 bool Create(uint8_t* packet,
47 size_t* index,
48 size_t max_length,
49 RtcpPacket::PacketReadyCallback* callback) const override;
50
51 private:
danilchap0fc37d72016-05-31 01:36:37 -070052 static constexpr size_t kFciLength = 8;
eladalon8fa21c42017-06-16 07:07:47 -070053
Danil Chapovalov32e590e2016-01-22 11:04:56 +010054 // SSRC of media source is not used in FIR packet. Shadow base functions.
danilchap822a16f2016-09-27 09:27:47 -070055 void SetMediaSsrc(uint32_t ssrc);
Danil Chapovalov32e590e2016-01-22 11:04:56 +010056 uint32_t media_ssrc() const;
Danil Chapovalov5679da12016-01-15 13:19:53 +010057
Danil Chapovalov32e590e2016-01-22 11:04:56 +010058 std::vector<Request> items_;
Danil Chapovalov5679da12016-01-15 13:19:53 +010059};
Danil Chapovalov5679da12016-01-15 13:19:53 +010060} // namespace rtcp
61} // namespace webrtc
62#endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_FIR_H_