danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 11 | #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_ |
| 12 | #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_ |
| 13 | |
| 14 | #include <vector> |
| 15 | |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 16 | #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 17 | #include "webrtc/rtc_base/basictypes.h" |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | namespace rtcp { |
danilchap | 95e7560 | 2016-08-01 06:51:13 -0700 | [diff] [blame] | 21 | class CommonHeader; |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 22 | |
| 23 | class Nack : public Rtpfb { |
| 24 | public: |
danilchap | 95e7560 | 2016-08-01 06:51:13 -0700 | [diff] [blame] | 25 | static constexpr uint8_t kFeedbackMessageType = 1; |
| 26 | Nack(); |
| 27 | ~Nack() override; |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 28 | |
| 29 | // Parse assumes header is already parsed and validated. |
danilchap | 95e7560 | 2016-08-01 06:51:13 -0700 | [diff] [blame] | 30 | bool Parse(const CommonHeader& packet); |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 31 | |
danilchap | 822a16f | 2016-09-27 09:27:47 -0700 | [diff] [blame] | 32 | void SetPacketIds(const uint16_t* nack_list, size_t length); |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 33 | const std::vector<uint16_t>& packet_ids() const { return packet_ids_; } |
| 34 | |
eladalon | 8fa21c4 | 2017-06-16 07:07:47 -0700 | [diff] [blame] | 35 | size_t BlockLength() const override; |
| 36 | |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 37 | bool Create(uint8_t* packet, |
| 38 | size_t* index, |
| 39 | size_t max_length, |
| 40 | RtcpPacket::PacketReadyCallback* callback) const override; |
| 41 | |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 42 | private: |
danilchap | 95e7560 | 2016-08-01 06:51:13 -0700 | [diff] [blame] | 43 | static constexpr size_t kNackItemLength = 4; |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 44 | struct PackedNack { |
| 45 | uint16_t first_pid; |
| 46 | uint16_t bitmask; |
| 47 | }; |
| 48 | |
danilchap | 822a16f | 2016-09-27 09:27:47 -0700 | [diff] [blame] | 49 | void Pack(); // Fills packed_ using packed_ids_. (used in SetPacketIds). |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 50 | void Unpack(); // Fills packet_ids_ using packed_. (used in Parse). |
| 51 | |
| 52 | std::vector<PackedNack> packed_; |
| 53 | std::vector<uint16_t> packet_ids_; |
danilchap | a8890a5 | 2015-12-22 03:43:04 -0800 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | } // namespace rtcp |
| 57 | } // namespace webrtc |
| 58 | #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_ |