| 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 // This is an application of a minimal host process in a Chromoting | 5 // This is an application of a minimal host process in a Chromoting |
| 6 // system. It serves the purpose of gluing different pieces together | 6 // system. It serves the purpose of gluing different pieces together |
| 7 // to make a functional host process for testing. | 7 // to make a functional host process for testing. |
| 8 // | 8 // |
| 9 // It peforms the following functionality: | 9 // It peforms the following functionality: |
| 10 // 1. Connect to the GTalk network and register the machine as a host. | 10 // 1. Connect to the GTalk network and register the machine as a host. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 30 #include "media/base/media.h" | 30 #include "media/base/media.h" |
| 31 #include "remoting/base/tracer.h" | 31 #include "remoting/base/tracer.h" |
| 32 #include "remoting/host/capturer_fake.h" | 32 #include "remoting/host/capturer_fake.h" |
| 33 #include "remoting/host/chromoting_host.h" | 33 #include "remoting/host/chromoting_host.h" |
| 34 #include "remoting/host/chromoting_host_context.h" | 34 #include "remoting/host/chromoting_host_context.h" |
| 35 #include "remoting/host/event_executor.h" | 35 #include "remoting/host/event_executor.h" |
| 36 #include "remoting/host/json_host_config.h" | 36 #include "remoting/host/json_host_config.h" |
| 37 #include "remoting/proto/video.pb.h" | 37 #include "remoting/proto/video.pb.h" |
| 38 | 38 |
| 39 #if defined(TOOLKIT_USES_GTK) |
| 40 #include "ui/gfx/gtk_util.h" |
| 41 #endif |
| 42 |
| 39 using remoting::ChromotingHost; | 43 using remoting::ChromotingHost; |
| 40 using remoting::protocol::CandidateSessionConfig; | 44 using remoting::protocol::CandidateSessionConfig; |
| 41 using remoting::protocol::ChannelConfig; | 45 using remoting::protocol::ChannelConfig; |
| 42 using std::string; | 46 using std::string; |
| 43 using std::wstring; | 47 using std::wstring; |
| 44 | 48 |
| 45 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 46 const wchar_t kDefaultConfigPath[] = L".ChromotingConfig.json"; | 50 const wchar_t kDefaultConfigPath[] = L".ChromotingConfig.json"; |
| 47 const wchar_t kHomeDrive[] = L"HOMEDRIVE"; | 51 const wchar_t kHomeDrive[] = L"HOMEDRIVE"; |
| 48 const wchar_t kHomePath[] = L"HOMEPATH"; | 52 const wchar_t kHomePath[] = L"HOMEPATH"; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 // Needed for the Mac, so we don't leak objects when threads are created. | 75 // Needed for the Mac, so we don't leak objects when threads are created. |
| 72 base::mac::ScopedNSAutoreleasePool pool; | 76 base::mac::ScopedNSAutoreleasePool pool; |
| 73 | 77 |
| 74 CommandLine::Init(argc, argv); | 78 CommandLine::Init(argc, argv); |
| 75 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 79 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 76 | 80 |
| 77 base::AtExitManager exit_manager; | 81 base::AtExitManager exit_manager; |
| 78 base::EnsureNSPRInit(); | 82 base::EnsureNSPRInit(); |
| 79 | 83 |
| 80 // Allocate a chromoting context and starts it. | 84 // Allocate a chromoting context and starts it. |
| 81 remoting::ChromotingHostContext context; | 85 gfx::GtkInitFromCommandLine(*cmd_line); |
| 86 MessageLoopForUI message_loop; |
| 87 remoting::ChromotingHostContext context(&message_loop); |
| 82 context.Start(); | 88 context.Start(); |
| 83 | 89 |
| 84 | 90 |
| 85 #if defined(OS_WIN) | 91 #if defined(OS_WIN) |
| 86 wstring home_path = GetEnvironmentVar(kHomeDrive); | 92 wstring home_path = GetEnvironmentVar(kHomeDrive); |
| 87 home_path += GetEnvironmentVar(kHomePath); | 93 home_path += GetEnvironmentVar(kHomePath); |
| 88 #else | 94 #else |
| 89 string home_path = GetEnvironmentVar(base::env_vars::kHome); | 95 string home_path = GetEnvironmentVar(base::env_vars::kHome); |
| 90 #endif | 96 #endif |
| 91 FilePath config_path(home_path); | 97 FilePath config_path(home_path); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 << "Cannot load media library"; | 119 << "Cannot load media library"; |
| 114 | 120 |
| 115 // Construct a chromoting host. | 121 // Construct a chromoting host. |
| 116 scoped_refptr<ChromotingHost> host; | 122 scoped_refptr<ChromotingHost> host; |
| 117 | 123 |
| 118 bool fake = cmd_line->HasSwitch(kFakeSwitchName); | 124 bool fake = cmd_line->HasSwitch(kFakeSwitchName); |
| 119 if (fake) { | 125 if (fake) { |
| 120 remoting::Capturer* capturer = | 126 remoting::Capturer* capturer = |
| 121 new remoting::CapturerFake(context.main_message_loop()); | 127 new remoting::CapturerFake(context.main_message_loop()); |
| 122 remoting::protocol::InputStub* input_stub = | 128 remoting::protocol::InputStub* input_stub = |
| 123 CreateEventExecutor(context.main_message_loop(), capturer); | 129 CreateEventExecutor(context.ui_message_loop(), capturer); |
| 124 host = ChromotingHost::Create( | 130 host = ChromotingHost::Create( |
| 125 &context, config, capturer, input_stub); | 131 &context, config, capturer, input_stub); |
| 126 } else { | 132 } else { |
| 127 host = ChromotingHost::Create(&context, config); | 133 host = ChromotingHost::Create(&context, config); |
| 128 } | 134 } |
| 129 | 135 |
| 130 if (cmd_line->HasSwitch(kVideoSwitchName)) { | 136 if (cmd_line->HasSwitch(kVideoSwitchName)) { |
| 131 string video_codec = cmd_line->GetSwitchValueASCII(kVideoSwitchName); | 137 string video_codec = cmd_line->GetSwitchValueASCII(kVideoSwitchName); |
| 132 scoped_ptr<CandidateSessionConfig> config( | 138 scoped_ptr<CandidateSessionConfig> config( |
| 133 CandidateSessionConfig::CreateDefault()); | 139 CandidateSessionConfig::CreateDefault()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 148 LOG(ERROR) << "Unknown video codec: " << video_codec; | 154 LOG(ERROR) << "Unknown video codec: " << video_codec; |
| 149 context.Stop(); | 155 context.Stop(); |
| 150 return 1; | 156 return 1; |
| 151 } | 157 } |
| 152 config->mutable_video_configs()->push_back(ChannelConfig( | 158 config->mutable_video_configs()->push_back(ChannelConfig( |
| 153 transport, remoting::protocol::kDefaultStreamVersion, codec)); | 159 transport, remoting::protocol::kDefaultStreamVersion, codec)); |
| 154 host->set_protocol_config(config.release()); | 160 host->set_protocol_config(config.release()); |
| 155 } | 161 } |
| 156 | 162 |
| 157 // Let the chromoting host run until the shutdown task is executed. | 163 // Let the chromoting host run until the shutdown task is executed. |
| 158 MessageLoop message_loop(MessageLoop::TYPE_UI); | |
| 159 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); | 164 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); |
| 160 message_loop.Run(); | 165 message_loop.MessageLoop::Run(); |
| 161 | 166 |
| 162 // And then stop the chromoting context. | 167 // And then stop the chromoting context. |
| 163 context.Stop(); | 168 context.Stop(); |
| 164 file_io_thread.Stop(); | 169 file_io_thread.Stop(); |
| 165 return 0; | 170 return 0; |
| 166 } | 171 } |
| OLD | NEW |