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