Commit 36d3f2a0 authored by wez@chromium.org's avatar wez@chromium.org

Add enable_vp9 option to host config.

Review URL: https://codereview.chromium.org/331853009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277876 0039d316-1c4b-4281-b951-d872f2087c98
parent 061a496e
...@@ -31,8 +31,6 @@ namespace remoting { ...@@ -31,8 +31,6 @@ namespace remoting {
namespace { namespace {
const char kEnableVp9SwitchName[] = "enable-vp9";
const net::BackoffEntry::Policy kDefaultBackoffPolicy = { const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
// Number of initial errors (in sequence) to ignore before applying // Number of initial errors (in sequence) to ignore before applying
// exponential back-off rules. // exponential back-off rules.
...@@ -92,11 +90,6 @@ ChromotingHost::ChromotingHost( ...@@ -92,11 +90,6 @@ ChromotingHost::ChromotingHost(
jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
// Enable VP9 if specified on the command-line.
if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableVp9SwitchName)) {
protocol_config_->EnableVideoCodec(protocol::ChannelConfig::CODEC_VP9);
}
if (!desktop_environment_factory_->SupportsAudioCapture()) { if (!desktop_environment_factory_->SupportsAudioCapture()) {
protocol_config_->DisableAudioChannel(); protocol_config_->DisableAudioChannel();
} }
......
...@@ -139,13 +139,14 @@ class ChromotingHost : public base::NonThreadSafe, ...@@ -139,13 +139,14 @@ class ChromotingHost : public base::NonThreadSafe,
protocol::Session* session, protocol::Session* session,
protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE; protocol::SessionManager::IncomingSessionResponse* response) OVERRIDE;
// Gets the candidate configuration for the protocol.
const protocol::CandidateSessionConfig* protocol_config() const {
return protocol_config_.get();
}
// Sets desired configuration for the protocol. Must be called before Start(). // Sets desired configuration for the protocol. Must be called before Start().
void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config); void set_protocol_config(scoped_ptr<protocol::CandidateSessionConfig> config);
base::WeakPtr<ChromotingHost> AsWeakPtr() {
return weak_factory_.GetWeakPtr();
}
// The host uses a pairing registry to generate and store pairing information // The host uses a pairing registry to generate and store pairing information
// for clients for PIN-less authentication. // for clients for PIN-less authentication.
scoped_refptr<protocol::PairingRegistry> pairing_registry() const { scoped_refptr<protocol::PairingRegistry> pairing_registry() const {
...@@ -156,6 +157,10 @@ class ChromotingHost : public base::NonThreadSafe, ...@@ -156,6 +157,10 @@ class ChromotingHost : public base::NonThreadSafe,
pairing_registry_ = pairing_registry; pairing_registry_ = pairing_registry;
} }
base::WeakPtr<ChromotingHost> AsWeakPtr() {
return weak_factory_.GetWeakPtr();
}
private: private:
friend class ChromotingHostTest; friend class ChromotingHostTest;
......
...@@ -17,5 +17,6 @@ const char kHostNameConfigPath[] = "host_name"; ...@@ -17,5 +17,6 @@ const char kHostNameConfigPath[] = "host_name";
const char kHostSecretHashConfigPath[] = "host_secret_hash"; const char kHostSecretHashConfigPath[] = "host_secret_hash";
const char kPrivateKeyConfigPath[] = "private_key"; const char kPrivateKeyConfigPath[] = "private_key";
const char kUsageStatsConsentConfigPath[] = "usage_stats_consent"; const char kUsageStatsConsentConfigPath[] = "usage_stats_consent";
const char kEnableVp9ConfigPath[] = "enable_vp9";
} // namespace remoting } // namespace remoting
...@@ -40,6 +40,8 @@ extern const char kHostSecretHashConfigPath[]; ...@@ -40,6 +40,8 @@ extern const char kHostSecretHashConfigPath[];
extern const char kPrivateKeyConfigPath[]; extern const char kPrivateKeyConfigPath[];
// Whether consent is given for usage stats reporting. // Whether consent is given for usage stats reporting.
extern const char kUsageStatsConsentConfigPath[]; extern const char kUsageStatsConsentConfigPath[];
// Whether to offer VP9 encoding to clients.
extern const char kEnableVp9ConfigPath[];
// HostConfig interace provides read-only access to host configuration. // HostConfig interace provides read-only access to host configuration.
class HostConfig { class HostConfig {
......
...@@ -124,6 +124,9 @@ const char kAuthSocknameSwitchName[] = "ssh-auth-sockname"; ...@@ -124,6 +124,9 @@ const char kAuthSocknameSwitchName[] = "ssh-auth-sockname";
// when it is successfully started. // when it is successfully started.
const char kSignalParentSwitchName[] = "signal-parent"; const char kSignalParentSwitchName[] = "signal-parent";
// Command line switch used to enable VP9 encoding.
const char kEnableVp9SwitchName[] = "enable-vp9";
// Value used for --host-config option to indicate that the path must be read // Value used for --host-config option to indicate that the path must be read
// from stdin. // from stdin.
const char kStdinConfigPath[] = "-"; const char kStdinConfigPath[] = "-";
...@@ -287,6 +290,7 @@ class HostProcess ...@@ -287,6 +290,7 @@ class HostProcess
std::string serialized_config_; std::string serialized_config_;
std::string host_owner_; std::string host_owner_;
bool use_service_account_; bool use_service_account_;
bool enable_vp9_;
scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_; scoped_ptr<policy_hack::PolicyWatcher> policy_watcher_;
std::string host_domain_; std::string host_domain_;
...@@ -331,6 +335,7 @@ HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context, ...@@ -331,6 +335,7 @@ HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
: context_(context.Pass()), : context_(context.Pass()),
state_(HOST_INITIALIZING), state_(HOST_INITIALIZING),
use_service_account_(false), use_service_account_(false),
enable_vp9_(false),
host_username_match_required_(false), host_username_match_required_(false),
allow_nat_traversal_(true), allow_nat_traversal_(true),
allow_relay_(true), allow_relay_(true),
...@@ -816,6 +821,14 @@ bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) { ...@@ -816,6 +821,14 @@ bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) {
host_owner_ = xmpp_server_config_.username; host_owner_ = xmpp_server_config_.username;
use_service_account_ = false; use_service_account_ = false;
} }
// Allow offering of VP9 encoding to be overridden by the command-line.
if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableVp9SwitchName)) {
enable_vp9_ = true;
} else {
config->GetBoolean(kEnableVp9ConfigPath, &enable_vp9_);
}
return true; return true;
} }
...@@ -1190,6 +1203,13 @@ void HostProcess::StartHost() { ...@@ -1190,6 +1203,13 @@ void HostProcess::StartHost() {
context_->network_task_runner(), context_->network_task_runner(),
context_->ui_task_runner())); context_->ui_task_runner()));
if (enable_vp9_) {
scoped_ptr<protocol::CandidateSessionConfig> config =
host_->protocol_config()->Clone();
config->EnableVideoCodec(protocol::ChannelConfig::CODEC_VP9);
host_->set_protocol_config(config.Pass());
}
// TODO(simonmorris): Get the maximum session duration from a policy. // TODO(simonmorris): Get the maximum session duration from a policy.
#if defined(OS_LINUX) #if defined(OS_LINUX)
host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20)); host_->SetMaximumSessionDuration(base::TimeDelta::FromHours(20));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment