| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 EncoderStateFeedback::EncoderStateFeedback() | 49 EncoderStateFeedback::EncoderStateFeedback() |
| 50 : crit_(CriticalSectionWrapper::CreateCriticalSection()), | 50 : crit_(CriticalSectionWrapper::CreateCriticalSection()), |
| 51 observer_(new EncoderStateFeedbackObserver(this)) {} | 51 observer_(new EncoderStateFeedbackObserver(this)) {} |
| 52 | 52 |
| 53 EncoderStateFeedback::~EncoderStateFeedback() { | 53 EncoderStateFeedback::~EncoderStateFeedback() { |
| 54 assert(encoders_.empty()); | 54 assert(encoders_.empty()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void EncoderStateFeedback::UpdateSsrcs(const std::vector<uint32_t>& ssrcs, | 57 void EncoderStateFeedback::AddEncoder(const std::vector<uint32_t>& ssrcs, |
| 58 ViEEncoder* encoder) { | 58 ViEEncoder* encoder) { |
| 59 DCHECK(!ssrcs.empty()); |
| 59 CriticalSectionScoped lock(crit_.get()); | 60 CriticalSectionScoped lock(crit_.get()); |
| 60 SsrcEncoderMap::iterator it = encoders_.begin(); | |
| 61 while (it != encoders_.end()) { | |
| 62 if (it->second == encoder) { | |
| 63 encoders_.erase(it++); | |
| 64 } else { | |
| 65 ++it; | |
| 66 } | |
| 67 } | |
| 68 for (uint32_t ssrc : ssrcs) { | 61 for (uint32_t ssrc : ssrcs) { |
| 69 DCHECK(encoders_.find(ssrc) == encoders_.end()); | 62 DCHECK(encoders_.find(ssrc) == encoders_.end()); |
| 70 encoders_[ssrc] = encoder; | 63 encoders_[ssrc] = encoder; |
| 71 } | 64 } |
| 72 } | 65 } |
| 73 | 66 |
| 74 bool EncoderStateFeedback::AddEncoder(uint32_t ssrc, ViEEncoder* encoder) { | |
| 75 CriticalSectionScoped lock(crit_.get()); | |
| 76 if (encoders_.find(ssrc) != encoders_.end()) { | |
| 77 // Two encoders must not have the same ssrc. | |
| 78 return false; | |
| 79 } | |
| 80 | |
| 81 encoders_[ssrc] = encoder; | |
| 82 return true; | |
| 83 } | |
| 84 | |
| 85 void EncoderStateFeedback::RemoveEncoder(const ViEEncoder* encoder) { | 67 void EncoderStateFeedback::RemoveEncoder(const ViEEncoder* encoder) { |
| 86 CriticalSectionScoped lock(crit_.get()); | 68 CriticalSectionScoped lock(crit_.get()); |
| 87 SsrcEncoderMap::iterator it = encoders_.begin(); | 69 SsrcEncoderMap::iterator it = encoders_.begin(); |
| 88 while (it != encoders_.end()) { | 70 while (it != encoders_.end()) { |
| 89 if (it->second == encoder) { | 71 if (it->second == encoder) { |
| 90 encoders_.erase(it++); | 72 encoders_.erase(it++); |
| 91 } else { | 73 } else { |
| 92 ++it; | 74 ++it; |
| 93 } | 75 } |
| 94 } | 76 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 return; | 115 return; |
| 134 } | 116 } |
| 135 | 117 |
| 136 ViEEncoder* encoder = it->second; | 118 ViEEncoder* encoder = it->second; |
| 137 encoders_.erase(it); | 119 encoders_.erase(it); |
| 138 encoders_[new_ssrc] = encoder; | 120 encoders_[new_ssrc] = encoder; |
| 139 encoder->OnLocalSsrcChanged(old_ssrc, new_ssrc); | 121 encoder->OnLocalSsrcChanged(old_ssrc, new_ssrc); |
| 140 } | 122 } |
| 141 | 123 |
| 142 } // namespace webrtc | 124 } // namespace webrtc |
| OLD | NEW |