Add ICU message format support
[chromium-blink-merge.git] / content / renderer / media / mock_media_constraint_factory.cc
blob11894508cc71975a9a6fe960b7f2c708d98dca5c
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.
5 #include "base/strings/string_number_conversions.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "content/renderer/media/mock_media_constraint_factory.h"
8 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface.h"
10 namespace content {
12 namespace {
14 static const char kValueTrue[] = "true";
15 static const char kValueFalse[] = "false";
17 } // namespace
19 MockMediaConstraintFactory::MockMediaConstraintFactory() {
22 MockMediaConstraintFactory::~MockMediaConstraintFactory() {
25 blink::WebMediaConstraints
26 MockMediaConstraintFactory::CreateWebMediaConstraints() {
27 blink::WebVector<blink::WebMediaConstraint> mandatory(mandatory_);
28 blink::WebVector<blink::WebMediaConstraint> optional(optional_);
29 blink::WebMediaConstraints constraints;
30 constraints.initialize(optional, mandatory);
31 return constraints;
34 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
35 int value) {
36 mandatory_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key),
37 base::IntToString16(value)));
40 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
41 double value) {
42 mandatory_.push_back(blink::WebMediaConstraint(
43 base::UTF8ToUTF16(key),
44 base::UTF8ToUTF16(base::DoubleToString(value))));
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)));
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);
59 void MockMediaConstraintFactory::AddOptional(const std::string& key,
60 int value) {
61 optional_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key),
62 base::IntToString16(value)));
65 void MockMediaConstraintFactory::AddOptional(const std::string& key,
66 double value) {
67 optional_.push_back(blink::WebMediaConstraint(
68 base::UTF8ToUTF16(key),
69 base::UTF8ToUTF16(base::DoubleToString(value))));
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)));
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);
84 void MockMediaConstraintFactory::DisableDefaultAudioConstraints() {
85 static const char* kDefaultAudioConstraints[] = {
86 webrtc::MediaConstraintsInterface::kGoogEchoCancellation,
87 webrtc::MediaConstraintsInterface::kExtendedFilterEchoCancellation,
88 webrtc::MediaConstraintsInterface::kAutoGainControl,
89 webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl,
90 webrtc::MediaConstraintsInterface::kNoiseSuppression,
91 webrtc::MediaConstraintsInterface::kHighpassFilter,
92 webrtc::MediaConstraintsInterface::kTypingNoiseDetection,
93 webrtc::MediaConstraintsInterface::kExperimentalNoiseSuppression
95 MockMediaConstraintFactory factory;
96 for (size_t i = 0; i < arraysize(kDefaultAudioConstraints); ++i) {
97 AddMandatory(kDefaultAudioConstraints[i], false);
101 } // namespace content