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

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 Per's comments. Created 6 years, 8 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 bool GetProperty(const std::string& key);
68
69 // Returns true if all the mandatory constraints in |constraints_| are valid;
70 // Otherwise return false.
71 bool IsValid();
72
73 private:
74 const blink::WebMediaConstraints constraints_;
75 const int effects_;
76 };
53 77
54 // Enables the echo cancellation in |audio_processing|. 78 // Enables the echo cancellation in |audio_processing|.
55 void EnableEchoCancellation(AudioProcessing* audio_processing); 79 void EnableEchoCancellation(AudioProcessing* audio_processing);
56 80
57 // Enables the noise suppression in |audio_processing|. 81 // Enables the noise suppression in |audio_processing|.
58 void EnableNoiseSuppression(AudioProcessing* audio_processing); 82 void EnableNoiseSuppression(AudioProcessing* audio_processing);
59 83
60 // Enables the experimental noise suppression in |audio_processing|. 84 // Enables the experimental noise suppression in |audio_processing|.
61 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing); 85 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing);
62 86
63 // Enables the high pass filter in |audio_processing|. 87 // Enables the high pass filter in |audio_processing|.
64 void EnableHighPassFilter(AudioProcessing* audio_processing); 88 void EnableHighPassFilter(AudioProcessing* audio_processing);
65 89
66 // Enables the typing detection in |audio_processing|. 90 // Enables the typing detection in |audio_processing|.
67 void EnableTypingDetection(AudioProcessing* audio_processing, 91 void EnableTypingDetection(AudioProcessing* audio_processing,
68 webrtc::TypingDetection* typing_detector); 92 webrtc::TypingDetection* typing_detector);
69 93
70 // Enables the experimental echo cancellation in |audio_processing|. 94 // Enables the experimental echo cancellation in |audio_processing|.
71 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing); 95 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing);
72 96
73 // Starts the echo cancellation dump in |audio_processing|. 97 // Starts the echo cancellation dump in |audio_processing|.
74 void StartEchoCancellationDump(AudioProcessing* audio_processing, 98 void StartEchoCancellationDump(AudioProcessing* audio_processing,
75 const base::PlatformFile& aec_dump_file); 99 const base::PlatformFile& aec_dump_file);
76 100
77 // Stops the echo cancellation dump in |audio_processing|. 101 // Stops the echo cancellation dump in |audio_processing|.
78 // This method has no impact if echo cancellation dump has not been started on 102 // This method has no impact if echo cancellation dump has not been started on
79 // |audio_processing|. 103 // |audio_processing|.
80 void StopEchoCancellationDump(AudioProcessing* audio_processing); 104 void StopEchoCancellationDump(AudioProcessing* audio_processing);
81 105
82 void EnableAutomaticGainControl(AudioProcessing* audio_processing); 106 void EnableAutomaticGainControl(AudioProcessing* audio_processing);
83 107
84 void GetAecStats(AudioProcessing* audio_processing, 108 void GetAecStats(AudioProcessing* audio_processing,
85 webrtc::AudioProcessorInterface::AudioProcessorStats* stats); 109 webrtc::AudioProcessorInterface::AudioProcessorStats* stats);
86 110
87 } // namespace content 111 } // namespace content
88 112
89 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ 113 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698