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

Side by Side Diff: chromecast/base/chromecast_switches.cc

Issue 1767603003: [chromecast] Add cast_shell --accept-resource-provider switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: use kSwitchValue{True,False} and fix DONOTSUBMIT comment Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chromecast/base/chromecast_switches.h" 5 #include "chromecast/base/chromecast_switches.h"
6 6
7 #include "base/command_line.h"
8
7 namespace switches { 9 namespace switches {
8 10
11 namespace {
12 // Value indicating whether flag from command line switch is true.
13 const char kSwitchValueTrue[] = "true";
14 // Value indicating whether flag from command line switch is false.
15 const char kSwitchValueFalse[] = "false";
16 } // namespace
17
9 // Enable the CMA media pipeline. 18 // Enable the CMA media pipeline.
10 const char kEnableCmaMediaPipeline[] = "enable-cma-media-pipeline"; 19 const char kEnableCmaMediaPipeline[] = "enable-cma-media-pipeline";
11 20
12 // The bitmask of codecs (media_caps.h) supported by the current HDMI sink. 21 // The bitmask of codecs (media_caps.h) supported by the current HDMI sink.
13 const char kHdmiSinkSupportedCodecs[] = "hdmi-sink-supported-codecs"; 22 const char kHdmiSinkSupportedCodecs[] = "hdmi-sink-supported-codecs";
14 23
15 // Enable file accesses. It should not be enabled for most Cast devices. 24 // Enable file accesses. It should not be enabled for most Cast devices.
16 const char kEnableLocalFileAccesses[] = "enable-local-file-accesses"; 25 const char kEnableLocalFileAccesses[] = "enable-local-file-accesses";
17 26
18 // Override the URL to which metrics logs are sent for debugging. 27 // Override the URL to which metrics logs are sent for debugging.
19 const char kOverrideMetricsUploadUrl[] = "override-metrics-upload-url"; 28 const char kOverrideMetricsUploadUrl[] = "override-metrics-upload-url";
20 29
21 // Disable features that require WiFi management. 30 // Disable features that require WiFi management.
22 const char kNoWifi[] = "no-wifi"; 31 const char kNoWifi[] = "no-wifi";
23 32
24 // Allows media playback for hidden WebContents 33 // Allows media playback for hidden WebContents
25 const char kAllowHiddenMediaPlayback[] = "allow-hidden-media-playback"; 34 const char kAllowHiddenMediaPlayback[] = "allow-hidden-media-playback";
26 35
27 // Pass the app id information to the renderer process, to be used for logging. 36 // Pass the app id information to the renderer process, to be used for logging.
28 // last-launched-app should be the app that just launched and is spawning the 37 // last-launched-app should be the app that just launched and is spawning the
29 // renderer. 38 // renderer.
30 const char kLastLaunchedApp[] = "last-launched-app"; 39 const char kLastLaunchedApp[] = "last-launched-app";
31 // previous-app should be the app that was running when last-launched-app 40 // previous-app should be the app that was running when last-launched-app
32 // started. 41 // started.
33 const char kPreviousApp[] = "previous-app"; 42 const char kPreviousApp[] = "previous-app";
34 43
44 // Flag indicating that a resource provider must be set up to provide cast
45 // receiver with resources. Apps cannot start until provided resources.
46 // This flag implies --alsa-check-close-timeout=0.
47 const char kAcceptResourceProvider[] = "accept-resource-provider";
48
35 // Size of the ALSA output buffer in frames. This directly sets the latency of 49 // Size of the ALSA output buffer in frames. This directly sets the latency of
36 // the output device. Latency can be calculated by multiplying the sample rate 50 // the output device. Latency can be calculated by multiplying the sample rate
37 // by the output buffer size. 51 // by the output buffer size.
38 const char kAlsaOutputBufferSize[] = "alsa-output-buffer-size"; 52 const char kAlsaOutputBufferSize[] = "alsa-output-buffer-size";
39 53
40 // Size of the ALSA output period in frames. The period of an ALSA output device 54 // Size of the ALSA output period in frames. The period of an ALSA output device
41 // determines how many frames elapse between hardware interrupts. 55 // determines how many frames elapse between hardware interrupts.
42 const char kAlsaOutputPeriodSize[] = "alsa-output-period-size"; 56 const char kAlsaOutputPeriodSize[] = "alsa-output-period-size";
43 57
44 // How many frames need to be in the output buffer before output starts. 58 // How many frames need to be in the output buffer before output starts.
45 const char kAlsaOutputStartThreshold[] = "alsa-output-start-threshold"; 59 const char kAlsaOutputStartThreshold[] = "alsa-output-start-threshold";
46 60
47 // Minimum number of available frames for scheduling a transfer. 61 // Minimum number of available frames for scheduling a transfer.
48 const char kAlsaOutputAvailMin[] = "alsa-output-avail-min"; 62 const char kAlsaOutputAvailMin[] = "alsa-output-avail-min";
49 63
50 // Time in ms to wait before closing the PCM handle when no more mixer inputs 64 // Time in ms to wait before closing the PCM handle when no more mixer inputs
51 // remain. 65 // remain. Assumed to be 0 if --accept-resource-provider is present.
52 const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout"; 66 const char kAlsaCheckCloseTimeout[] = "alsa-check-close-timeout";
53 67
54 // Number of channels on the alsa output device that the stream mixer uses. 68 // Number of channels on the alsa output device that the stream mixer uses.
55 // Default is 2 channels. 69 // Default is 2 channels.
56 const char kAlsaNumOutputChannels[] = "alsa-num-output-channels"; 70 const char kAlsaNumOutputChannels[] = "alsa-num-output-channels";
57 71
58 } // namespace switches 72 } // namespace switches
73
74 namespace cast {
75
76 bool GetSwitchValueBoolean(const std::string& switch_string,
77 const bool default_value) {
78 const base::CommandLine* command_line =
79 base::CommandLine::ForCurrentProcess();
80 bool ret = default_value;
81 if (command_line->HasSwitch(switch_string)) {
82 if (command_line->GetSwitchValueASCII(switch_string)
83 .compare(switches::kSwitchValueTrue) &&
kmackay 2016/03/08 17:32:48 I'd really prefer to use == or != rather than comp
jyw 2016/03/08 22:40:51 Done.
84 command_line->GetSwitchValueASCII(switch_string)
85 .compare(switches::kSwitchValueFalse) &&
86 command_line->GetSwitchValueASCII(switch_string).compare("")) {
87 LOG(WARNING) << "Invalid switch value " << switch_string << "="
88 << command_line->GetSwitchValueASCII(switch_string)
89 << "; assuming default value of " << default_value;
90 return default_value;
91 }
92 ret = command_line->GetSwitchValueASCII(switch_string)
93 .compare(switches::kSwitchValueFalse);
94 }
95 return ret;
96 }
97
98 } // namespace cast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698