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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 size_t* index, | 96 size_t* index, |
97 size_t max_length, | 97 size_t max_length, |
98 RtcpPacket::PacketReadyCallback* callback) const { | 98 RtcpPacket::PacketReadyCallback* callback) const { |
99 while (*index + BlockLength() > max_length) { | 99 while (*index + BlockLength() > max_length) { |
100 if (!OnBufferFull(packet, index, callback)) | 100 if (!OnBufferFull(packet, index, callback)) |
101 return false; | 101 return false; |
102 } | 102 } |
103 size_t index_end = *index + BlockLength(); | 103 size_t index_end = *index + BlockLength(); |
104 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, | 104 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, |
105 index); | 105 index); |
106 RTC_DCHECK_EQ(0u, Psfb::media_ssrc()); | 106 RTC_DCHECK_EQ(0, Psfb::media_ssrc()); |
107 CreateCommonFeedback(packet + *index); | 107 CreateCommonFeedback(packet + *index); |
108 *index += kCommonFeedbackLength; | 108 *index += kCommonFeedbackLength; |
109 | 109 |
110 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, kUniqueIdentifier); | 110 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, kUniqueIdentifier); |
111 *index += sizeof(uint32_t); | 111 *index += sizeof(uint32_t); |
112 const uint32_t kMaxMantissa = 0x3ffff; // 18 bits. | 112 const uint32_t kMaxMantissa = 0x3ffff; // 18 bits. |
113 uint64_t mantissa = bitrate_bps_; | 113 uint64_t mantissa = bitrate_bps_; |
114 uint8_t exponenta = 0; | 114 uint8_t exponenta = 0; |
115 while (mantissa > kMaxMantissa) { | 115 while (mantissa > kMaxMantissa) { |
116 mantissa >>= 1; | 116 mantissa >>= 1; |
117 ++exponenta; | 117 ++exponenta; |
118 } | 118 } |
119 packet[(*index)++] = ssrcs_.size(); | 119 packet[(*index)++] = ssrcs_.size(); |
120 packet[(*index)++] = (exponenta << 2) | (mantissa >> 16); | 120 packet[(*index)++] = (exponenta << 2) | (mantissa >> 16); |
121 ByteWriter<uint16_t>::WriteBigEndian(packet + *index, mantissa & 0xffff); | 121 ByteWriter<uint16_t>::WriteBigEndian(packet + *index, mantissa & 0xffff); |
122 *index += sizeof(uint16_t); | 122 *index += sizeof(uint16_t); |
123 | 123 |
124 for (uint32_t ssrc : ssrcs_) { | 124 for (uint32_t ssrc : ssrcs_) { |
125 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc); | 125 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc); |
126 *index += sizeof(uint32_t); | 126 *index += sizeof(uint32_t); |
127 } | 127 } |
128 RTC_DCHECK_EQ(index_end, *index); | 128 RTC_DCHECK_EQ(index_end, *index); |
129 return true; | 129 return true; |
130 } | 130 } |
131 } // namespace rtcp | 131 } // namespace rtcp |
132 } // namespace webrtc | 132 } // namespace webrtc |
OLD | NEW |