| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/host/session_manager.h" | 5 #include "remoting/host/session_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 MessageLoop* encode_loop, | 37 MessageLoop* encode_loop, |
| 38 MessageLoop* network_loop, | 38 MessageLoop* network_loop, |
| 39 Capturer* capturer, | 39 Capturer* capturer, |
| 40 Encoder* encoder) | 40 Encoder* encoder) |
| 41 : capture_loop_(capture_loop), | 41 : capture_loop_(capture_loop), |
| 42 encode_loop_(encode_loop), | 42 encode_loop_(encode_loop), |
| 43 network_loop_(network_loop), | 43 network_loop_(network_loop), |
| 44 capturer_(capturer), | 44 capturer_(capturer), |
| 45 encoder_(encoder), | 45 encoder_(encoder), |
| 46 rate_(kDefaultCaptureRate), | 46 rate_(kDefaultCaptureRate), |
| 47 max_rate_(kDefaultCaptureRate), | |
| 48 started_(false), | 47 started_(false), |
| 49 recordings_(0), | 48 recordings_(0), |
| 49 max_rate_(kDefaultCaptureRate), |
| 50 rate_control_started_(false) { | 50 rate_control_started_(false) { |
| 51 DCHECK(capture_loop_); | 51 DCHECK(capture_loop_); |
| 52 DCHECK(encode_loop_); | 52 DCHECK(encode_loop_); |
| 53 DCHECK(network_loop_); | 53 DCHECK(network_loop_); |
| 54 } | 54 } |
| 55 | 55 |
| 56 SessionManager::~SessionManager() { | 56 SessionManager::~SessionManager() { |
| 57 clients_.clear(); | 57 clients_.clear(); |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 return; | 301 return; |
| 302 | 302 |
| 303 int max_pending_update_streams = 0; | 303 int max_pending_update_streams = 0; |
| 304 for (size_t i = 0; i < clients_.size(); ++i) { | 304 for (size_t i = 0; i < clients_.size(); ++i) { |
| 305 max_pending_update_streams = | 305 max_pending_update_streams = |
| 306 std::max(max_pending_update_streams, | 306 std::max(max_pending_update_streams, |
| 307 clients_[i]->GetPendingUpdateStreamMessages()); | 307 clients_[i]->GetPendingUpdateStreamMessages()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 // If |slow_down| equals zero, we have no slow down. | 310 // If |slow_down| equals zero, we have no slow down. |
| 311 int slow_down = max_pending_update_streams / kSlowDownFactor; | 311 size_t slow_down = max_pending_update_streams / kSlowDownFactor; |
| 312 // Set new_rate to -1 for checking later. | 312 // Set new_rate to -1 for checking later. |
| 313 double new_rate = -1; | 313 double new_rate = -1; |
| 314 // If the slow down is too large. | 314 // If the slow down is too large. |
| 315 if (slow_down >= arraysize(kRateDividers)) { | 315 if (slow_down >= arraysize(kRateDividers)) { |
| 316 // Then we stop the capture completely. | 316 // Then we stop the capture completely. |
| 317 new_rate = 0; | 317 new_rate = 0; |
| 318 } else { | 318 } else { |
| 319 // Slow down the capture rate using the divider. | 319 // Slow down the capture rate using the divider. |
| 320 new_rate = max_rate_ / kRateDividers[slow_down]; | 320 new_rate = max_rate_ / kRateDividers[slow_down]; |
| 321 } | 321 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 data, | 385 data, |
| 386 state)); | 386 state)); |
| 387 | 387 |
| 388 if (state == Encoder::EncodingEnded) { | 388 if (state == Encoder::EncodingEnded) { |
| 389 capture_loop_->PostTask( | 389 capture_loop_->PostTask( |
| 390 FROM_HERE, NewRunnableMethod(this, &SessionManager::DoFinishEncode)); | 390 FROM_HERE, NewRunnableMethod(this, &SessionManager::DoFinishEncode)); |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 | 393 |
| 394 } // namespace remoting | 394 } // namespace remoting |
| OLD | NEW |