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

Side by Side Diff: content/renderer/media/mock_media_constraint_factory.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: Created 6 years, 7 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 "base/strings/string_number_conversions.h" 5 #include "base/strings/string_number_conversions.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/renderer/media/mock_media_constraint_factory.h" 7 #include "content/renderer/media/mock_media_constraint_factory.h"
8 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h" 8 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface .h"
9 9
10 namespace content { 10 namespace content {
11 11
12 namespace {
13
14 static const char kValueTrue[] = "true";
15 static const char kValueFalse[] = "false";
16
17 } // namespace
18
12 MockMediaConstraintFactory::MockMediaConstraintFactory() { 19 MockMediaConstraintFactory::MockMediaConstraintFactory() {
13 } 20 }
14 21
15 MockMediaConstraintFactory::~MockMediaConstraintFactory() { 22 MockMediaConstraintFactory::~MockMediaConstraintFactory() {
16 } 23 }
17 24
18 blink::WebMediaConstraints 25 blink::WebMediaConstraints
19 MockMediaConstraintFactory::CreateWebMediaConstraints() { 26 MockMediaConstraintFactory::CreateWebMediaConstraints() {
20 blink::WebVector<blink::WebMediaConstraint> mandatory(mandatory_); 27 blink::WebVector<blink::WebMediaConstraint> mandatory(mandatory_);
21 blink::WebVector<blink::WebMediaConstraint> optional(optional_); 28 blink::WebVector<blink::WebMediaConstraint> optional(optional_);
22 blink::WebMediaConstraints constraints; 29 blink::WebMediaConstraints constraints;
23 constraints.initialize(optional, mandatory); 30 constraints.initialize(optional, mandatory);
24 return constraints; 31 return constraints;
25 } 32 }
26 33
27 void MockMediaConstraintFactory::AddMandatory(const std::string& key, 34 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
28 int value) { 35 int value) {
29 mandatory_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key), 36 mandatory_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key),
30 base::IntToString16(value))); 37 base::IntToString16(value)));
31 } 38 }
32 39
33 void MockMediaConstraintFactory::AddMandatory(const std::string& key, 40 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
34 double value) { 41 double value) {
35 mandatory_.push_back(blink::WebMediaConstraint( 42 mandatory_.push_back(blink::WebMediaConstraint(
36 base::UTF8ToUTF16(key), 43 base::UTF8ToUTF16(key),
37 base::UTF8ToUTF16(base::DoubleToString(value)))); 44 base::UTF8ToUTF16(base::DoubleToString(value))));
38 } 45 }
39 46
47 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
48 const std::string& value) {
49 mandatory_.push_back(blink::WebMediaConstraint(
50 base::UTF8ToUTF16(key), base::UTF8ToUTF16(value)));
51 }
52
53 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
54 bool value) {
55 const std::string string_value = value ? kValueTrue : kValueFalse;
56 AddMandatory(key, string_value);
57 }
58
40 void MockMediaConstraintFactory::AddOptional(const std::string& key, 59 void MockMediaConstraintFactory::AddOptional(const std::string& key,
41 int value) { 60 int value) {
42 optional_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key), 61 optional_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key),
43 base::IntToString16(value))); 62 base::IntToString16(value)));
44 } 63 }
45 64
46 void MockMediaConstraintFactory::AddOptional(const std::string& key, 65 void MockMediaConstraintFactory::AddOptional(const std::string& key,
47 double value) { 66 double value) {
48 optional_.push_back(blink::WebMediaConstraint( 67 optional_.push_back(blink::WebMediaConstraint(
49 base::UTF8ToUTF16(key), 68 base::UTF8ToUTF16(key),
50 base::UTF8ToUTF16(base::DoubleToString(value)))); 69 base::UTF8ToUTF16(base::DoubleToString(value))));
51 } 70 }
52 71
72 void MockMediaConstraintFactory::AddOptional(const std::string& key,
73 const std::string& value) {
74 optional_.push_back(blink::WebMediaConstraint(
75 base::UTF8ToUTF16(key), base::UTF8ToUTF16(value)));
76 }
77
78 void MockMediaConstraintFactory::AddOptional(const std::string& key,
79 bool value) {
80 const std::string string_value = value ? kValueTrue : kValueFalse;
81 AddOptional(key, string_value);
82 }
83
53 void MockMediaConstraintFactory::DisableDefaultAudioConstraints() { 84 void MockMediaConstraintFactory::DisableDefaultAudioConstraints() {
54 static const char* kDefaultAudioConstraints[] = { 85 static const char* kDefaultAudioConstraints[] = {
55 webrtc::MediaConstraintsInterface::kEchoCancellation, 86 webrtc::MediaConstraintsInterface::kEchoCancellation,
56 webrtc::MediaConstraintsInterface::kExperimentalEchoCancellation, 87 webrtc::MediaConstraintsInterface::kExperimentalEchoCancellation,
57 webrtc::MediaConstraintsInterface::kAutoGainControl, 88 webrtc::MediaConstraintsInterface::kAutoGainControl,
58 webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, 89 webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl,
59 webrtc::MediaConstraintsInterface::kNoiseSuppression, 90 webrtc::MediaConstraintsInterface::kNoiseSuppression,
60 webrtc::MediaConstraintsInterface::kHighpassFilter, 91 webrtc::MediaConstraintsInterface::kHighpassFilter,
61 webrtc::MediaConstraintsInterface::kTypingNoiseDetection, 92 webrtc::MediaConstraintsInterface::kTypingNoiseDetection,
62 webrtc::MediaConstraintsInterface::kExperimentalNoiseSuppression 93 webrtc::MediaConstraintsInterface::kExperimentalNoiseSuppression
63 }; 94 };
64 MockMediaConstraintFactory factory; 95 MockMediaConstraintFactory factory;
65 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { 96 for (size_t i = 0; i < arraysize(kDefaultAudioConstraints); ++i) {
66 AddMandatory(kDefaultAudioConstraints[i], false); 97 AddMandatory(kDefaultAudioConstraints[i], false);
67 } 98 }
68 } 99 }
69 100
70 } // namespace content 101 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698