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

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: moved some of the constraints code to MediaAudioConstraints class, and hope it makes the code more … 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 constraints for MediaStreamAudioProcessor.
34 // in both, the value from |constraints| is maintained, including its 31 class MediaAudioConstraints {
35 // mandatory/optional status. New values from |kDefaultAudioConstraints| will 32 public:
36 // be added with mandatory status. 33 // Constraint keys used by audio processing.
37 void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints); 34 static const char kEchoCancellation[];
35 static const char kGoogEchoCancellation[];
36 static const char kGoogExperimentalEchoCancellation[];
37 static const char kGoogAutoGainControl[];
38 static const char kGoogExperimentalAutoGainControl[];
39 static const char kGoogNoiseSuppression[];
40 static const char kGoogExperimentalNoiseSuppression[];
41 static const char kGoogHighpassFilter[];
42 static const char kGoogTypingNoiseDetection[];
43 static const char kGoogAudioMirroring[];
38 44
39 // Checks if any audio constraints are set that requires audio processing to 45 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which
40 // be applied. |effects| is the bitmasks telling whether certain platform 46 // exists in both, the value from |constraints| is maintained, including its
41 // hardware audio effects are enabled, like hardware echo cancellation. If some 47 // mandatory/optional status. New values from |kDefaultAudioConstraints| will
42 // hardware effect is enabled, the corresponding software audio processing will 48 // be added with optional status.
43 // be disabled. 49 static void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints);
44 bool NeedsAudioProcessing(const blink::WebMediaConstraints& constraints,
45 int effects);
46 50
47 // Gets the property named by |key| from the |constraints|. 51 // |effects| is the bitmasks telling whether certain platform
48 // Returns true if the key is found and has a valid boolean value; Otherwise 52 // hardware audio effects are enabled, like hardware echo cancellation. If
49 // false. 53 // some hardware effect is enabled, the corresponding software audio
50 bool GetPropertyFromConstraints( 54 // processing will be disabled.
51 const MediaConstraintsInterface* constraints, 55 MediaAudioConstraints(const blink::WebMediaConstraints& constraints,
52 const std::string& key); 56 int effects);
57 virtual ~MediaAudioConstraints();
58
59 // Checks if any audio constraints are set that requires audio processing to
60 // be applied.
61 bool NeedsAudioProcessing();
62
63 // Gets the property of the constraint named by |key| in |constraints_|.
64 // Returns the constraint's value if the key is found; Otherwise returns the
65 // default value of the constraint.
66 bool GetProperty(const std::string& key);
67
68 // Returns true if all the mandatory constraints in |constraints_| are valid;
69 // Otherwise return false.
70 bool IsValid();
71
72 private:
73 const blink::WebMediaConstraints constraints_;
74 const int effects_;
75 };
53 76
54 // Enables the echo cancellation in |audio_processing|. 77 // Enables the echo cancellation in |audio_processing|.
55 void EnableEchoCancellation(AudioProcessing* audio_processing); 78 void EnableEchoCancellation(AudioProcessing* audio_processing);
56 79
57 // Enables the noise suppression in |audio_processing|. 80 // Enables the noise suppression in |audio_processing|.
58 void EnableNoiseSuppression(AudioProcessing* audio_processing); 81 void EnableNoiseSuppression(AudioProcessing* audio_processing);
59 82
60 // Enables the experimental noise suppression in |audio_processing|. 83 // Enables the experimental noise suppression in |audio_processing|.
61 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing); 84 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing);
62 85
63 // Enables the high pass filter in |audio_processing|. 86 // Enables the high pass filter in |audio_processing|.
64 void EnableHighPassFilter(AudioProcessing* audio_processing); 87 void EnableHighPassFilter(AudioProcessing* audio_processing);
65 88
66 // Enables the typing detection in |audio_processing|. 89 // Enables the typing detection in |audio_processing|.
67 void EnableTypingDetection(AudioProcessing* audio_processing, 90 void EnableTypingDetection(AudioProcessing* audio_processing,
68 webrtc::TypingDetection* typing_detector); 91 webrtc::TypingDetection* typing_detector);
69 92
70 // Enables the experimental echo cancellation in |audio_processing|. 93 // Enables the experimental echo cancellation in |audio_processing|.
71 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing); 94 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing);
72 95
73 // Starts the echo cancellation dump in |audio_processing|. 96 // Starts the echo cancellation dump in |audio_processing|.
74 void StartEchoCancellationDump(AudioProcessing* audio_processing, 97 void StartEchoCancellationDump(AudioProcessing* audio_processing,
75 const base::PlatformFile& aec_dump_file); 98 const base::PlatformFile& aec_dump_file);
76 99
77 // Stops the echo cancellation dump in |audio_processing|. 100 // Stops the echo cancellation dump in |audio_processing|.
78 // This method has no impact if echo cancellation dump has not been started on 101 // This method has no impact if echo cancellation dump has not been started on
79 // |audio_processing|. 102 // |audio_processing|.
80 void StopEchoCancellationDump(AudioProcessing* audio_processing); 103 void StopEchoCancellationDump(AudioProcessing* audio_processing);
81 104
82 void EnableAutomaticGainControl(AudioProcessing* audio_processing); 105 void EnableAutomaticGainControl(AudioProcessing* audio_processing);
83 106
84 void GetAecStats(AudioProcessing* audio_processing, 107 void GetAecStats(AudioProcessing* audio_processing,
85 webrtc::AudioProcessorInterface::AudioProcessorStats* stats); 108 webrtc::AudioProcessorInterface::AudioProcessorStats* stats);
86 109
87 } // namespace content 110 } // namespace content
88 111
89 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ 112 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698