OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 * | |
10 */ | 9 */ |
11 | 10 |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_ |
14 | 13 |
15 #include <string> | |
16 #include <vector> | 14 #include <vector> |
17 | 15 |
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 16 #include "webrtc/base/basictypes.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rtpfb.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
20 | 19 |
21 namespace webrtc { | 20 namespace webrtc { |
22 namespace rtcp { | 21 namespace rtcp { |
23 | 22 |
24 class Bye : public RtcpPacket { | 23 class Nack : public Rtpfb { |
25 public: | 24 public: |
26 static const uint8_t kPacketType = 203; | 25 const uint8_t kFeedbackMessageType = 1; |
| 26 Nack() {} |
27 | 27 |
28 Bye(); | 28 virtual ~Nack() {} |
29 virtual ~Bye() {} | |
30 | 29 |
31 // Parse assumes header is already parsed and validated. | 30 // Parse assumes header is already parsed and validated. |
32 bool Parse(const RTCPUtility::RtcpCommonHeader& header, | 31 bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
33 const uint8_t* payload); // Size of the payload is in the header. | 32 const uint8_t* payload); // Size of the payload is in the header. |
34 | 33 |
35 void From(uint32_t ssrc) { sender_ssrc_ = ssrc; } | 34 void WithList(const uint16_t* nack_list, size_t length); |
36 bool WithCsrc(uint32_t csrc); | 35 const std::vector<uint16_t>& packet_ids() const { return packet_ids_; } |
37 void WithReason(const std::string& reason); | |
38 | |
39 uint32_t sender_ssrc() const { return sender_ssrc_; } | |
40 const std::vector<uint32_t>& csrcs() const { return csrcs_; } | |
41 const std::string& reason() const { return reason_; } | |
42 | 36 |
43 protected: | 37 protected: |
44 bool Create(uint8_t* packet, | 38 bool Create(uint8_t* packet, |
45 size_t* index, | 39 size_t* index, |
46 size_t max_length, | 40 size_t max_length, |
47 RtcpPacket::PacketReadyCallback* callback) const override; | 41 RtcpPacket::PacketReadyCallback* callback) const override; |
48 | 42 |
49 private: | |
50 static const int kMaxNumberOfCsrcs = 0x1f - 1; // First item is sender SSRC. | |
51 | |
52 size_t BlockLength() const override; | 43 size_t BlockLength() const override; |
53 | 44 |
54 uint32_t sender_ssrc_; | 45 private: |
55 std::vector<uint32_t> csrcs_; | 46 const size_t kNackItemLength = 4; |
56 std::string reason_; | 47 struct PackedNack { |
| 48 uint16_t first_pid; |
| 49 uint16_t bitmask; |
| 50 }; |
57 | 51 |
58 RTC_DISALLOW_COPY_AND_ASSIGN(Bye); | 52 void Pack(); // Fills packed_ using packed_ids_. (used in WithList). |
| 53 void Unpack(); // Fills packet_ids_ using packed_. (used in Parse). |
| 54 |
| 55 std::vector<PackedNack> packed_; |
| 56 std::vector<uint16_t> packet_ids_; |
| 57 |
| 58 RTC_DISALLOW_COPY_AND_ASSIGN(Nack); |
59 }; | 59 }; |
60 | 60 |
61 } // namespace rtcp | 61 } // namespace rtcp |
62 } // namespace webrtc | 62 } // namespace webrtc |
63 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_BYE_H_ | 63 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_NACK_H_ |
OLD | NEW |