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

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

Powered by Google App Engine
This is Rietveld 408576698