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

Side by Side Diff: content/renderer/media/mock_media_constraint_factory.cc

Issue 1729683002: Remove old-style constraints from Chrome internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Complete the interface change Created 4 years, 9 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 <stddef.h>
6
7 #include "base/macros.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "content/renderer/media/media_stream_audio_processor_options.h"
11 #include "content/renderer/media/mock_media_constraint_factory.h"
12 #include "third_party/webrtc/api/mediaconstraintsinterface.h"
13
14 namespace content {
15
16 namespace {
17
18 static const char kValueTrue[] = "true";
19 static const char kValueFalse[] = "false";
20
21 } // namespace
22
23 MockMediaConstraintFactory::MockMediaConstraintFactory() {
24 }
25
26 MockMediaConstraintFactory::~MockMediaConstraintFactory() {
27 }
28
29 blink::WebMediaConstraints
30 MockMediaConstraintFactory::CreateWebMediaConstraints() const {
31 blink::WebVector<blink::WebMediaConstraint> mandatory(mandatory_);
32 blink::WebVector<blink::WebMediaConstraint> optional(optional_);
33 blink::WebMediaConstraints constraints;
34 blink::WebMediaTrackConstraintSet basic;
35 blink::WebVector<blink::WebMediaTrackConstraintSet> advanced;
36 constraints.initialize(optional, mandatory, basic, advanced);
37 return constraints;
38 }
39
40 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
41 int value) {
42 mandatory_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key),
43 base::IntToString16(value)));
44 }
45
46 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
47 double value) {
48 mandatory_.push_back(blink::WebMediaConstraint(
49 base::UTF8ToUTF16(key),
50 base::UTF8ToUTF16(base::DoubleToString(value))));
51 }
52
53 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
54 const std::string& value) {
55 mandatory_.push_back(blink::WebMediaConstraint(
56 base::UTF8ToUTF16(key), base::UTF8ToUTF16(value)));
57 }
58
59 void MockMediaConstraintFactory::AddMandatory(const std::string& key,
60 bool value) {
61 const std::string string_value = value ? kValueTrue : kValueFalse;
62 AddMandatory(key, string_value);
63 }
64
65 void MockMediaConstraintFactory::AddOptional(const std::string& key,
66 int value) {
67 optional_.push_back(blink::WebMediaConstraint(base::UTF8ToUTF16(key),
68 base::IntToString16(value)));
69 }
70
71 void MockMediaConstraintFactory::AddOptional(const std::string& key,
72 double value) {
73 optional_.push_back(blink::WebMediaConstraint(
74 base::UTF8ToUTF16(key),
75 base::UTF8ToUTF16(base::DoubleToString(value))));
76 }
77
78 void MockMediaConstraintFactory::AddOptional(const std::string& key,
79 const std::string& value) {
80 optional_.push_back(blink::WebMediaConstraint(
81 base::UTF8ToUTF16(key), base::UTF8ToUTF16(value)));
82 }
83
84 void MockMediaConstraintFactory::AddOptional(const std::string& key,
85 bool value) {
86 const std::string string_value = value ? kValueTrue : kValueFalse;
87 AddOptional(key, string_value);
88 }
89
90 void MockMediaConstraintFactory::DisableDefaultAudioConstraints() {
91 static const char* kDefaultAudioConstraints[] = {
92 webrtc::MediaConstraintsInterface::kGoogEchoCancellation,
93 webrtc::MediaConstraintsInterface::kExtendedFilterEchoCancellation,
94 webrtc::MediaConstraintsInterface::kAutoGainControl,
95 webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl,
96 webrtc::MediaConstraintsInterface::kNoiseSuppression,
97 webrtc::MediaConstraintsInterface::kHighpassFilter,
98 webrtc::MediaConstraintsInterface::kTypingNoiseDetection,
99 webrtc::MediaConstraintsInterface::kExperimentalNoiseSuppression,
100 // This isn't part of the MediaConstraintsInterface.
101 MediaAudioConstraints::kGoogBeamforming
102 };
103 MockMediaConstraintFactory factory;
104 for (size_t i = 0; i < arraysize(kDefaultAudioConstraints); ++i) {
105 AddMandatory(kDefaultAudioConstraints[i], false);
106 }
107 }
108
109 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/mock_media_constraint_factory.h ('k') | content/renderer/media/mock_peer_connection_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698