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 |
(...skipping 21 matching lines...) Expand all Loading... |
32 // . . | 32 // . . |
33 // . . | 33 // . . |
34 // . . | 34 // . . |
35 // | inter-arrival jitter | | 35 // | inter-arrival jitter | |
36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 36 // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
37 // | 37 // |
38 // If present, this RTCP packet must be placed after a receiver report | 38 // If present, this RTCP packet must be placed after a receiver report |
39 // (inside a compound RTCP packet), and MUST have the same value for RC | 39 // (inside a compound RTCP packet), and MUST have the same value for RC |
40 // (reception report count) as the receiver report. | 40 // (reception report count) as the receiver report. |
41 | 41 |
| 42 ExtendedJitterReport::ExtendedJitterReport() = default; |
| 43 |
| 44 ExtendedJitterReport::~ExtendedJitterReport() = default; |
| 45 |
42 bool ExtendedJitterReport::Parse(const CommonHeader& packet) { | 46 bool ExtendedJitterReport::Parse(const CommonHeader& packet) { |
43 RTC_DCHECK_EQ(packet.type(), kPacketType); | 47 RTC_DCHECK_EQ(packet.type(), kPacketType); |
44 | 48 |
45 const uint8_t number_of_jitters = packet.count(); | 49 const uint8_t number_of_jitters = packet.count(); |
46 | 50 |
47 if (packet.payload_size_bytes() < number_of_jitters * kJitterSizeBytes) { | 51 if (packet.payload_size_bytes() < number_of_jitters * kJitterSizeBytes) { |
48 LOG(LS_WARNING) << "Packet is too small to contain all the jitter."; | 52 LOG(LS_WARNING) << "Packet is too small to contain all the jitter."; |
49 return false; | 53 return false; |
50 } | 54 } |
51 | 55 |
52 inter_arrival_jitters_.resize(number_of_jitters); | 56 inter_arrival_jitters_.resize(number_of_jitters); |
53 for (size_t index = 0; index < number_of_jitters; ++index) { | 57 for (size_t index = 0; index < number_of_jitters; ++index) { |
54 inter_arrival_jitters_[index] = ByteReader<uint32_t>::ReadBigEndian( | 58 inter_arrival_jitters_[index] = ByteReader<uint32_t>::ReadBigEndian( |
55 &packet.payload()[index * kJitterSizeBytes]); | 59 &packet.payload()[index * kJitterSizeBytes]); |
56 } | 60 } |
57 | 61 |
58 return true; | 62 return true; |
59 } | 63 } |
60 | 64 |
61 bool ExtendedJitterReport::SetJitterValues(std::vector<uint32_t> values) { | 65 bool ExtendedJitterReport::SetJitterValues(std::vector<uint32_t> values) { |
62 if (values.size() > kMaxNumberOfJitterValues) { | 66 if (values.size() > kMaxNumberOfJitterValues) { |
63 LOG(LS_WARNING) << "Too many inter-arrival jitter items."; | 67 LOG(LS_WARNING) << "Too many inter-arrival jitter items."; |
64 return false; | 68 return false; |
65 } | 69 } |
66 inter_arrival_jitters_ = std::move(values); | 70 inter_arrival_jitters_ = std::move(values); |
67 return true; | 71 return true; |
68 } | 72 } |
69 | 73 |
| 74 size_t ExtendedJitterReport::BlockLength() const { |
| 75 return kHeaderLength + kJitterSizeBytes * inter_arrival_jitters_.size(); |
| 76 } |
| 77 |
70 bool ExtendedJitterReport::Create( | 78 bool ExtendedJitterReport::Create( |
71 uint8_t* packet, | 79 uint8_t* packet, |
72 size_t* index, | 80 size_t* index, |
73 size_t max_length, | 81 size_t max_length, |
74 RtcpPacket::PacketReadyCallback* callback) const { | 82 RtcpPacket::PacketReadyCallback* callback) const { |
75 while (*index + BlockLength() > max_length) { | 83 while (*index + BlockLength() > max_length) { |
76 if (!OnBufferFull(packet, index, callback)) | 84 if (!OnBufferFull(packet, index, callback)) |
77 return false; | 85 return false; |
78 } | 86 } |
79 const size_t index_end = *index + BlockLength(); | 87 const size_t index_end = *index + BlockLength(); |
80 size_t length = inter_arrival_jitters_.size(); | 88 size_t length = inter_arrival_jitters_.size(); |
81 CreateHeader(length, kPacketType, length, packet, index); | 89 CreateHeader(length, kPacketType, length, packet, index); |
82 | 90 |
83 for (uint32_t jitter : inter_arrival_jitters_) { | 91 for (uint32_t jitter : inter_arrival_jitters_) { |
84 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, jitter); | 92 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, jitter); |
85 *index += kJitterSizeBytes; | 93 *index += kJitterSizeBytes; |
86 } | 94 } |
87 // Sanity check. | 95 // Sanity check. |
88 RTC_DCHECK_EQ(index_end, *index); | 96 RTC_DCHECK_EQ(index_end, *index); |
89 return true; | 97 return true; |
90 } | 98 } |
91 | 99 |
92 } // namespace rtcp | 100 } // namespace rtcp |
93 } // namespace webrtc | 101 } // namespace webrtc |
OLD | NEW |