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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } | 209 } |
| 208 } | 210 } |
| 209 | 211 |
| 210 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { | 212 void ChromotingHost::OnSessionChannelsConnected(ClientSession* client) { |
| 211 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 213 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 212 | 214 |
| 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 |
| 219 scoped_ptr<AudioEncoder> audio_encoder = | |
|
Sergey Ulanov
2012/07/31 22:22:17
Move this below, inside the if statement where you
kxing
2012/07/31 23:06:06
Done.
| |
| 220 CreateAudioEncoder(client->connection()->session()->config()); | |
| 221 | |
| 217 recorder_ = new ScreenRecorder(context_->capture_task_runner(), | 222 recorder_ = new ScreenRecorder(context_->capture_task_runner(), |
| 218 context_->encode_task_runner(), | 223 context_->encode_task_runner(), |
| 219 context_->network_task_runner(), | 224 context_->network_task_runner(), |
| 220 desktop_environment_->capturer(), | 225 desktop_environment_->capturer(), |
| 221 encoder); | 226 encoder); |
| 222 if (client->connection()->session()->config().is_audio_enabled()) { | 227 if (client->connection()->session()->config().is_audio_enabled()) { |
| 223 audio_scheduler_ = new AudioScheduler( | 228 audio_scheduler_ = new AudioScheduler( |
| 224 context_->capture_task_runner(), | 229 context_->capture_task_runner(), |
| 225 context_->network_task_runner(), | 230 context_->network_task_runner(), |
| 226 desktop_environment_->audio_capturer(), | 231 desktop_environment_->audio_capturer(), |
| 232 audio_encoder.Pass(), | |
| 227 client->connection()->audio_stub()); | 233 client->connection()->audio_stub()); |
| 228 } | 234 } |
| 229 | 235 |
| 230 // Immediately add the connection and start the session. | 236 // Immediately add the connection and start the session. |
| 231 recorder_->AddConnection(client->connection()); | 237 recorder_->AddConnection(client->connection()); |
| 232 recorder_->Start(); | 238 recorder_->Start(); |
| 233 desktop_environment_->OnSessionStarted(client->CreateClipboardProxy()); | 239 desktop_environment_->OnSessionStarted(client->CreateClipboardProxy()); |
| 234 | 240 |
| 235 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 241 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
| 236 OnClientConnected(client->client_jid())); | 242 OnClientConnected(client->client_jid())); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 return EncoderRowBased::CreateVerbatimEncoder(); | 416 return EncoderRowBased::CreateVerbatimEncoder(); |
| 411 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { | 417 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { |
| 412 return EncoderRowBased::CreateZlibEncoder(); | 418 return EncoderRowBased::CreateZlibEncoder(); |
| 413 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | 419 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
| 414 return new remoting::EncoderVp8(); | 420 return new remoting::EncoderVp8(); |
| 415 } | 421 } |
| 416 | 422 |
| 417 return NULL; | 423 return NULL; |
| 418 } | 424 } |
| 419 | 425 |
| 426 // static | |
| 427 scoped_ptr<AudioEncoder> ChromotingHost::CreateAudioEncoder( | |
| 428 const protocol::SessionConfig& config) { | |
| 429 const protocol::ChannelConfig& audio_config = config.audio_config(); | |
| 430 | |
| 431 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | |
| 432 return AudioEncoderVerbatim::CreateVerbatimAudioEncoder(); | |
| 433 } | |
| 434 | |
| 435 NOTIMPLEMENTED(); | |
| 436 return scoped_ptr<AudioEncoder>(NULL); | |
| 437 } | |
| 438 | |
| 420 void ChromotingHost::StopScreenRecorder() { | 439 void ChromotingHost::StopScreenRecorder() { |
| 421 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); | 440 DCHECK(context_->network_task_runner()->BelongsToCurrentThread()); |
| 422 DCHECK(recorder_.get()); | 441 DCHECK(recorder_.get()); |
| 423 | 442 |
| 424 ++stopping_recorders_; | 443 ++stopping_recorders_; |
| 425 scoped_refptr<ScreenRecorder> recorder = recorder_; | 444 scoped_refptr<ScreenRecorder> recorder = recorder_; |
| 426 recorder_ = NULL; | 445 recorder_ = NULL; |
| 427 recorder->Stop(base::Bind(&ChromotingHost::OnRecorderStopped, this)); | 446 recorder->Stop(base::Bind(&ChromotingHost::OnRecorderStopped, this)); |
| 428 } | 447 } |
| 429 | 448 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 OnShutdown()); | 485 OnShutdown()); |
| 467 | 486 |
| 468 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); | 487 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); |
| 469 it != shutdown_tasks_.end(); ++it) { | 488 it != shutdown_tasks_.end(); ++it) { |
| 470 it->Run(); | 489 it->Run(); |
| 471 } | 490 } |
| 472 shutdown_tasks_.clear(); | 491 shutdown_tasks_.clear(); |
| 473 } | 492 } |
| 474 | 493 |
| 475 } // namespace remoting | 494 } // namespace remoting |
| OLD | NEW |