OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/media_stream_audio_processor_options.h" | 5 #include "content/renderer/media/media_stream_audio_processor_options.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/common/media/media_stream_options.h" |
11 #include "content/renderer/media/rtc_media_constraints.h" | 12 #include "content/renderer/media/rtc_media_constraints.h" |
12 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
13 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 14 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
14 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" | 15 #include "third_party/libjingle/source/talk/app/webrtc/mediaconstraintsinterface
.h" |
15 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" | 16 #include "third_party/webrtc/modules/audio_processing/include/audio_processing.h
" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
(...skipping 13 matching lines...) Expand all Loading... |
34 { webrtc::MediaConstraintsInterface::kAutoGainControl, | 35 { webrtc::MediaConstraintsInterface::kAutoGainControl, |
35 webrtc::MediaConstraintsInterface::kValueTrue }, | 36 webrtc::MediaConstraintsInterface::kValueTrue }, |
36 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, | 37 { webrtc::MediaConstraintsInterface::kExperimentalAutoGainControl, |
37 webrtc::MediaConstraintsInterface::kValueTrue }, | 38 webrtc::MediaConstraintsInterface::kValueTrue }, |
38 { webrtc::MediaConstraintsInterface::kNoiseSuppression, | 39 { webrtc::MediaConstraintsInterface::kNoiseSuppression, |
39 webrtc::MediaConstraintsInterface::kValueTrue }, | 40 webrtc::MediaConstraintsInterface::kValueTrue }, |
40 { webrtc::MediaConstraintsInterface::kHighpassFilter, | 41 { webrtc::MediaConstraintsInterface::kHighpassFilter, |
41 webrtc::MediaConstraintsInterface::kValueTrue }, | 42 webrtc::MediaConstraintsInterface::kValueTrue }, |
42 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection, | 43 { webrtc::MediaConstraintsInterface::kTypingNoiseDetection, |
43 webrtc::MediaConstraintsInterface::kValueTrue }, | 44 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 45 #if defined(OS_WIN) |
| 46 { content::kMediaStreamAudioDucking, |
| 47 webrtc::MediaConstraintsInterface::kValueTrue }, |
| 48 #endif |
44 }; | 49 }; |
45 | 50 |
46 } // namespace | 51 } // namespace |
47 | 52 |
48 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) { | 53 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints) { |
49 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { | 54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDefaultAudioConstraints); ++i) { |
50 bool already_set_value; | 55 bool already_set_value; |
51 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key, | 56 if (!webrtc::FindConstraint(constraints, kDefaultAudioConstraints[i].key, |
52 &already_set_value, NULL)) { | 57 &already_set_value, NULL)) { |
| 58 // TODO(tommi): This adds the default constraints to the 'mandatory' |
| 59 // section but it might make more sense to add these to the optional |
| 60 // section since if for whatever reason the default implied constraints |
| 61 // aren't supported on some platform then we should not fail the |
| 62 // getUserMedia call. 'kMediaStreamAudioDucking' is an example where |
| 63 // it is not supported on XP but is supported on newer versions. |
53 constraints->AddMandatory(kDefaultAudioConstraints[i].key, | 64 constraints->AddMandatory(kDefaultAudioConstraints[i].key, |
54 kDefaultAudioConstraints[i].value, false); | 65 kDefaultAudioConstraints[i].value, false); |
55 } else { | 66 } else { |
56 DVLOG(1) << "Constraint " << kDefaultAudioConstraints[i].key | 67 DVLOG(1) << "Constraint " << kDefaultAudioConstraints[i].key |
57 << " already set to " << already_set_value; | 68 << " already set to " << already_set_value; |
58 } | 69 } |
59 } | 70 } |
60 } | 71 } |
61 | 72 |
62 bool NeedsAudioProcessing(const blink::WebMediaConstraints& constraints, | 73 bool NeedsAudioProcessing(const blink::WebMediaConstraints& constraints, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; | 173 const webrtc::GainControl::Mode mode = webrtc::GainControl::kFixedDigital; |
163 #else | 174 #else |
164 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; | 175 const webrtc::GainControl::Mode mode = webrtc::GainControl::kAdaptiveAnalog; |
165 #endif | 176 #endif |
166 int err = audio_processing->gain_control()->set_mode(mode); | 177 int err = audio_processing->gain_control()->set_mode(mode); |
167 err |= audio_processing->gain_control()->Enable(true); | 178 err |= audio_processing->gain_control()->Enable(true); |
168 CHECK_EQ(err, 0); | 179 CHECK_EQ(err, 0); |
169 } | 180 } |
170 | 181 |
171 } // namespace content | 182 } // namespace content |
OLD | NEW |