| 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/bye.h" | 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.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 | 20 |
| 23 // Bye packet (BYE) (RFC 3550). | 21 // Bye packet (BYE) (RFC 3550). |
| 24 // | 22 // |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 RTC_DCHECK_LE(bytes_to_pad, 3u); | 102 RTC_DCHECK_LE(bytes_to_pad, 3u); |
| 105 if (bytes_to_pad > 0) { | 103 if (bytes_to_pad > 0) { |
| 106 memset(&packet[*index], 0, bytes_to_pad); | 104 memset(&packet[*index], 0, bytes_to_pad); |
| 107 *index += bytes_to_pad; | 105 *index += bytes_to_pad; |
| 108 } | 106 } |
| 109 } | 107 } |
| 110 RTC_DCHECK_EQ(index_end, *index); | 108 RTC_DCHECK_EQ(index_end, *index); |
| 111 return true; | 109 return true; |
| 112 } | 110 } |
| 113 | 111 |
| 114 bool Bye::SetCsrcs(std::vector<uint32_t> csrcs) { | 112 bool Bye::WithCsrc(uint32_t csrc) { |
| 115 if (csrcs.size() > kMaxNumberOfCsrcs) { | 113 if (csrcs_.size() >= kMaxNumberOfCsrcs) { |
| 116 LOG(LS_WARNING) << "Too many CSRCs for Bye packet."; | 114 LOG(LS_WARNING) << "Max CSRC size reached."; |
| 117 return false; | 115 return false; |
| 118 } | 116 } |
| 119 csrcs_ = std::move(csrcs); | 117 csrcs_.push_back(csrc); |
| 120 return true; | 118 return true; |
| 121 } | 119 } |
| 122 | 120 |
| 123 void Bye::SetReason(std::string reason) { | 121 void Bye::WithReason(const std::string& reason) { |
| 124 RTC_DCHECK_LE(reason.size(), 0xffu); | 122 RTC_DCHECK_LE(reason.size(), 0xffu); |
| 125 reason_ = std::move(reason); | 123 reason_ = reason; |
| 126 } | 124 } |
| 127 | 125 |
| 128 size_t Bye::BlockLength() const { | 126 size_t Bye::BlockLength() const { |
| 129 size_t src_count = (1 + csrcs_.size()); | 127 size_t src_count = (1 + csrcs_.size()); |
| 130 size_t reason_size_in_32bits = reason_.empty() ? 0 : (reason_.size() / 4 + 1); | 128 size_t reason_size_in_32bits = reason_.empty() ? 0 : (reason_.size() / 4 + 1); |
| 131 return kHeaderLength + 4 * (src_count + reason_size_in_32bits); | 129 return kHeaderLength + 4 * (src_count + reason_size_in_32bits); |
| 132 } | 130 } |
| 133 | 131 |
| 134 } // namespace rtcp | 132 } // namespace rtcp |
| 135 } // namespace webrtc | 133 } // namespace webrtc |
| OLD | NEW |