Line data Source code
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 :
16 : #include "webrtc/base/basictypes.h"
17 : #include "webrtc/base/constructormagic.h"
18 : #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h"
19 :
20 : namespace webrtc {
21 : namespace rtcp {
22 : class CommonHeader;
23 :
24 : class Nack : public Rtpfb {
25 : public:
26 : static constexpr uint8_t kFeedbackMessageType = 1;
27 : Nack();
28 : ~Nack() override;
29 :
30 : // Parse assumes header is already parsed and validated.
31 : bool Parse(const CommonHeader& packet);
32 :
33 : void SetPacketIds(const uint16_t* nack_list, size_t length);
34 0 : const std::vector<uint16_t>& packet_ids() const { return packet_ids_; }
35 :
36 : protected:
37 : bool Create(uint8_t* packet,
38 : size_t* index,
39 : size_t max_length,
40 : RtcpPacket::PacketReadyCallback* callback) const override;
41 :
42 : size_t BlockLength() const override;
43 :
44 : private:
45 : static constexpr size_t kNackItemLength = 4;
46 : struct PackedNack {
47 : uint16_t first_pid;
48 : uint16_t bitmask;
49 : };
50 :
51 : void Pack(); // Fills packed_ using packed_ids_. (used in SetPacketIds).
52 : void Unpack(); // Fills packet_ids_ using packed_. (used in Parse).
53 :
54 : std::vector<PackedNack> packed_;
55 : std::vector<uint16_t> packet_ids_;
56 :
57 : RTC_DISALLOW_COPY_AND_ASSIGN(Nack);
58 : };
59 :
60 : } // namespace rtcp
61 : } // namespace webrtc
62 : #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_
|