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

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

Issue 372943002: Add video frame recording capability to Chromoting hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Working implementation. Created 6 years, 5 months 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
OLDNEW
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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "remoting/host/json_host_config.h" 61 #include "remoting/host/json_host_config.h"
62 #include "remoting/host/logging.h" 62 #include "remoting/host/logging.h"
63 #include "remoting/host/me2me_desktop_environment.h" 63 #include "remoting/host/me2me_desktop_environment.h"
64 #include "remoting/host/pairing_registry_delegate.h" 64 #include "remoting/host/pairing_registry_delegate.h"
65 #include "remoting/host/policy_hack/policy_watcher.h" 65 #include "remoting/host/policy_hack/policy_watcher.h"
66 #include "remoting/host/session_manager_factory.h" 66 #include "remoting/host/session_manager_factory.h"
67 #include "remoting/host/signaling_connector.h" 67 #include "remoting/host/signaling_connector.h"
68 #include "remoting/host/token_validator_factory_impl.h" 68 #include "remoting/host/token_validator_factory_impl.h"
69 #include "remoting/host/usage_stats_consent.h" 69 #include "remoting/host/usage_stats_consent.h"
70 #include "remoting/host/username.h" 70 #include "remoting/host/username.h"
71 #include "remoting/host/video_frame_recorder_host_extension.h"
71 #include "remoting/jingle_glue/network_settings.h" 72 #include "remoting/jingle_glue/network_settings.h"
72 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 73 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
73 #include "remoting/protocol/me2me_host_authenticator_factory.h" 74 #include "remoting/protocol/me2me_host_authenticator_factory.h"
74 #include "remoting/protocol/pairing_registry.h" 75 #include "remoting/protocol/pairing_registry.h"
75 #include "remoting/protocol/token_validator.h" 76 #include "remoting/protocol/token_validator.h"
76 77
77 #if defined(OS_POSIX) 78 #if defined(OS_POSIX)
78 #include <signal.h> 79 #include <signal.h>
79 #include <sys/types.h> 80 #include <sys/types.h>
80 #include <unistd.h> 81 #include <unistd.h>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; 117 const char kAuthSocknameSwitchName[] = "ssh-auth-sockname";
117 #endif // defined(OS_LINUX) 118 #endif // defined(OS_LINUX)
118 119
119 // The command line switch used by the parent to request the host to signal it 120 // The command line switch used by the parent to request the host to signal it
120 // when it is successfully started. 121 // when it is successfully started.
121 const char kSignalParentSwitchName[] = "signal-parent"; 122 const char kSignalParentSwitchName[] = "signal-parent";
122 123
123 // Command line switch used to enable VP9 encoding. 124 // Command line switch used to enable VP9 encoding.
124 const char kEnableVp9SwitchName[] = "enable-vp9"; 125 const char kEnableVp9SwitchName[] = "enable-vp9";
125 126
127 // Command line switch used to enable and configure the frame-recorder.
128 const char kFrameRecorderBufferKbName[] = "frame-recorder-buffer-kb";
Sergey Ulanov 2014/07/11 18:38:03 Add this flag in the usage message in host_main.cc
Sergey Ulanov 2014/07/11 18:38:03 Do we really need this flag? Maybe always have rec
Wez 2014/07/31 23:57:46 It's not clear what a "sensible buffer size" would
129
126 // Value used for --host-config option to indicate that the path must be read 130 // Value used for --host-config option to indicate that the path must be read
127 // from stdin. 131 // from stdin.
128 const char kStdinConfigPath[] = "-"; 132 const char kStdinConfigPath[] = "-";
129 133
130 } // namespace 134 } // namespace
131 135
132 namespace remoting { 136 namespace remoting {
133 137
134 class HostProcess 138 class HostProcess
135 : public ConfigWatcher::Delegate, 139 : public ConfigWatcher::Delegate,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 scoped_ptr<ConfigWatcher> config_watcher_; 284 scoped_ptr<ConfigWatcher> config_watcher_;
281 285
282 std::string host_id_; 286 std::string host_id_;
283 protocol::SharedSecretHash host_secret_hash_; 287 protocol::SharedSecretHash host_secret_hash_;
284 scoped_refptr<RsaKeyPair> key_pair_; 288 scoped_refptr<RsaKeyPair> key_pair_;
285 std::string oauth_refresh_token_; 289 std::string oauth_refresh_token_;
286 std::string serialized_config_; 290 std::string serialized_config_;
287 std::string host_owner_; 291 std::string host_owner_;
288 bool use_service_account_; 292 bool use_service_account_;
289 bool enable_vp9_; 293 bool enable_vp9_;
294 int64_t frame_recorder_buffer_size_;
290 295
291 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; 296 scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
292 std::string host_domain_; 297 std::string host_domain_;
293 bool host_username_match_required_; 298 bool host_username_match_required_;
294 bool allow_nat_traversal_; 299 bool allow_nat_traversal_;
295 bool allow_relay_; 300 bool allow_relay_;
296 int min_udp_port_; 301 int min_udp_port_;
297 int max_udp_port_; 302 int max_udp_port_;
298 std::string talkgadget_prefix_; 303 std::string talkgadget_prefix_;
299 bool allow_pairing_; 304 bool allow_pairing_;
(...skipping 25 matching lines...) Expand all
325 330
326 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_; 331 scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_;
327 }; 332 };
328 333
329 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, 334 HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
330 int* exit_code_out) 335 int* exit_code_out)
331 : context_(context.Pass()), 336 : context_(context.Pass()),
332 state_(HOST_INITIALIZING), 337 state_(HOST_INITIALIZING),
333 use_service_account_(false), 338 use_service_account_(false),
334 enable_vp9_(false), 339 enable_vp9_(false),
340 frame_recorder_buffer_size_(0),
335 host_username_match_required_(false), 341 host_username_match_required_(false),
336 allow_nat_traversal_(true), 342 allow_nat_traversal_(true),
337 allow_relay_(true), 343 allow_relay_(true),
338 min_udp_port_(0), 344 min_udp_port_(0),
339 max_udp_port_(0), 345 max_udp_port_(0),
340 allow_pairing_(true), 346 allow_pairing_(true),
341 curtain_required_(false), 347 curtain_required_(false),
342 enable_gnubby_auth_(false), 348 enable_gnubby_auth_(false),
343 #if defined(REMOTING_MULTI_PROCESS) 349 #if defined(REMOTING_MULTI_PROCESS)
344 desktop_session_connector_(NULL), 350 desktop_session_connector_(NULL),
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 use_service_account_ = false; 824 use_service_account_ = false;
819 } 825 }
820 826
821 // Allow offering of VP9 encoding to be overridden by the command-line. 827 // Allow offering of VP9 encoding to be overridden by the command-line.
822 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableVp9SwitchName)) { 828 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableVp9SwitchName)) {
823 enable_vp9_ = true; 829 enable_vp9_ = true;
824 } else { 830 } else {
825 config->GetBoolean(kEnableVp9ConfigPath, &enable_vp9_); 831 config->GetBoolean(kEnableVp9ConfigPath, &enable_vp9_);
826 } 832 }
827 833
834 // Allow the command-line to override the size of the frame recorder buffer.
835 std::string frame_recorder_buffer_kb;
836 if (CommandLine::ForCurrentProcess()->HasSwitch(
837 kFrameRecorderBufferKbName)) {
838 frame_recorder_buffer_kb =
839 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
840 kFrameRecorderBufferKbName);
841 } else {
842 config->GetString(kFrameRecorderBufferKbConfigPath,
843 &frame_recorder_buffer_kb);
844 }
845 if (!frame_recorder_buffer_kb.empty()) {
846 int buffer_kb = 0;
847 if (base::StringToInt(frame_recorder_buffer_kb, &buffer_kb)) {
848 frame_recorder_buffer_size_ = 1024LL * buffer_kb;
849 }
850 }
851
828 return true; 852 return true;
829 } 853 }
830 854
831 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) { 855 void HostProcess::OnPolicyUpdate(scoped_ptr<base::DictionaryValue> policies) {
832 if (!context_->network_task_runner()->BelongsToCurrentThread()) { 856 if (!context_->network_task_runner()->BelongsToCurrentThread()) {
833 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind( 857 context_->network_task_runner()->PostTask(FROM_HERE, base::Bind(
834 &HostProcess::OnPolicyUpdate, this, base::Passed(&policies))); 858 &HostProcess::OnPolicyUpdate, this, base::Passed(&policies)));
835 return; 859 return;
836 } 860 }
837 861
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 context_->network_task_runner(), 1222 context_->network_task_runner(),
1199 context_->ui_task_runner())); 1223 context_->ui_task_runner()));
1200 1224
1201 if (enable_vp9_) { 1225 if (enable_vp9_) {
1202 scoped_ptr<protocol::CandidateSessionConfig> config = 1226 scoped_ptr<protocol::CandidateSessionConfig> config =
1203 host_->protocol_config()->Clone(); 1227 host_->protocol_config()->Clone();
1204 config->EnableVideoCodec(protocol::ChannelConfig::CODEC_VP9); 1228 config->EnableVideoCodec(protocol::ChannelConfig::CODEC_VP9);
1205 host_->set_protocol_config(config.Pass()); 1229 host_->set_protocol_config(config.Pass());
1206 } 1230 }
1207 1231
1232 if (frame_recorder_buffer_size_ > 0) {
1233 scoped_ptr<VideoFrameRecorderHostExtension> frame_recorder_extension(
1234 new VideoFrameRecorderHostExtension());
1235 frame_recorder_extension->SetMaxContentBytes(frame_recorder_buffer_size_);
1236 host_->SetEnableVideoFrameRecording(true);
1237 host_->AddExtension(frame_recorder_extension.PassAs<HostExtension>());
1238 }
1239
1208 // TODO(simonmorris): Get the maximum session duration from a policy. 1240 // TODO(simonmorris): Get the maximum session duration from a policy.
1209 #if defined(OS_LINUX) 1241 #if defined(OS_LINUX)
1210 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); 1242 host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
1211 #endif 1243 #endif
1212 1244
1213 heartbeat_sender_.reset(new HeartbeatSender( 1245 heartbeat_sender_.reset(new HeartbeatSender(
1214 this, host_id_, signal_strategy_.get(), key_pair_, 1246 this, host_id_, signal_strategy_.get(), key_pair_,
1215 directory_bot_jid_)); 1247 directory_bot_jid_));
1216 1248
1217 host_status_sender_.reset(new HostStatusSender( 1249 host_status_sender_.reset(new HostStatusSender(
1218 host_id_, signal_strategy_.get(), key_pair_, directory_bot_jid_)); 1250 host_id_, signal_strategy_.get(), key_pair_, directory_bot_jid_));
1219 1251
1220 host_change_notification_listener_.reset(new HostChangeNotificationListener( 1252 host_change_notification_listener_.reset(new HostChangeNotificationListener(
1221 this, host_id_, signal_strategy_.get(), directory_bot_jid_)); 1253 this, host_id_, signal_strategy_.get(), directory_bot_jid_));
1222 1254
1223 host_status_logger_.reset( 1255 host_status_logger_.reset(
1224 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::ME2ME, 1256 new HostStatusLogger(host_->AsWeakPtr(), ServerLogEntry::ME2ME,
1225 signal_strategy_.get(), directory_bot_jid_)); 1257 signal_strategy_.get(), directory_bot_jid_));
1226 1258
1227 // Set up repoting the host status notifications. 1259 // Set up reporting the host status notifications.
1228 #if defined(REMOTING_MULTI_PROCESS) 1260 #if defined(REMOTING_MULTI_PROCESS)
1229 host_event_logger_.reset( 1261 host_event_logger_.reset(
1230 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get())); 1262 new IpcHostEventLogger(host_->AsWeakPtr(), daemon_channel_.get()));
1231 #else // !defined(REMOTING_MULTI_PROCESS) 1263 #else // !defined(REMOTING_MULTI_PROCESS)
1232 host_event_logger_ = 1264 host_event_logger_ =
1233 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName); 1265 HostEventLogger::Create(host_->AsWeakPtr(), kApplicationName);
1234 #endif // !defined(REMOTING_MULTI_PROCESS) 1266 #endif // !defined(REMOTING_MULTI_PROCESS)
1235 1267
1236 host_->SetEnableCurtaining(curtain_required_); 1268 host_->SetEnableCurtaining(curtain_required_);
1237 host_->Start(host_owner_); 1269 host_->Start(host_owner_);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 return exit_code; 1407 return exit_code;
1376 } 1408 }
1377 1409
1378 } // namespace remoting 1410 } // namespace remoting
1379 1411
1380 #if !defined(OS_WIN) 1412 #if !defined(OS_WIN)
1381 int main(int argc, char** argv) { 1413 int main(int argc, char** argv) {
1382 return remoting::HostMain(argc, argv); 1414 return remoting::HostMain(argc, argv);
1383 } 1415 }
1384 #endif // !defined(OS_WIN) 1416 #endif // !defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698