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/tmmbr.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbr.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 Tmmbr::kFeedbackMessageType; |
21 // RFC 4585: Feedback format. | 21 // RFC 4585: Feedback format. |
22 // Common packet format: | 22 // Common packet format: |
23 // | 23 // |
24 // 0 1 2 3 | 24 // 0 1 2 3 |
25 // 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 | 25 // 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 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 26 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
27 // |V=2|P| FMT | PT | length | | 27 // |V=2|P| FMT | PT | length | |
28 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 28 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
29 // | SSRC of packet sender | | 29 // | SSRC of packet sender | |
30 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 30 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
31 // | SSRC of media source (unused) = 0 | | 31 // | SSRC of media source (unused) = 0 | |
32 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 32 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
33 // : Feedback Control Information (FCI) : | 33 // : Feedback Control Information (FCI) : |
34 // : : | 34 // : : |
35 // Temporary Maximum Media Stream Bit Rate Request (TMMBR) (RFC 5104). | 35 // Temporary Maximum Media Stream Bit Rate Request (TMMBR) (RFC 5104). |
36 // The Feedback Control Information (FCI) for the TMMBR | 36 // The Feedback Control Information (FCI) for the TMMBR |
37 // consists of one or more FCI entries. | 37 // consists of one or more FCI entries. |
38 // FCI: | 38 // FCI: |
39 // 0 1 2 3 | 39 // 0 1 2 3 |
40 // 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 | 40 // 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 |
41 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 41 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
42 // | SSRC | | 42 // | SSRC | |
43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 43 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
44 // | MxTBR Exp | MxTBR Mantissa |Measured Overhead| | 44 // | MxTBR Exp | MxTBR Mantissa |Measured Overhead| |
45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 45 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
46 bool Tmmbr::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { | 46 bool Tmmbr::Parse(const CommonHeader& packet) { |
47 RTC_CHECK(header.packet_type == kPacketType); | 47 RTC_DCHECK_EQ(packet.type(), kPacketType); |
48 RTC_CHECK(header.count_or_format == kFeedbackMessageType); | 48 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType); |
49 | 49 |
50 if (header.payload_size_bytes < kCommonFeedbackLength + TmmbItem::kLength) { | 50 if (packet.payload_size_bytes() < kCommonFeedbackLength + TmmbItem::kLength) { |
51 LOG(LS_WARNING) << "Payload length " << header.payload_size_bytes | 51 LOG(LS_WARNING) << "Payload length " << packet.payload_size_bytes() |
52 << " is too small for a TMMBR."; | 52 << " is too small for a TMMBR."; |
53 return false; | 53 return false; |
54 } | 54 } |
55 size_t items_size_bytes = header.payload_size_bytes - kCommonFeedbackLength; | 55 size_t items_size_bytes = packet.payload_size_bytes() - kCommonFeedbackLength; |
56 if (items_size_bytes % TmmbItem::kLength != 0) { | 56 if (items_size_bytes % TmmbItem::kLength != 0) { |
57 LOG(LS_WARNING) << "Payload length " << header.payload_size_bytes | 57 LOG(LS_WARNING) << "Payload length " << packet.payload_size_bytes() |
58 << " is not valid for a TMMBR."; | 58 << " is not valid for a TMMBR."; |
59 return false; | 59 return false; |
60 } | 60 } |
61 ParseCommonFeedback(payload); | 61 ParseCommonFeedback(packet.payload()); |
62 | 62 |
63 const uint8_t* next_item = payload + kCommonFeedbackLength; | 63 const uint8_t* next_item = packet.payload() + kCommonFeedbackLength; |
64 size_t number_of_items = items_size_bytes / TmmbItem::kLength; | 64 size_t number_of_items = items_size_bytes / TmmbItem::kLength; |
65 items_.resize(number_of_items); | 65 items_.resize(number_of_items); |
66 for (TmmbItem& item : items_) { | 66 for (TmmbItem& item : items_) { |
67 if (!item.Parse(next_item)) | 67 if (!item.Parse(next_item)) |
68 return false; | 68 return false; |
69 next_item += TmmbItem::kLength; | 69 next_item += TmmbItem::kLength; |
70 } | 70 } |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
(...skipping 19 matching lines...) Expand all Loading... |
93 *index += kCommonFeedbackLength; | 93 *index += kCommonFeedbackLength; |
94 for (const TmmbItem& item : items_) { | 94 for (const TmmbItem& item : items_) { |
95 item.Create(packet + *index); | 95 item.Create(packet + *index); |
96 *index += TmmbItem::kLength; | 96 *index += TmmbItem::kLength; |
97 } | 97 } |
98 RTC_CHECK_EQ(index_end, *index); | 98 RTC_CHECK_EQ(index_end, *index); |
99 return true; | 99 return true; |
100 } | 100 } |
101 } // namespace rtcp | 101 } // namespace rtcp |
102 } // namespace webrtc | 102 } // namespace webrtc |
OLD | NEW |