Chromium Code Reviews| Index: remoting/host/simple_host_process.cc |
| diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc |
| index 269b76fd9c94fa9d04b9372e484b4c1a002aa805..6ce9bde9d795f1cbd38b231decf5fecf56cc2f5b 100644 |
| --- a/remoting/host/simple_host_process.cc |
| +++ b/remoting/host/simple_host_process.cc |
| @@ -35,13 +35,19 @@ |
| #include "remoting/host/json_host_config.h" |
| #include "remoting/proto/video.pb.h" |
| +using remoting::ChromotingHost; |
| +using remoting::protocol::CandidateSessionConfig; |
| +using remoting::protocol::ChannelConfig; |
| +using std::string; |
| +using std::wstring; |
| + |
| #if defined(OS_WIN) |
| -const std::wstring kDefaultConfigPath = L".ChromotingConfig.json"; |
| +const wchar_t kDefaultConfigPath[] = L".ChromotingConfig.json"; |
| const wchar_t kHomeDrive[] = L"HOMEDRIVE"; |
| const wchar_t kHomePath[] = L"HOMEPATH"; |
| const wchar_t* GetEnvironmentVar(const wchar_t* x) { return _wgetenv(x); } |
| #else |
| -const std::string kDefaultConfigPath = ".ChromotingConfig.json"; |
| +const char kDefaultConfigPath[] = ".ChromotingConfig.json"; |
| static char* GetEnvironmentVar(const char* x) { return getenv(x); } |
|
dmac
2010/11/23 01:14:57
use routines in base/environment.h for dealing wit
Sergey Ulanov
2010/11/23 01:59:18
This can be done in a separate CL. I've added TODO
|
| #endif |
| @@ -49,8 +55,15 @@ void ShutdownTask(MessageLoop* message_loop) { |
| message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| } |
| -const std::string kFakeSwitchName = "fake"; |
| -const std::string kConfigSwitchName = "config"; |
| +const char kFakeSwitchName[] = "fake"; |
|
dmac
2010/11/23 01:14:57
should these switches be in chrome/switches? or pe
Sergey Ulanov
2010/11/23 01:59:18
These options are for simple_host, and they don't
|
| +const char kConfigSwitchName[] = "config"; |
| +const char kVideoSwitchName[] = "video"; |
| + |
| +const char kVideoSwitchValueVerbatim[] = "verbatim"; |
| +const char kVideoSwitchValueZip[] = "zip"; |
| +const char kVideoSwitchValueVp8[] = "vp8"; |
| +const char kVideoSwitchValueVp8Rtp[] = "vp8rtp"; |
| + |
| int main(int argc, char** argv) { |
| // Needed for the Mac, so we don't leak objects when threads are created. |
| @@ -68,10 +81,10 @@ int main(int argc, char** argv) { |
| #if defined(OS_WIN) |
| - std::wstring home_path = GetEnvironmentVar(kHomeDrive); |
| + wstring home_path = GetEnvironmentVar(kHomeDrive); |
| home_path += GetEnvironmentVar(kHomePath); |
| #else |
| - std::string home_path = GetEnvironmentVar(base::env_vars::kHome); |
| + string home_path = GetEnvironmentVar(base::env_vars::kHome); |
| #endif |
| FilePath config_path(home_path); |
| config_path = config_path.Append(kDefaultConfigPath); |
| @@ -98,15 +111,42 @@ int main(int argc, char** argv) { |
| << "Cannot load media library"; |
| // Construct a chromoting host. |
| - scoped_refptr<remoting::ChromotingHost> host; |
| + scoped_refptr<ChromotingHost> host; |
| bool fake = cmd_line->HasSwitch(kFakeSwitchName); |
| if (fake) { |
| - host = new remoting::ChromotingHost( |
| + host = ChromotingHost::Create( |
| &context, config, |
| new remoting::CapturerFake(context.main_message_loop())); |
| } else { |
| - host = new remoting::ChromotingHost(&context, config); |
| + host = ChromotingHost::Create(&context, config); |
| + } |
| + |
| + if (cmd_line->HasSwitch(kVideoSwitchName)) { |
| + string video_codec = cmd_line->GetSwitchValueASCII(kVideoSwitchName); |
| + scoped_ptr<CandidateSessionConfig> config( |
| + CandidateSessionConfig::CreateDefault()); |
| + config->mutable_video_configs()->clear(); |
| + |
| + ChannelConfig::TransportType transport = ChannelConfig::TRANSPORT_STREAM; |
| + ChannelConfig::Codec codec; |
| + if (video_codec == kVideoSwitchValueVerbatim) { |
| + codec = ChannelConfig::CODEC_VERBATIM; |
| + } else if (video_codec == kVideoSwitchValueZip) { |
| + codec = ChannelConfig::CODEC_ZIP; |
| + } else if (video_codec == kVideoSwitchValueVp8) { |
| + codec = ChannelConfig::CODEC_VP8; |
| + } else if (video_codec == kVideoSwitchValueVp8Rtp) { |
| + transport = ChannelConfig::TRANSPORT_SRTP; |
| + codec = ChannelConfig::CODEC_VP8; |
| + } else { |
| + LOG(ERROR) << "Unknown video codec: " << video_codec; |
| + context.Stop(); |
| + return 1; |
| + } |
| + config->mutable_video_configs()->push_back(ChannelConfig( |
| + transport, remoting::protocol::kDefaultStreamVersion, codec)); |
| + host->set_protocol_config(config.release()); |
| } |
| // Let the chromoting host run until the shutdown task is executed. |