| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 312 } |
| 313 DCHECK_NE(new_rate, -1.0); | 313 DCHECK_NE(new_rate, -1.0); |
| 314 | 314 |
| 315 // Then set the rate. | 315 // Then set the rate. |
| 316 capture_loop_->PostTask( | 316 capture_loop_->PostTask( |
| 317 FROM_HERE, | 317 FROM_HERE, |
| 318 NewRunnableMethod(this, &SessionManager::DoSetRate, new_rate)); | 318 NewRunnableMethod(this, &SessionManager::DoSetRate, new_rate)); |
| 319 ScheduleNextRateControl(); | 319 ScheduleNextRateControl(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void SessionManager::DoSendUpdate(ChromotingHostMessage* message, | 322 void SessionManager::DoSendUpdate(HostMessage* message, |
| 323 Encoder::EncodingState state) { | 323 Encoder::EncodingState state) { |
| 324 DCHECK_EQ(network_loop_, MessageLoop::current()); | 324 DCHECK_EQ(network_loop_, MessageLoop::current()); |
| 325 | 325 |
| 326 // Create a data buffer in wire format from |message|. | 326 // Create a data buffer in wire format from |message|. |
| 327 scoped_refptr<media::DataBuffer> data = | 327 scoped_refptr<media::DataBuffer> data = |
| 328 ClientConnection::CreateWireFormatDataBuffer(message); | 328 ClientConnection::CreateWireFormatDataBuffer(message); |
| 329 | 329 |
| 330 for (ClientConnectionList::const_iterator i = clients_.begin(); | 330 for (ClientConnectionList::const_iterator i = clients_.begin(); |
| 331 i < clients_.end(); ++i) { | 331 i < clients_.end(); ++i) { |
| 332 // TODO(hclam): Merge BeginUpdateStreamMessage into |message|. | 332 // TODO(hclam): Merge BeginUpdateStreamMessage into |message|. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 FROM_HERE, NewRunnableMethod(this, &SessionManager::DoFinishEncode)); | 386 FROM_HERE, NewRunnableMethod(this, &SessionManager::DoFinishEncode)); |
| 387 } | 387 } |
| 388 | 388 |
| 389 // TODO(hclam): Enable |force_refresh| if a new client was | 389 // TODO(hclam): Enable |force_refresh| if a new client was |
| 390 // added. | 390 // added. |
| 391 encoder_->Encode(capture_data, false, | 391 encoder_->Encode(capture_data, false, |
| 392 NewCallback(this, &SessionManager::EncodeDataAvailableTask)); | 392 NewCallback(this, &SessionManager::EncodeDataAvailableTask)); |
| 393 } | 393 } |
| 394 | 394 |
| 395 void SessionManager::EncodeDataAvailableTask( | 395 void SessionManager::EncodeDataAvailableTask( |
| 396 ChromotingHostMessage* message, Encoder::EncodingState state) { | 396 HostMessage* message, Encoder::EncodingState state) { |
| 397 DCHECK_EQ(encode_loop_, MessageLoop::current()); | 397 DCHECK_EQ(encode_loop_, MessageLoop::current()); |
| 398 | 398 |
| 399 // Before a new encode task starts, notify clients a new update | 399 // Before a new encode task starts, notify clients a new update |
| 400 // stream is coming. | 400 // stream is coming. |
| 401 // Notify this will keep a reference to the DataBuffer in the | 401 // Notify this will keep a reference to the DataBuffer in the |
| 402 // task. The ownership will eventually pass to the ClientConnections. | 402 // task. The ownership will eventually pass to the ClientConnections. |
| 403 network_loop_->PostTask( | 403 network_loop_->PostTask( |
| 404 FROM_HERE, | 404 FROM_HERE, |
| 405 NewRunnableMethod(this, &SessionManager::DoSendUpdate, message, state)); | 405 NewRunnableMethod(this, &SessionManager::DoSendUpdate, message, state)); |
| 406 | 406 |
| 407 if (state & Encoder::EncodingEnded) { | 407 if (state & Encoder::EncodingEnded) { |
| 408 capture_loop_->PostTask( | 408 capture_loop_->PostTask( |
| 409 FROM_HERE, NewRunnableMethod(this, &SessionManager::DoFinishEncode)); | 409 FROM_HERE, NewRunnableMethod(this, &SessionManager::DoFinishEncode)); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 } // namespace remoting | 413 } // namespace remoting |
| OLD | NEW |