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/sender_report.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sender_report.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 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 namespace rtcp { | 19 namespace rtcp { |
| 20 constexpr uint8_t SenderReport::kPacketType; |
20 // Sender report (SR) (RFC 3550). | 21 // Sender report (SR) (RFC 3550). |
21 // 0 1 2 3 | 22 // 0 1 2 3 |
22 // 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 | 23 // 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 |
23 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 24 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
24 // |V=2|P| RC | PT=SR=200 | length | | 25 // |V=2|P| RC | PT=SR=200 | length | |
25 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 26 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
26 // 0 | SSRC of sender | | 27 // 0 | SSRC of sender | |
27 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 28 // +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
28 // 4 | NTP timestamp, most significant word | | 29 // 4 | NTP timestamp, most significant word | |
29 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 30 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
30 // 8 | NTP timestamp, least significant word | | 31 // 8 | NTP timestamp, least significant word | |
31 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 32 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
32 // 12 | RTP timestamp | | 33 // 12 | RTP timestamp | |
33 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 34 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
34 // 16 | sender's packet count | | 35 // 16 | sender's packet count | |
35 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
36 // 20 | sender's octet count | | 37 // 20 | sender's octet count | |
37 // 24 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | 38 // 24 +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ |
38 | 39 |
39 SenderReport::SenderReport() | 40 SenderReport::SenderReport() |
40 : sender_ssrc_(0), | 41 : sender_ssrc_(0), |
41 rtp_timestamp_(0), | 42 rtp_timestamp_(0), |
42 sender_packet_count_(0), | 43 sender_packet_count_(0), |
43 sender_octet_count_(0) {} | 44 sender_octet_count_(0) {} |
44 | 45 |
45 bool SenderReport::Parse(const CommonHeader& packet) { | 46 bool SenderReport::Parse(const CommonHeader& packet) { |
46 RTC_DCHECK(packet.type() == kPacketType); | 47 RTC_DCHECK_EQ(packet.type(), kPacketType); |
47 | 48 |
48 const uint8_t report_block_count = packet.count(); | 49 const uint8_t report_block_count = packet.count(); |
49 if (packet.payload_size_bytes() < | 50 if (packet.payload_size_bytes() < |
50 kSenderBaseLength + report_block_count * ReportBlock::kLength) { | 51 kSenderBaseLength + report_block_count * ReportBlock::kLength) { |
51 LOG(LS_WARNING) << "Packet is too small to contain all the data."; | 52 LOG(LS_WARNING) << "Packet is too small to contain all the data."; |
52 return false; | 53 return false; |
53 } | 54 } |
54 // Read SenderReport header. | 55 // Read SenderReport header. |
55 const uint8_t* const payload = packet.payload(); | 56 const uint8_t* const payload = packet.payload(); |
56 sender_ssrc_ = ByteReader<uint32_t>::ReadBigEndian(&payload[0]); | 57 sender_ssrc_ = ByteReader<uint32_t>::ReadBigEndian(&payload[0]); |
(...skipping 52 matching lines...) Loading... |
109 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { | 110 if (report_blocks_.size() >= kMaxNumberOfReportBlocks) { |
110 LOG(LS_WARNING) << "Max report blocks reached."; | 111 LOG(LS_WARNING) << "Max report blocks reached."; |
111 return false; | 112 return false; |
112 } | 113 } |
113 report_blocks_.push_back(block); | 114 report_blocks_.push_back(block); |
114 return true; | 115 return true; |
115 } | 116 } |
116 | 117 |
117 } // namespace rtcp | 118 } // namespace rtcp |
118 } // namespace webrtc | 119 } // namespace webrtc |
OLD | NEW |