OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 * | 9 * |
10 */ | 10 */ |
11 | |
12 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ |
13 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ |
14 | 13 |
15 #include <vector> | 14 #include <vector> |
16 | 15 |
17 #include "webrtc/base/basictypes.h" | 16 #include "webrtc/base/basictypes.h" |
18 #include "webrtc/base/constructormagic.h" | 17 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/psfb.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | |
21 | 19 |
22 namespace webrtc { | 20 namespace webrtc { |
23 namespace rtcp { | 21 namespace rtcp { |
| 22 class CommonHeader; |
24 | 23 |
25 // Slice loss indication (SLI) (RFC 4585). | 24 // Slice loss indication (SLI) (RFC 4585). |
26 class Sli : public Psfb { | 25 class Sli : public Psfb { |
27 public: | 26 public: |
28 static const uint8_t kFeedbackMessageType = 2; | 27 static constexpr uint8_t kFeedbackMessageType = 2; |
29 class Macroblocks { | 28 class Macroblocks { |
30 public: | 29 public: |
31 static const size_t kLength = 4; | 30 static constexpr size_t kLength = 4; |
32 Macroblocks() : item_(0) {} | 31 Macroblocks() : item_(0) {} |
33 Macroblocks(uint8_t picture_id, uint16_t first, uint16_t number); | 32 Macroblocks(uint8_t picture_id, uint16_t first, uint16_t number); |
34 ~Macroblocks() {} | 33 ~Macroblocks() {} |
35 | 34 |
36 void Parse(const uint8_t* buffer); | 35 void Parse(const uint8_t* buffer); |
37 void Create(uint8_t* buffer) const; | 36 void Create(uint8_t* buffer) const; |
38 | 37 |
39 uint16_t first() const { return item_ >> 19; } | 38 uint16_t first() const { return item_ >> 19; } |
40 uint16_t number() const { return (item_ >> 6) & 0x1fff; } | 39 uint16_t number() const { return (item_ >> 6) & 0x1fff; } |
41 uint8_t picture_id() const { return (item_ & 0x3f); } | 40 uint8_t picture_id() const { return (item_ & 0x3f); } |
42 | 41 |
43 private: | 42 private: |
44 uint32_t item_; | 43 uint32_t item_; |
45 }; | 44 }; |
46 | 45 |
47 Sli() {} | 46 Sli() {} |
48 virtual ~Sli() {} | 47 ~Sli() override {} |
49 | 48 |
50 // Parse assumes header is already parsed and validated. | 49 // Parse assumes header is already parsed and validated. |
51 bool Parse(const RTCPUtility::RtcpCommonHeader& header, | 50 bool Parse(const CommonHeader& packet); |
52 const uint8_t* payload); // Size of the payload is in the header. | |
53 | 51 |
54 void WithPictureId(uint8_t picture_id, | 52 void WithPictureId(uint8_t picture_id, |
55 uint16_t first_macroblock = 0, | 53 uint16_t first_macroblock = 0, |
56 uint16_t number_macroblocks = 0x1fff) { | 54 uint16_t number_macroblocks = 0x1fff) { |
57 items_.push_back( | 55 items_.push_back( |
58 Macroblocks(picture_id, first_macroblock, number_macroblocks)); | 56 Macroblocks(picture_id, first_macroblock, number_macroblocks)); |
59 } | 57 } |
60 | 58 |
61 const std::vector<Macroblocks>& macroblocks() const { return items_; } | 59 const std::vector<Macroblocks>& macroblocks() const { return items_; } |
62 | 60 |
(...skipping 10 matching lines...) Expand all Loading... |
73 } | 71 } |
74 | 72 |
75 std::vector<Macroblocks> items_; | 73 std::vector<Macroblocks> items_; |
76 | 74 |
77 RTC_DISALLOW_COPY_AND_ASSIGN(Sli); | 75 RTC_DISALLOW_COPY_AND_ASSIGN(Sli); |
78 }; | 76 }; |
79 | 77 |
80 } // namespace rtcp | 78 } // namespace rtcp |
81 } // namespace webrtc | 79 } // namespace webrtc |
82 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ | 80 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SLI_H_ |
OLD | NEW |