| 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 |
| 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.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 // Source Description (SDES) (RFC 3550). | 20 // Source Description (SDES) (RFC 3550). |
| 23 // | 21 // |
| 24 // 0 1 2 3 | 22 // 0 1 2 3 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 130 } |
| 133 // Adjust to 32bit boundary. | 131 // Adjust to 32bit boundary. |
| 134 looking_at += (payload_end - looking_at) % 4; | 132 looking_at += (payload_end - looking_at) % 4; |
| 135 } | 133 } |
| 136 | 134 |
| 137 chunks_ = std::move(chunks); | 135 chunks_ = std::move(chunks); |
| 138 block_length_ = block_length; | 136 block_length_ = block_length; |
| 139 return true; | 137 return true; |
| 140 } | 138 } |
| 141 | 139 |
| 142 bool Sdes::AddCName(uint32_t ssrc, std::string cname) { | 140 bool Sdes::WithCName(uint32_t ssrc, const std::string& cname) { |
| 143 RTC_DCHECK_LE(cname.length(), 0xffu); | 141 RTC_DCHECK_LE(cname.length(), 0xffu); |
| 144 if (chunks_.size() >= kMaxNumberOfChunks) { | 142 if (chunks_.size() >= kMaxNumberOfChunks) { |
| 145 LOG(LS_WARNING) << "Max SDES chunks reached."; | 143 LOG(LS_WARNING) << "Max SDES chunks reached."; |
| 146 return false; | 144 return false; |
| 147 } | 145 } |
| 148 Chunk chunk; | 146 Chunk chunk; |
| 149 chunk.ssrc = ssrc; | 147 chunk.ssrc = ssrc; |
| 150 chunk.cname = std::move(cname); | 148 chunk.cname = cname; |
| 151 chunks_.push_back(chunk); | 149 chunks_.push_back(chunk); |
| 152 block_length_ += ChunkSize(chunk); | 150 block_length_ += ChunkSize(chunk); |
| 153 return true; | 151 return true; |
| 154 } | 152 } |
| 155 | 153 |
| 156 bool Sdes::Create(uint8_t* packet, | 154 bool Sdes::Create(uint8_t* packet, |
| 157 size_t* index, | 155 size_t* index, |
| 158 size_t max_length, | 156 size_t max_length, |
| 159 RtcpPacket::PacketReadyCallback* callback) const { | 157 RtcpPacket::PacketReadyCallback* callback) const { |
| 160 while (*index + BlockLength() > max_length) { | 158 while (*index + BlockLength() > max_length) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 179 const int kPadding = 0; | 177 const int kPadding = 0; |
| 180 memset(packet + *index, kPadding, padding_size); | 178 memset(packet + *index, kPadding, padding_size); |
| 181 *index += padding_size; | 179 *index += padding_size; |
| 182 } | 180 } |
| 183 | 181 |
| 184 RTC_CHECK_EQ(*index, index_end); | 182 RTC_CHECK_EQ(*index, index_end); |
| 185 return true; | 183 return true; |
| 186 } | 184 } |
| 187 } // namespace rtcp | 185 } // namespace rtcp |
| 188 } // namespace webrtc | 186 } // namespace webrtc |
| OLD | NEW |