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 |
(...skipping 25 matching lines...) Expand all Loading... |
36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
37 // 20 | sender's octet count | | 37 // 20 | sender's octet count | |
38 // 24 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 38 // 24 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
39 | 39 |
40 SenderReport::SenderReport() | 40 SenderReport::SenderReport() |
41 : sender_ssrc_(0), | 41 : sender_ssrc_(0), |
42 rtp_timestamp_(0), | 42 rtp_timestamp_(0), |
43 sender_packet_count_(0), | 43 sender_packet_count_(0), |
44 sender_octet_count_(0) {} | 44 sender_octet_count_(0) {} |
45 | 45 |
| 46 SenderReport::~SenderReport() = default; |
| 47 |
46 bool SenderReport::Parse(const CommonHeader& packet) { | 48 bool SenderReport::Parse(const CommonHeader& packet) { |
47 RTC_DCHECK_EQ(packet.type(), kPacketType); | 49 RTC_DCHECK_EQ(packet.type(), kPacketType); |
48 | 50 |
49 const uint8_t report_block_count = packet.count(); | 51 const uint8_t report_block_count = packet.count(); |
50 if (packet.payload_size_bytes() < | 52 if (packet.payload_size_bytes() < |
51 kSenderBaseLength + report_block_count * ReportBlock::kLength) { | 53 kSenderBaseLength + report_block_count * ReportBlock::kLength) { |
52 LOG(LS_WARNING) << "Packet is too small to contain all the data."; | 54 LOG(LS_WARNING) << "Packet is too small to contain all the data."; |
53 return false; | 55 return false; |
54 } | 56 } |
55 // Read SenderReport header. | 57 // Read SenderReport header. |
(...skipping 11 matching lines...) Expand all Loading... |
67 bool block_parsed = block.Parse(next_block, ReportBlock::kLength); | 69 bool block_parsed = block.Parse(next_block, ReportBlock::kLength); |
68 RTC_DCHECK(block_parsed); | 70 RTC_DCHECK(block_parsed); |
69 next_block += ReportBlock::kLength; | 71 next_block += ReportBlock::kLength; |
70 } | 72 } |
71 // Double check we didn't read beyond provided buffer. | 73 // Double check we didn't read beyond provided buffer. |
72 RTC_DCHECK_LE(next_block - payload, | 74 RTC_DCHECK_LE(next_block - payload, |
73 static_cast<ptrdiff_t>(packet.payload_size_bytes())); | 75 static_cast<ptrdiff_t>(packet.payload_size_bytes())); |
74 return true; | 76 return true; |
75 } | 77 } |
76 | 78 |
| 79 size_t SenderReport::BlockLength() const { |
| 80 return kHeaderLength + kSenderBaseLength + |
| 81 report_blocks_.size() * ReportBlock::kLength; |
| 82 } |
| 83 |
77 bool SenderReport::Create(uint8_t* packet, | 84 bool SenderReport::Create(uint8_t* packet, |
78 size_t* index, | 85 size_t* index, |
79 size_t max_length, | 86 size_t max_length, |
80 RtcpPacket::PacketReadyCallback* callback) const { | 87 RtcpPacket::PacketReadyCallback* callback) const { |
81 while (*index + BlockLength() > max_length) { | 88 while (*index + BlockLength() > max_length) { |
82 if (!OnBufferFull(packet, index, callback)) | 89 if (!OnBufferFull(packet, index, callback)) |
83 return false; | 90 return false; |
84 } | 91 } |
85 const size_t index_end = *index + BlockLength(); | 92 const size_t index_end = *index + BlockLength(); |
86 | 93 |
(...skipping 23 matching lines...) Expand all Loading... |
110 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { | 117 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { |
111 LOG(LS_WARNING) << "Max report blocks reached."; | 118 LOG(LS_WARNING) << "Max report blocks reached."; |
112 return false; | 119 return false; |
113 } | 120 } |
114 report_blocks_.push_back(block); | 121 report_blocks_.push_back(block); |
115 return true; | 122 return true; |
116 } | 123 } |
117 | 124 |
118 } // namespace rtcp | 125 } // namespace rtcp |
119 } // namespace webrtc | 126 } // namespace webrtc |
OLD | NEW |