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 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sli.h" |
12 | 12 |
13 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
16 | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
17 using webrtc::RTCPUtility::RtcpCommonHeader; | |
18 | 17 |
19 namespace webrtc { | 18 namespace webrtc { |
20 namespace rtcp { | 19 namespace rtcp { |
| 20 constexpr uint8_t Sli::kFeedbackMessageType; |
21 // RFC 4585: Feedback format. | 21 // RFC 4585: Feedback format. |
22 // | 22 // |
23 // Common packet format: | 23 // Common packet format: |
24 // | 24 // |
25 // 0 1 2 3 | 25 // 0 1 2 3 |
26 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 26 // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 27 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
28 // |V=2|P| FMT | PT | length | | 28 // |V=2|P| FMT | PT | length | |
29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
30 // | SSRC of packet sender | | 30 // | SSRC of packet sender | |
(...skipping 20 matching lines...) Expand all Loading... |
51 } | 51 } |
52 | 52 |
53 void Sli::Macroblocks::Parse(const uint8_t* buffer) { | 53 void Sli::Macroblocks::Parse(const uint8_t* buffer) { |
54 item_ = ByteReader<uint32_t>::ReadBigEndian(buffer); | 54 item_ = ByteReader<uint32_t>::ReadBigEndian(buffer); |
55 } | 55 } |
56 | 56 |
57 void Sli::Macroblocks::Create(uint8_t* buffer) const { | 57 void Sli::Macroblocks::Create(uint8_t* buffer) const { |
58 ByteWriter<uint32_t>::WriteBigEndian(buffer, item_); | 58 ByteWriter<uint32_t>::WriteBigEndian(buffer, item_); |
59 } | 59 } |
60 | 60 |
61 bool Sli::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { | 61 bool Sli::Parse(const CommonHeader& packet) { |
62 RTC_DCHECK(header.packet_type == kPacketType); | 62 RTC_DCHECK_EQ(packet.type(), kPacketType); |
63 RTC_DCHECK(header.count_or_format == kFeedbackMessageType); | 63 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType); |
64 | 64 |
65 if (header.payload_size_bytes < | 65 if (packet.payload_size_bytes() < |
66 kCommonFeedbackLength + Macroblocks::kLength) { | 66 kCommonFeedbackLength + Macroblocks::kLength) { |
67 LOG(LS_WARNING) << "Packet is too small to be a valid SLI packet"; | 67 LOG(LS_WARNING) << "Packet is too small to be a valid SLI packet"; |
68 return false; | 68 return false; |
69 } | 69 } |
70 | 70 |
71 size_t number_of_items = | 71 size_t number_of_items = |
72 (header.payload_size_bytes - kCommonFeedbackLength) / | 72 (packet.payload_size_bytes() - kCommonFeedbackLength) / |
73 Macroblocks::kLength; | 73 Macroblocks::kLength; |
74 | 74 |
75 ParseCommonFeedback(payload); | 75 ParseCommonFeedback(packet.payload()); |
76 items_.resize(number_of_items); | 76 items_.resize(number_of_items); |
77 | 77 |
78 const uint8_t* next_item = payload + kCommonFeedbackLength; | 78 const uint8_t* next_item = packet.payload() + kCommonFeedbackLength; |
79 for (Macroblocks& item : items_) { | 79 for (Macroblocks& item : items_) { |
80 item.Parse(next_item); | 80 item.Parse(next_item); |
81 next_item += Macroblocks::kLength; | 81 next_item += Macroblocks::kLength; |
82 } | 82 } |
83 | 83 |
84 return true; | 84 return true; |
85 } | 85 } |
86 | 86 |
87 bool Sli::Create(uint8_t* packet, | 87 bool Sli::Create(uint8_t* packet, |
88 size_t* index, | 88 size_t* index, |
(...skipping 10 matching lines...) Expand all Loading... |
99 *index += kCommonFeedbackLength; | 99 *index += kCommonFeedbackLength; |
100 for (const Macroblocks& item : items_) { | 100 for (const Macroblocks& item : items_) { |
101 item.Create(packet + *index); | 101 item.Create(packet + *index); |
102 *index += Macroblocks::kLength; | 102 *index += Macroblocks::kLength; |
103 } | 103 } |
104 return true; | 104 return true; |
105 } | 105 } |
106 | 106 |
107 } // namespace rtcp | 107 } // namespace rtcp |
108 } // namespace webrtc | 108 } // namespace webrtc |
OLD | NEW |