Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.cc

Issue 2010723002: [rtcp] Tmmbn/Tmmbr Parse updated not to use RTCPUtility (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/tmmbn.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.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 Tmmbn::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 Notification (TMMBN) (RFC 5104). 35 // Temporary Maximum Media Stream Bit Rate Notification (TMMBN) (RFC 5104).
36 // The Feedback Control Information (FCI) consists of zero, one, or more 36 // The Feedback Control Information (FCI) consists of zero, one, or more
37 // TMMBN FCI entries. 37 // TMMBN FCI entries.
38 // 0 1 2 3 38 // 0 1 2 3
39 // 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 39 // 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 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 // | SSRC | 41 // | SSRC |
42 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 // | MxTBR Exp | MxTBR Mantissa |Measured Overhead| 43 // | MxTBR Exp | MxTBR Mantissa |Measured Overhead|
44 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 bool Tmmbn::Parse(const RtcpCommonHeader& header, const uint8_t* payload) { 45 bool Tmmbn::Parse(const CommonHeader& packet) {
46 RTC_CHECK(header.packet_type == kPacketType); 46 RTC_DCHECK_EQ(packet.type(), kPacketType);
47 RTC_CHECK(header.count_or_format == kFeedbackMessageType); 47 RTC_DCHECK_EQ(packet.fmt(), kFeedbackMessageType);
48 48
49 if (header.payload_size_bytes < kCommonFeedbackLength) { 49 if (packet.payload_size_bytes() < kCommonFeedbackLength) {
50 LOG(LS_WARNING) << "Payload length " << header.payload_size_bytes 50 LOG(LS_WARNING) << "Payload length " << packet.payload_size_bytes()
51 << " is too small for TMMBN."; 51 << " is too small for TMMBN.";
52 return false; 52 return false;
53 } 53 }
54 size_t items_size_bytes = header.payload_size_bytes - kCommonFeedbackLength; 54 size_t items_size_bytes = packet.payload_size_bytes() - kCommonFeedbackLength;
55 if (items_size_bytes % TmmbItem::kLength != 0) { 55 if (items_size_bytes % TmmbItem::kLength != 0) {
56 LOG(LS_WARNING) << "Payload length " << header.payload_size_bytes 56 LOG(LS_WARNING) << "Payload length " << packet.payload_size_bytes()
57 << " is not valid for TMMBN."; 57 << " is not valid for TMMBN.";
58 return false; 58 return false;
59 } 59 }
60 ParseCommonFeedback(payload); 60 ParseCommonFeedback(packet.payload());
61 const uint8_t* next_item = payload + kCommonFeedbackLength; 61 const uint8_t* next_item = packet.payload() + kCommonFeedbackLength;
62 62
63 size_t number_of_items = items_size_bytes / TmmbItem::kLength; 63 size_t number_of_items = items_size_bytes / TmmbItem::kLength;
64 items_.resize(number_of_items); 64 items_.resize(number_of_items);
65 for (TmmbItem& item : items_) { 65 for (TmmbItem& item : items_) {
66 if (!item.Parse(next_item)) 66 if (!item.Parse(next_item))
67 return false; 67 return false;
68 next_item += TmmbItem::kLength; 68 next_item += TmmbItem::kLength;
69 } 69 }
70 return true; 70 return true;
71 } 71 }
(...skipping 19 matching lines...) Expand all
91 *index += kCommonFeedbackLength; 91 *index += kCommonFeedbackLength;
92 for (const TmmbItem& item : items_) { 92 for (const TmmbItem& item : items_) {
93 item.Create(packet + *index); 93 item.Create(packet + *index);
94 *index += TmmbItem::kLength; 94 *index += TmmbItem::kLength;
95 } 95 }
96 RTC_CHECK_EQ(index_end, *index); 96 RTC_CHECK_EQ(index_end, *index);
97 return true; 97 return true;
98 } 98 }
99 } // namespace rtcp 99 } // namespace rtcp
100 } // namespace webrtc 100 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/tmmbn_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698