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

Side by Side 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: moved some of the constraints code to MediaAudioConstraints class, and hope it makes the code more … 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/renderer/media/media_stream_constraints_util.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
10 #include "third_party/WebKit/public/platform/WebString.h"
11
12 namespace content {
13
14 bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
15 const std::string& key,
16 bool* value) {
17 int constraint_value = 0;
18 if (!GetConstraintValue(constraints, key, &constraint_value))
19 return false;
20
21 *value = static_cast<bool>(constraint_value);
22 return true;
23 }
24
25 bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
26 const std::string& key,
27 int* value) {
28 return GetMandatoryConstraintValue(constraints, key, value) ||
29 GetOptionalConstraintValue(constraints, key, value);
30 }
31
32 bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
33 const std::string& key,
34 std::string* value) {
35 blink::WebString value_str;
36 if (!constraints.getMandatoryConstraintValue(base::UTF8ToUTF16(key),
37 value_str) &&
38 !constraints.getOptionalConstraintValue(base::UTF8ToUTF16(key),
39 value_str)) {
40 return false;
41 }
42
43 *value = value_str.utf8();
44 return true;
45 }
46
47 bool GetMandatoryConstraintValue(const blink::WebMediaConstraints& constraints,
48 const std::string& key,
49 int* value) {
50 blink::WebString value_str;
51 if (!constraints.getMandatoryConstraintValue(base::UTF8ToUTF16(key),
52 value_str)) {
53 return false;
54 }
55
56 return base::StringToInt(value_str.utf8(), value);
57 }
58
59 bool GetOptionalConstraintValue(const blink::WebMediaConstraints& constraints,
60 const std::string& key,
61 int* value) {
62 blink::WebString value_str;
63 if (!constraints.getOptionalConstraintValue(base::UTF8ToUTF16(key),
64 value_str)) {
65 return false;
66 }
67
68 return base::StringToInt(value_str.utf8(), value);
69 }
70
71 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698