Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: remoting/host/simple_host_process.cc

Issue 4229003: Add VideoReader and VideoWriter interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/mock_objects.h ('k') | remoting/proto/video.proto » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 #include "base/at_exit.h" 21 #include "base/at_exit.h"
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "base/environment.h" 23 #include "base/environment.h"
24 #include "base/file_path.h" 24 #include "base/file_path.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/mac/scoped_nsautorelease_pool.h" 26 #include "base/mac/scoped_nsautorelease_pool.h"
27 #include "base/nss_util.h" 27 #include "base/nss_util.h"
28 #include "base/path_service.h" 28 #include "base/path_service.h"
29 #include "base/thread.h" 29 #include "base/thread.h"
30 #include "media/base/media.h" 30 #include "media/base/media.h"
31 #include "remoting/base/encoder_verbatim.h"
32 #include "remoting/base/encoder_vp8.h"
33 #include "remoting/base/encoder_zlib.h"
34 #include "remoting/base/tracer.h" 31 #include "remoting/base/tracer.h"
35 #include "remoting/host/capturer_fake.h" 32 #include "remoting/host/capturer_fake.h"
36 #include "remoting/host/chromoting_host.h" 33 #include "remoting/host/chromoting_host.h"
37 #include "remoting/host/chromoting_host_context.h" 34 #include "remoting/host/chromoting_host_context.h"
38 #include "remoting/host/json_host_config.h" 35 #include "remoting/host/json_host_config.h"
39 #include "remoting/proto/video.pb.h" 36 #include "remoting/proto/video.pb.h"
40 37
41 #if defined(OS_WIN) 38 #if defined(OS_WIN)
42 #include "remoting/host/capturer_gdi.h" 39 #include "remoting/host/capturer_gdi.h"
43 #include "remoting/host/event_executor_win.h" 40 #include "remoting/host/event_executor_win.h"
(...skipping 14 matching lines...) Expand all
58 const std::string kDefaultConfigPath = ".ChromotingConfig.json"; 55 const std::string kDefaultConfigPath = ".ChromotingConfig.json";
59 static char* GetEnvironmentVar(const char* x) { return getenv(x); } 56 static char* GetEnvironmentVar(const char* x) { return getenv(x); }
60 #endif 57 #endif
61 58
62 void ShutdownTask(MessageLoop* message_loop) { 59 void ShutdownTask(MessageLoop* message_loop) {
63 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 60 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
64 } 61 }
65 62
66 const std::string kFakeSwitchName = "fake"; 63 const std::string kFakeSwitchName = "fake";
67 const std::string kConfigSwitchName = "config"; 64 const std::string kConfigSwitchName = "config";
68 const std::string kVerbatimSwitchName = "verbatim";
69 const std::string kVp8SwitchName = "vp8";
70 65
71 int main(int argc, char** argv) { 66 int main(int argc, char** argv) {
72 // Needed for the Mac, so we don't leak objects when threads are created. 67 // Needed for the Mac, so we don't leak objects when threads are created.
73 base::mac::ScopedNSAutoreleasePool pool; 68 base::mac::ScopedNSAutoreleasePool pool;
74 69
75 CommandLine::Init(argc, argv); 70 CommandLine::Init(argc, argv);
76 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 71 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
77 72
78 base::AtExitManager exit_manager; 73 base::AtExitManager exit_manager;
79 74
80 base::EnsureNSPRInit(); 75 base::EnsureNSPRInit();
81 76
82 scoped_ptr<remoting::Capturer> capturer; 77 scoped_ptr<remoting::Capturer> capturer;
83 scoped_ptr<remoting::Encoder> encoder;
84 scoped_ptr<remoting::EventExecutor> event_handler; 78 scoped_ptr<remoting::EventExecutor> event_handler;
85 #if defined(OS_WIN) 79 #if defined(OS_WIN)
86 capturer.reset(new remoting::CapturerGdi()); 80 capturer.reset(new remoting::CapturerGdi());
87 event_handler.reset(new remoting::EventExecutorWin(capturer.get())); 81 event_handler.reset(new remoting::EventExecutorWin(capturer.get()));
88 #elif defined(OS_LINUX) 82 #elif defined(OS_LINUX)
89 capturer.reset(new remoting::CapturerLinux()); 83 capturer.reset(new remoting::CapturerLinux());
90 event_handler.reset(new remoting::EventExecutorLinux(capturer.get())); 84 event_handler.reset(new remoting::EventExecutorLinux(capturer.get()));
91 #elif defined(OS_MACOSX) 85 #elif defined(OS_MACOSX)
92 capturer.reset(new remoting::CapturerMac()); 86 capturer.reset(new remoting::CapturerMac());
93 event_handler.reset(new remoting::EventExecutorMac(capturer.get())); 87 event_handler.reset(new remoting::EventExecutorMac(capturer.get()));
94 #endif 88 #endif
95 encoder.reset(new remoting::EncoderZlib());
96 89
97 // Check the argument to see if we should use a fake capturer and encoder. 90 // Check the argument to see if we should use a fake capturer.
98 bool fake = cmd_line->HasSwitch(kFakeSwitchName); 91 bool fake = cmd_line->HasSwitch(kFakeSwitchName);
99 bool verbatim = cmd_line->HasSwitch(kVerbatimSwitchName);
100 bool vp8 = cmd_line->HasSwitch(kVp8SwitchName);
101 92
102 #if defined(OS_WIN) 93 #if defined(OS_WIN)
103 std::wstring home_path = GetEnvironmentVar(kHomeDrive); 94 std::wstring home_path = GetEnvironmentVar(kHomeDrive);
104 home_path += GetEnvironmentVar(kHomePath); 95 home_path += GetEnvironmentVar(kHomePath);
105 #else 96 #else
106 std::string home_path = GetEnvironmentVar(base::env_vars::kHome); 97 std::string home_path = GetEnvironmentVar(base::env_vars::kHome);
107 #endif 98 #endif
108 FilePath config_path(home_path); 99 FilePath config_path(home_path);
109 config_path = config_path.Append(kDefaultConfigPath); 100 config_path = config_path.Append(kDefaultConfigPath);
110 if (cmd_line->HasSwitch(kConfigSwitchName)) { 101 if (cmd_line->HasSwitch(kConfigSwitchName)) {
111 config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName); 102 config_path = cmd_line->GetSwitchValuePath(kConfigSwitchName);
112 } 103 }
113 104
114 if (fake) { 105 if (fake) {
115 // Inject a fake capturer. 106 // Inject a fake capturer.
116 LOG(INFO) << "Using a fake capturer."; 107 LOG(INFO) << "Using a fake capturer.";
117 capturer.reset(new remoting::CapturerFake()); 108 capturer.reset(new remoting::CapturerFake());
118 } 109 }
119 110
120 if (verbatim) {
121 LOG(INFO) << "Using the verbatim encoder.";
122 encoder.reset(new remoting::EncoderVerbatim());
123 }
124
125 // TODO(sergeyu): Enable VP8 on ARM builds.
126 #if !defined(ARCH_CPU_ARM_FAMILY)
127 if (vp8) {
128 LOG(INFO) << "Using the verbatim encoder.";
129 encoder.reset(new remoting::EncoderVp8());
130 }
131 #endif
132
133 base::Thread file_io_thread("FileIO"); 111 base::Thread file_io_thread("FileIO");
134 file_io_thread.Start(); 112 file_io_thread.Start();
135 113
136 scoped_refptr<remoting::JsonHostConfig> config( 114 scoped_refptr<remoting::JsonHostConfig> config(
137 new remoting::JsonHostConfig( 115 new remoting::JsonHostConfig(
138 config_path, file_io_thread.message_loop_proxy())); 116 config_path, file_io_thread.message_loop_proxy()));
139 117
140 if (!config->Read()) { 118 if (!config->Read()) {
141 LOG(ERROR) << "Failed to read configuration file " << config_path.value(); 119 LOG(ERROR) << "Failed to read configuration file " << config_path.value();
142 return 1; 120 return 1;
143 } 121 }
144 122
145 // Allocate a chromoting context and starts it. 123 // Allocate a chromoting context and starts it.
146 remoting::ChromotingHostContext context; 124 remoting::ChromotingHostContext context;
147 context.Start(); 125 context.Start();
148 126
149 FilePath module_path; 127 FilePath module_path;
150 PathService::Get(base::DIR_MODULE, &module_path); 128 PathService::Get(base::DIR_MODULE, &module_path);
151 CHECK(media::InitializeMediaLibrary(module_path)) 129 CHECK(media::InitializeMediaLibrary(module_path))
152 << "Cannot load media library"; 130 << "Cannot load media library";
153 131
154 // Construct a chromoting host. 132 // Construct a chromoting host.
155 scoped_refptr<remoting::ChromotingHost> host( 133 scoped_refptr<remoting::ChromotingHost> host(
156 new remoting::ChromotingHost(&context, 134 new remoting::ChromotingHost(&context,
157 config, 135 config,
158 capturer.release(), 136 capturer.release(),
159 encoder.release(),
160 event_handler.release())); 137 event_handler.release()));
161 138
162 // Let the chromoting host run until the shutdown task is executed. 139 // Let the chromoting host run until the shutdown task is executed.
163 MessageLoop message_loop(MessageLoop::TYPE_UI); 140 MessageLoop message_loop(MessageLoop::TYPE_UI);
164 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop)); 141 host->Start(NewRunnableFunction(&ShutdownTask, &message_loop));
165 message_loop.Run(); 142 message_loop.Run();
166 143
167 // And then stop the chromoting context. 144 // And then stop the chromoting context.
168 context.Stop(); 145 context.Stop();
169 file_io_thread.Stop(); 146 file_io_thread.Stop();
170 return 0; 147 return 0;
171 } 148 }
OLDNEW
« no previous file with comments | « remoting/host/mock_objects.h ('k') | remoting/proto/video.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698