blob: 3f6330d717c5d9870a86d3e37b9ac6844ca07113 [file] [log] [blame]
danilchapa8890a52015-12-22 03:43:04 -08001/*
2 * Copyright (c) 2015 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_
12#define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_
danilchapa8890a52015-12-22 03:43:04 -080013
14#include <vector>
15
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020016#include "modules/rtp_rtcp/source/rtcp_packet/rtpfb.h"
17#include "rtc_base/basictypes.h"
danilchapa8890a52015-12-22 03:43:04 -080018
19namespace webrtc {
20namespace rtcp {
danilchap95e75602016-08-01 06:51:13 -070021class CommonHeader;
danilchapa8890a52015-12-22 03:43:04 -080022
23class Nack : public Rtpfb {
24 public:
danilchap95e75602016-08-01 06:51:13 -070025 static constexpr uint8_t kFeedbackMessageType = 1;
26 Nack();
27 ~Nack() override;
danilchapa8890a52015-12-22 03:43:04 -080028
29 // Parse assumes header is already parsed and validated.
danilchap95e75602016-08-01 06:51:13 -070030 bool Parse(const CommonHeader& packet);
danilchapa8890a52015-12-22 03:43:04 -080031
danilchap822a16f2016-09-27 09:27:47 -070032 void SetPacketIds(const uint16_t* nack_list, size_t length);
danilchapa8890a52015-12-22 03:43:04 -080033 const std::vector<uint16_t>& packet_ids() const { return packet_ids_; }
34
eladalon8fa21c42017-06-16 07:07:47 -070035 size_t BlockLength() const override;
36
danilchapa8890a52015-12-22 03:43:04 -080037 bool Create(uint8_t* packet,
38 size_t* index,
39 size_t max_length,
40 RtcpPacket::PacketReadyCallback* callback) const override;
41
danilchapa8890a52015-12-22 03:43:04 -080042 private:
danilchap95e75602016-08-01 06:51:13 -070043 static constexpr size_t kNackItemLength = 4;
danilchapa8890a52015-12-22 03:43:04 -080044 struct PackedNack {
45 uint16_t first_pid;
46 uint16_t bitmask;
47 };
48
danilchap822a16f2016-09-27 09:27:47 -070049 void Pack(); // Fills packed_ using packed_ids_. (used in SetPacketIds).
danilchapa8890a52015-12-22 03:43:04 -080050 void Unpack(); // Fills packet_ids_ using packed_. (used in Parse).
51
52 std::vector<PackedNack> packed_;
53 std::vector<uint16_t> packet_ids_;
danilchapa8890a52015-12-22 03:43:04 -080054};
55
56} // namespace rtcp
57} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020058#endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_