OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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/extended_jitter_report.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_jitter_report.h" |
12 | 12 |
13 #include <utility> | |
14 | |
15 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
16 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
19 | 17 |
20 namespace webrtc { | 18 namespace webrtc { |
21 namespace rtcp { | 19 namespace rtcp { |
22 constexpr uint8_t ExtendedJitterReport::kPacketType; | 20 constexpr uint8_t ExtendedJitterReport::kPacketType; |
23 // Transmission Time Offsets in RTP Streams (RFC 5450). | 21 // Transmission Time Offsets in RTP Streams (RFC 5450). |
24 // | 22 // |
(...skipping 26 matching lines...) Expand all Loading... |
51 | 49 |
52 inter_arrival_jitters_.resize(number_of_jitters); | 50 inter_arrival_jitters_.resize(number_of_jitters); |
53 for (size_t index = 0; index < number_of_jitters; ++index) { | 51 for (size_t index = 0; index < number_of_jitters; ++index) { |
54 inter_arrival_jitters_[index] = ByteReader<uint32_t>::ReadBigEndian( | 52 inter_arrival_jitters_[index] = ByteReader<uint32_t>::ReadBigEndian( |
55 &packet.payload()[index * kJitterSizeBytes]); | 53 &packet.payload()[index * kJitterSizeBytes]); |
56 } | 54 } |
57 | 55 |
58 return true; | 56 return true; |
59 } | 57 } |
60 | 58 |
61 bool ExtendedJitterReport::SetJitterValues(std::vector<uint32_t> values) { | 59 bool ExtendedJitterReport::WithJitter(uint32_t jitter) { |
62 if (values.size() > kMaxNumberOfJitterValues) { | 60 if (inter_arrival_jitters_.size() >= kMaxNumberOfJitters) { |
63 LOG(LS_WARNING) << "Too many inter-arrival jitter items."; | 61 LOG(LS_WARNING) << "Max inter-arrival jitter items reached."; |
64 return false; | 62 return false; |
65 } | 63 } |
66 inter_arrival_jitters_ = std::move(values); | 64 inter_arrival_jitters_.push_back(jitter); |
67 return true; | 65 return true; |
68 } | 66 } |
69 | 67 |
70 bool ExtendedJitterReport::Create( | 68 bool ExtendedJitterReport::Create( |
71 uint8_t* packet, | 69 uint8_t* packet, |
72 size_t* index, | 70 size_t* index, |
73 size_t max_length, | 71 size_t max_length, |
74 RtcpPacket::PacketReadyCallback* callback) const { | 72 RtcpPacket::PacketReadyCallback* callback) const { |
75 while (*index + BlockLength() > max_length) { | 73 while (*index + BlockLength() > max_length) { |
76 if (!OnBufferFull(packet, index, callback)) | 74 if (!OnBufferFull(packet, index, callback)) |
77 return false; | 75 return false; |
78 } | 76 } |
79 const size_t index_end = *index + BlockLength(); | 77 const size_t index_end = *index + BlockLength(); |
80 size_t length = inter_arrival_jitters_.size(); | 78 size_t length = inter_arrival_jitters_.size(); |
81 CreateHeader(length, kPacketType, length, packet, index); | 79 CreateHeader(length, kPacketType, length, packet, index); |
82 | 80 |
83 for (uint32_t jitter : inter_arrival_jitters_) { | 81 for (uint32_t jitter : inter_arrival_jitters_) { |
84 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, jitter); | 82 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, jitter); |
85 *index += kJitterSizeBytes; | 83 *index += kJitterSizeBytes; |
86 } | 84 } |
87 // Sanity check. | 85 // Sanity check. |
88 RTC_DCHECK_EQ(index_end, *index); | 86 RTC_DCHECK_EQ(index_end, *index); |
89 return true; | 87 return true; |
90 } | 88 } |
91 | 89 |
92 } // namespace rtcp | 90 } // namespace rtcp |
93 } // namespace webrtc | 91 } // namespace webrtc |
OLD | NEW |