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