Index: content/renderer/media/media_stream_constraints_util.cc |
diff --git a/content/renderer/media/media_stream_constraints_util.cc b/content/renderer/media/media_stream_constraints_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f00a95b34ab31dc5f627c6e03b1ce2c0f1bea533 |
--- /dev/null |
+++ b/content/renderer/media/media_stream_constraints_util.cc |
@@ -0,0 +1,56 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/renderer/media/media_stream_constraints_util.h" |
+ |
+#include "base/strings/string_number_conversions.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
+#include "third_party/WebKit/public/platform/WebString.h" |
+ |
+namespace content { |
+ |
+bool GetConstraintValue(const blink::WebMediaConstraints& constraints, |
+ const std::string& name, |
+ bool* value) { |
+ int constraint_value = 0; |
+ if (!GetConstraintValue(constraints, name, &constraint_value)) |
+ return false; |
+ |
+ *value = static_cast<bool>(constraint_value); |
tommi (sloooow) - chröme
2014/04/08 10:49:30
Are you sure this works?
The values of these cons
no longer working on chromium
2014/04/11 08:56:30
Yes, the value is stored as blink::WebString in bl
|
+ return true; |
+} |
+ |
+bool GetConstraintValue(const blink::WebMediaConstraints& constraints, |
+ const std::string& name, |
+ int* value) { |
+ return GetManatoryConstraintValue(constraints, name, value) || |
+ GetOptionalConstraintValue(constraints, name, value); |
+} |
+ |
+bool GetManatoryConstraintValue(const blink::WebMediaConstraints& constraints, |
tommi (sloooow) - chröme
2014/04/08 10:49:30
GetMandatoryConstraintValue
(missing 'd')
no longer working on chromium
2014/04/11 08:56:30
Done.
|
+ const std::string& name, |
+ int* value) { |
+ blink::WebString value_str; |
+ if (!constraints.getMandatoryConstraintValue(base::UTF8ToUTF16(name), |
+ value_str)) |
+ return false; |
+ |
+ base::StringToInt(value_str.utf8(), value); |
tommi (sloooow) - chröme
2014/04/08 10:49:30
return base::StringToInt(value_str.utf8(), value);
no longer working on chromium
2014/04/11 08:56:30
Done.
|
+ return true; |
+} |
+ |
+bool GetOptionalConstraintValue(const blink::WebMediaConstraints& constraints, |
+ const std::string& name, |
+ int* value) { |
+ blink::WebString value_str; |
+ if (!constraints.getOptionalConstraintValue(base::UTF8ToUTF16(name), |
+ value_str)) |
tommi (sloooow) - chröme
2014/04/08 10:49:30
{}
no longer working on chromium
2014/04/11 08:56:30
Done.
|
+ return false; |
+ |
+ base::StringToInt(value_str.utf8(), value); |
tommi (sloooow) - chröme
2014/04/08 10:49:30
return base::StringToInt(value_str.utf8(), value);
no longer working on chromium
2014/04/11 08:56:30
Done.
|
+ return true; |
+} |
+ |
+} // namespace content |