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

Unified Diff: content/renderer/media/media_stream_constraints_util.cc

Issue 227743004: Added a kEchoCancellation constraint to turn off the audio processing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: addressed Per's comments. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
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..bd4f9025d45790fe88ce2a00fc54615bc2701905
--- /dev/null
+++ b/content/renderer/media/media_stream_constraints_util.cc
@@ -0,0 +1,71 @@
+// 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& key,
+ bool* value) {
+ int constraint_value = 0;
+ if (!GetConstraintValue(constraints, key, &constraint_value))
+ return false;
+
+ *value = static_cast<bool>(constraint_value);
tommi (sloooow) - chröme 2014/04/17 10:56:41 can you DCHECK that constraint_value is either 1 o
no longer working on chromium 2014/04/23 14:59:06 No, that is constraint from JS, users can set it t
no longer working on chromium 2014/04/23 18:16:48 Wrong reply, I added overloaded methods for the Ge
+ return true;
+}
+
+bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
+ const std::string& key,
+ int* value) {
+ return GetMandatoryConstraintValue(constraints, key, value) ||
+ GetOptionalConstraintValue(constraints, key, value);
+}
+
+bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
+ const std::string& key,
+ std::string* value) {
+ blink::WebString value_str;
+ if (!constraints.getMandatoryConstraintValue(base::UTF8ToUTF16(key),
+ value_str) &&
+ !constraints.getOptionalConstraintValue(base::UTF8ToUTF16(key),
+ value_str)) {
+ return false;
+ }
+
+ *value = value_str.utf8();
+ return true;
+}
+
+bool GetMandatoryConstraintValue(const blink::WebMediaConstraints& constraints,
+ const std::string& key,
+ int* value) {
+ blink::WebString value_str;
+ if (!constraints.getMandatoryConstraintValue(base::UTF8ToUTF16(key),
+ value_str)) {
+ return false;
+ }
+
+ return base::StringToInt(value_str.utf8(), value);
tommi (sloooow) - chröme 2014/04/17 10:56:41 I think I've asked about this as well before. It
no longer working on chromium 2014/04/23 15:11:55 Thanks for pointing it out. I misunderstood that t
+}
+
+bool GetOptionalConstraintValue(const blink::WebMediaConstraints& constraints,
+ const std::string& key,
+ int* value) {
+ blink::WebString value_str;
+ if (!constraints.getOptionalConstraintValue(base::UTF8ToUTF16(key),
+ value_str)) {
+ return false;
+ }
+
+ return base::StringToInt(value_str.utf8(), value);
tommi (sloooow) - chröme 2014/04/17 10:56:41 here too
no longer working on chromium 2014/04/23 15:11:55 Ditto.
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698