| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 encoders_.push_back(encoder); | 192 encoders_.push_back(encoder); |
| 193 num_created_encoders_++; | 193 num_created_encoders_++; |
| 194 created_video_encoder_event_.Set(); | 194 created_video_encoder_event_.Set(); |
| 195 return encoder; | 195 return encoder; |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool WaitForCreatedVideoEncoders(int num_encoders) { | 198 bool WaitForCreatedVideoEncoders(int num_encoders) { |
| 199 int64_t start_offset_ms = rtc::TimeMillis(); | 199 int64_t start_offset_ms = rtc::TimeMillis(); |
| 200 int64_t wait_time = kEventTimeoutMs; | 200 int64_t wait_time = kEventTimeoutMs; |
| 201 do { | 201 do { |
| 202 if (GetNumCreatedEncoders() >= num_encoders) | 202 int num_created_encoders = GetNumCreatedEncoders(); |
| 203 if (num_created_encoders == num_encoders) { |
| 203 return true; | 204 return true; |
| 205 } else if (num_created_encoders > num_encoders) { |
| 206 return false; |
| 207 } |
| 204 wait_time = kEventTimeoutMs - (rtc::TimeMillis() - start_offset_ms); | 208 wait_time = kEventTimeoutMs - (rtc::TimeMillis() - start_offset_ms); |
| 205 } while (wait_time > 0 && created_video_encoder_event_.Wait(wait_time)); | 209 } while (wait_time > 0 && created_video_encoder_event_.Wait(wait_time)); |
| 206 return false; | 210 return false; |
| 207 } | 211 } |
| 208 | 212 |
| 209 void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) override { | 213 void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) override { |
| 210 rtc::CritScope lock(&crit_); | 214 rtc::CritScope lock(&crit_); |
| 211 encoders_.erase( | 215 encoders_.erase( |
| 212 std::remove(encoders_.begin(), encoders_.end(), encoder), | 216 std::remove(encoders_.begin(), encoders_.end(), encoder), |
| 213 encoders_.end()); | 217 encoders_.end()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 rtc::Event created_video_encoder_event_; | 258 rtc::Event created_video_encoder_event_; |
| 255 std::vector<cricket::VideoCodec> codecs_; | 259 std::vector<cricket::VideoCodec> codecs_; |
| 256 std::vector<FakeWebRtcVideoEncoder*> encoders_ GUARDED_BY(crit_); | 260 std::vector<FakeWebRtcVideoEncoder*> encoders_ GUARDED_BY(crit_); |
| 257 int num_created_encoders_ GUARDED_BY(crit_); | 261 int num_created_encoders_ GUARDED_BY(crit_); |
| 258 bool encoders_have_internal_sources_; | 262 bool encoders_have_internal_sources_; |
| 259 }; | 263 }; |
| 260 | 264 |
| 261 } // namespace cricket | 265 } // namespace cricket |
| 262 | 266 |
| 263 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVIDEOENGINE_H_ | 267 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVIDEOENGINE_H_ |
| OLD | NEW |