Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "remoting/base/constants.h" | 12 #include "remoting/base/constants.h" |
| 13 #include "remoting/base/encoder.h" | 13 #include "remoting/base/encoder.h" |
| 14 #include "remoting/base/encoder_row_based.h" | 14 #include "remoting/base/encoder_row_based.h" |
| 15 #include "remoting/base/encoder_vp8.h" | 15 #include "remoting/base/encoder_vp8.h" |
| 16 #include "remoting/codec/audio_encoder.h" | |
| 17 #include "remoting/codec/audio_encoder_verbatim.h" | |
| 16 #include "remoting/host/audio_scheduler.h" | 18 #include "remoting/host/audio_scheduler.h" |
| 17 #include "remoting/host/chromoting_host_context.h" | 19 #include "remoting/host/chromoting_host_context.h" |
| 18 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
| 19 #include "remoting/host/event_executor.h" | 21 #include "remoting/host/event_executor.h" |
| 20 #include "remoting/host/host_config.h" | 22 #include "remoting/host/host_config.h" |
| 21 #include "remoting/host/screen_recorder.h" | 23 #include "remoting/host/screen_recorder.h" |
| 22 #include "remoting/protocol/connection_to_client.h" | 24 #include "remoting/protocol/connection_to_client.h" |
| 23 #include "remoting/protocol/client_stub.h" | 25 #include "remoting/protocol/client_stub.h" |
| 24 #include "remoting/protocol/host_stub.h" | 26 #include "remoting/protocol/host_stub.h" |
| 25 #include "remoting/protocol/input_stub.h" | 27 #include "remoting/protocol/input_stub.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 // Then we create a ScreenRecorder passing the message loops that | 215 // Then we create a ScreenRecorder passing the message loops that |
| 214 // it should run on. | 216 // it should run on. |
| 215 Encoder* encoder = CreateEncoder(client->connection()->session()->config()); | 217 Encoder* encoder = CreateEncoder(client->connection()->session()->config()); |
| 216 | 218 |
| 217 recorder_ = new ScreenRecorder(context_->capture_task_runner(), | 219 recorder_ = new ScreenRecorder(context_->capture_task_runner(), |
| 218 context_->encode_task_runner(), | 220 context_->encode_task_runner(), |
| 219 context_->network_task_runner(), | 221 context_->network_task_runner(), |
| 220 desktop_environment_->capturer(), | 222 desktop_environment_->capturer(), |
| 221 encoder); | 223 encoder); |
| 222 if (client->connection()->session()->config().is_audio_enabled()) { | 224 if (client->connection()->session()->config().is_audio_enabled()) { |
| 225 scoped_ptr<AudioEncoder> audio_encoder = | |
| 226 CreateAudioEncoder(client->connection()->session()->config()); | |
| 223 audio_scheduler_ = new AudioScheduler( | 227 audio_scheduler_ = new AudioScheduler( |
| 224 context_->capture_task_runner(), | 228 context_->capture_task_runner(), |
| 225 context_->network_task_runner(), | 229 context_->network_task_runner(), |
| 226 desktop_environment_->audio_capturer(), | 230 desktop_environment_->audio_capturer(), |
| 231 audio_encoder.Pass(), | |
| 227 client->connection()->audio_stub()); | 232 client->connection()->audio_stub()); |
| 228 } | 233 } |
| 229 | 234 |
| 230 // Immediately add the connection and start the session. | 235 // Immediately add the connection and start the session. |
| 231 recorder_->AddConnection(client->connection()); | 236 recorder_->AddConnection(client->connection()); |
| 232 recorder_->Start(); | 237 recorder_->Start(); |
| 233 desktop_environment_->OnSessionStarted(client->CreateClipboardProxy()); | 238 desktop_environment_->OnSessionStarted(client->CreateClipboardProxy()); |
| 234 | 239 |
| 235 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 240 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
| 236 OnClientConnected(client->client_jid())); | 241 OnClientConnected(client->client_jid())); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 return EncoderRowBased::CreateVerbatimEncoder(); | 415 return EncoderRowBased::CreateVerbatimEncoder(); |
| 411 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { | 416 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { |
| 412 return EncoderRowBased::CreateZlibEncoder(); | 417 return EncoderRowBased::CreateZlibEncoder(); |
| 413 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | 418 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
| 414 return new remoting::EncoderVp8(); | 419 return new remoting::EncoderVp8(); |
| 415 } | 420 } |
| 416 | 421 |
| 417 return NULL; | 422 return NULL; |
| 418 } | 423 } |
| 419 | 424 |
| 425 // static | |
| 426 scoped_ptr<AudioEncoder> ChromotingHost::CreateAudioEncoder( | |
| 427 const protocol::SessionConfig& config) { | |
| 428 const protocol::ChannelConfig& audio_config = config.audio_config(); | |
| 429 | |
| 430 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | |
| 431 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); | |
| 432 } | |
| 433 | |
| 434 NOTIMPLEMENTED(); | |
|
Wez
2012/08/07 18:07:41
nit: NOTIMPLEMENTED() is for methods that aren't i
| |
| 435 return scoped_ptr<AudioEncoder>(NULL); | |
| 436 } | |
| 437 | |
| 420 void ChromotingHost::StopScreenRecorder() { | 438 void ChromotingHost::StopScreenRecorder() { |
| 421 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 439 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 422 DCHECK(recorder_.get()); | 440 DCHECK(recorder_.get()); |
| 423 | 441 |
| 424 ++stopping_recorders_; | 442 ++stopping_recorders_; |
| 425 scoped_refptr<ScreenRecorder> recorder = recorder_; | 443 scoped_refptr<ScreenRecorder> recorder = recorder_; |
| 426 recorder_ = NULL; | 444 recorder_ = NULL; |
| 427 recorder->Stop(base::Bind(&ChromotingHost::OnRecorderStopped, this)); | 445 recorder->Stop(base::Bind(&ChromotingHost::OnRecorderStopped, this)); |
| 428 } | 446 } |
| 429 | 447 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 OnShutdown()); | 484 OnShutdown()); |
| 467 | 485 |
| 468 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 486 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 469 it != shutdown_tasks_.end(); ++it) { | 487 it != shutdown_tasks_.end(); ++it) { |
| 470 it->Run(); | 488 it->Run(); |
| 471 } | 489 } |
| 472 shutdown_tasks_.clear(); | 490 shutdown_tasks_.clear(); |
| 473 } | 491 } |
| 474 | 492 |
| 475 } // namespace remoting | 493 } // namespace remoting |
| OLD | NEW |