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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 *index += sizeof(uint32_t); | 94 *index += sizeof(uint32_t); |
95 } | 95 } |
96 // Store the reason to leave. | 96 // Store the reason to leave. |
97 if (!reason_.empty()) { | 97 if (!reason_.empty()) { |
98 uint8_t reason_length = reason_.size(); | 98 uint8_t reason_length = reason_.size(); |
99 packet[(*index)++] = reason_length; | 99 packet[(*index)++] = reason_length; |
100 memcpy(&packet[*index], reason_.data(), reason_length); | 100 memcpy(&packet[*index], reason_.data(), reason_length); |
101 *index += reason_length; | 101 *index += reason_length; |
102 // Add padding bytes if needed. | 102 // Add padding bytes if needed. |
103 size_t bytes_to_pad = index_end - *index; | 103 size_t bytes_to_pad = index_end - *index; |
104 RTC_DCHECK_LE(bytes_to_pad, 3u); | 104 RTC_DCHECK_LE(bytes_to_pad, 3); |
105 if (bytes_to_pad > 0) { | 105 if (bytes_to_pad > 0) { |
106 memset(&packet[*index], 0, bytes_to_pad); | 106 memset(&packet[*index], 0, bytes_to_pad); |
107 *index += bytes_to_pad; | 107 *index += bytes_to_pad; |
108 } | 108 } |
109 } | 109 } |
110 RTC_DCHECK_EQ(index_end, *index); | 110 RTC_DCHECK_EQ(index_end, *index); |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 bool Bye::SetCsrcs(std::vector<uint32_t> csrcs) { | 114 bool Bye::SetCsrcs(std::vector<uint32_t> csrcs) { |
(...skipping 11 matching lines...) Expand all Loading... |
126 } | 126 } |
127 | 127 |
128 size_t Bye::BlockLength() const { | 128 size_t Bye::BlockLength() const { |
129 size_t src_count = (1 + csrcs_.size()); | 129 size_t src_count = (1 + csrcs_.size()); |
130 size_t reason_size_in_32bits = reason_.empty() ? 0 : (reason_.size() / 4 + 1); | 130 size_t reason_size_in_32bits = reason_.empty() ? 0 : (reason_.size() / 4 + 1); |
131 return kHeaderLength + 4 * (src_count + reason_size_in_32bits); | 131 return kHeaderLength + 4 * (src_count + reason_size_in_32bits); |
132 } | 132 } |
133 | 133 |
134 } // namespace rtcp | 134 } // namespace rtcp |
135 } // namespace webrtc | 135 } // namespace webrtc |
OLD | NEW |