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

Side by Side Diff: content/renderer/media/media_stream_audio_processor_options.h

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: addressed Tommi's comments. 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 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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
11 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h" 12 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
12 13
13 namespace blink {
14 class WebMediaConstraints;
15 }
16
17 namespace webrtc { 14 namespace webrtc {
18 15
19 class AudioFrame; 16 class AudioFrame;
20 class AudioProcessing; 17 class AudioProcessing;
21 class MediaConstraintsInterface; 18 class MediaConstraintsInterface;
22 class TypingDetection; 19 class TypingDetection;
23 20
24 } 21 }
25 22
26 namespace content { 23 namespace content {
27 24
28 class RTCMediaConstraints; 25 class RTCMediaConstraints;
29 26
30 using webrtc::AudioProcessing; 27 using webrtc::AudioProcessing;
31 using webrtc::MediaConstraintsInterface; 28 using webrtc::MediaConstraintsInterface;
32 29
33 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which exists 30 // A helper class to parse audio constraints from a blink::WebMediaConstraints
34 // in both, the value from |constraints| is maintained, including its 31 // object.
35 // mandatory/optional status. New values from |kDefaultAudioConstraints| will 32 class MediaAudioConstraints {
36 // be added with mandatory status. 33 public:
37 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints); 34 // Constraint keys used by audio processing.
35 static const char kEchoCancellation[];
36 static const char kGoogEchoCancellation[];
37 static const char kGoogExperimentalEchoCancellation[];
38 static const char kGoogAutoGainControl[];
39 static const char kGoogExperimentalAutoGainControl[];
40 static const char kGoogNoiseSuppression[];
41 static const char kGoogExperimentalNoiseSuppression[];
42 static const char kGoogHighpassFilter[];
43 static const char kGoogTypingNoiseDetection[];
44 static const char kGoogAudioMirroring[];
38 45
39 // Checks if any audio constraints are set that requires audio processing to 46 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which
40 // be applied. |effects| is the bitmasks telling whether certain platform 47 // exists in both, the value from |constraints| is maintained, including its
41 // hardware audio effects are enabled, like hardware echo cancellation. If some 48 // mandatory/optional status. New values from |kDefaultAudioConstraints| will
42 // hardware effect is enabled, the corresponding software audio processing will 49 // be added with optional status.
43 // be disabled. 50 static void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints);
44 bool NeedsAudioProcessing(const blink::WebMediaConstraints& constraints,
45 int effects);
46 51
47 // Gets the property named by |key| from the |constraints|. 52 // |effects| is the bitmasks telling whether certain platform
48 // Returns true if the key is found and has a valid boolean value; Otherwise 53 // hardware audio effects are enabled, like hardware echo cancellation. If
49 // false. 54 // some hardware effect is enabled, the corresponding software audio
50 bool GetPropertyFromConstraints( 55 // processing will be disabled.
51 const MediaConstraintsInterface* constraints, 56 MediaAudioConstraints(const blink::WebMediaConstraints& constraints,
52 const std::string& key); 57 int effects);
58 virtual ~MediaAudioConstraints();
59
60 // Checks if any audio constraints are set that requires audio processing to
61 // be applied.
62 bool NeedsAudioProcessing();
63
64 // Gets the property of the constraint named by |key| in |constraints_|.
65 // Returns the constraint's value if the key is found; Otherwise returns the
66 // default value of the constraint.
67 // Note, for constraint of |kEchoCancellation| or |kGoogEchoCancellation|,
68 // clients should use GetEchoCancellationProperty().
69 bool GetProperty(const std::string& key);
70
71 // Gets the property of |kEchoCancellation| or |kGoogEchoCancellation|
72 // in |constraints_|. For |kGoogEchoCancellation|, the returned value will
73 // be depending on a combination of |effects_|, |kEchoCancellation| and
74 // |kGoogEchoCancellation| in |constraints_|.
75 bool GetEchoCancellationProperty(const std::string& key);
76
77 // Returns true if all the mandatory constraints in |constraints_| are valid;
78 // Otherwise return false.
79 bool IsValid();
80
81 private:
82 const blink::WebMediaConstraints constraints_;
83 const int effects_;
84 };
53 85
54 // Enables the echo cancellation in |audio_processing|. 86 // Enables the echo cancellation in |audio_processing|.
55 void EnableEchoCancellation(AudioProcessing* audio_processing); 87 void EnableEchoCancellation(AudioProcessing* audio_processing);
56 88
57 // Enables the noise suppression in |audio_processing|. 89 // Enables the noise suppression in |audio_processing|.
58 void EnableNoiseSuppression(AudioProcessing* audio_processing); 90 void EnableNoiseSuppression(AudioProcessing* audio_processing);
59 91
60 // Enables the experimental noise suppression in |audio_processing|. 92 // Enables the experimental noise suppression in |audio_processing|.
61 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing); 93 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing);
62 94
63 // Enables the high pass filter in |audio_processing|. 95 // Enables the high pass filter in |audio_processing|.
64 void EnableHighPassFilter(AudioProcessing* audio_processing); 96 void EnableHighPassFilter(AudioProcessing* audio_processing);
65 97
66 // Enables the typing detection in |audio_processing|. 98 // Enables the typing detection in |audio_processing|.
67 void EnableTypingDetection(AudioProcessing* audio_processing, 99 void EnableTypingDetection(AudioProcessing* audio_processing,
68 webrtc::TypingDetection* typing_detector); 100 webrtc::TypingDetection* typing_detector);
69 101
70 // Enables the experimental echo cancellation in |audio_processing|. 102 // Enables the experimental echo cancellation in |audio_processing|.
71 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing); 103 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing);
72 104
73 // Starts the echo cancellation dump in |audio_processing|. 105 // Starts the echo cancellation dump in |audio_processing|.
74 void StartEchoCancellationDump(AudioProcessing* audio_processing, 106 void StartEchoCancellationDump(AudioProcessing* audio_processing,
75 const base::PlatformFile& aec_dump_file); 107 const base::PlatformFile& aec_dump_file);
76 108
77 // Stops the echo cancellation dump in |audio_processing|. 109 // Stops the echo cancellation dump in |audio_processing|.
78 // This method has no impact if echo cancellation dump has not been started on 110 // This method has no impact if echo cancellation dump has not been started on
79 // |audio_processing|. 111 // |audio_processing|.
80 void StopEchoCancellationDump(AudioProcessing* audio_processing); 112 void StopEchoCancellationDump(AudioProcessing* audio_processing);
81 113
82 void EnableAutomaticGainControl(AudioProcessing* audio_processing); 114 void EnableAutomaticGainControl(AudioProcessing* audio_processing);
83 115
84 void GetAecStats(AudioProcessing* audio_processing, 116 void GetAecStats(AudioProcessing* audio_processing,
85 webrtc::AudioProcessorInterface::AudioProcessorStats* stats); 117 webrtc::AudioProcessorInterface::AudioProcessorStats* stats);
86 118
87 } // namespace content 119 } // namespace content
88 120
89 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ 121 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698