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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_
10 #include "base/files/file.h"
11 #include "content/common/content_export.h"
12 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
18 class AudioProcessing
;
19 class MediaConstraintsInterface
;
20 class TypingDetection
;
26 class RTCMediaConstraints
;
28 using webrtc::AudioProcessing
;
29 using webrtc::MediaConstraintsInterface
;
31 // A helper class to parse audio constraints from a blink::WebMediaConstraints
33 class CONTENT_EXPORT MediaAudioConstraints
{
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
[];
47 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which
48 // exists in both, the value from |constraints| is maintained, including its
49 // mandatory/optional status. New values from |kDefaultAudioConstraints| will
50 // be added with optional status.
51 static void ApplyFixedAudioConstraints(RTCMediaConstraints
* constraints
);
53 // |effects| is the bitmasks telling whether certain platform
54 // hardware audio effects are enabled, like hardware echo cancellation. If
55 // some hardware effect is enabled, the corresponding software audio
56 // processing will be disabled.
57 MediaAudioConstraints(const blink::WebMediaConstraints
& constraints
,
59 virtual ~MediaAudioConstraints();
61 // Checks if any audio constraints are set that requires audio processing to
63 bool NeedsAudioProcessing();
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
);
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();
77 // Returns true if all the mandatory constraints in |constraints_| are valid;
78 // Otherwise return false.
82 // Gets the default value of constraint named by |key| in |constraints|.
83 bool GetDefaultValueForConstraint(
84 const blink::WebMediaConstraints
& constraints
, const std::string
& key
);
86 const blink::WebMediaConstraints constraints_
;
88 bool default_audio_processing_constraint_value_
;
91 // Enables the echo cancellation in |audio_processing|.
92 void EnableEchoCancellation(AudioProcessing
* audio_processing
);
94 // Enables the noise suppression in |audio_processing|.
95 void EnableNoiseSuppression(AudioProcessing
* audio_processing
);
97 // Enables the high pass filter in |audio_processing|.
98 void EnableHighPassFilter(AudioProcessing
* audio_processing
);
100 // Enables the typing detection in |audio_processing|.
101 void EnableTypingDetection(AudioProcessing
* audio_processing
,
102 webrtc::TypingDetection
* typing_detector
);
104 // Starts the echo cancellation dump in |audio_processing|.
105 void StartEchoCancellationDump(AudioProcessing
* audio_processing
,
106 base::File aec_dump_file
);
108 // Stops the echo cancellation dump in |audio_processing|.
109 // This method has no impact if echo cancellation dump has not been started on
110 // |audio_processing|.
111 void StopEchoCancellationDump(AudioProcessing
* audio_processing
);
113 void EnableAutomaticGainControl(AudioProcessing
* audio_processing
);
115 void GetAecStats(AudioProcessing
* audio_processing
,
116 webrtc::AudioProcessorInterface::AudioProcessorStats
* stats
);
118 } // namespace content
120 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_