Enable right clicking on the applist doodle web contents and log the data.
[chromium-blink-merge.git] / content / renderer / media / media_stream_audio_processor_options.h
blobc942c41fe2d6490006dded469c8d33c0df695faf
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_
8 #include <string>
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"
15 namespace webrtc {
17 class AudioFrame;
18 class AudioProcessing;
19 class EchoCancellation;
20 class MediaConstraintsInterface;
21 class TypingDetection;
25 namespace content {
27 class RTCMediaConstraints;
29 using webrtc::AudioProcessing;
30 using webrtc::MediaConstraintsInterface;
32 // A helper class to parse audio constraints from a blink::WebMediaConstraints
33 // object.
34 class CONTENT_EXPORT MediaAudioConstraints {
35 public:
36 // Constraint keys used by audio processing.
37 static const char kEchoCancellation[];
38 static const char kGoogEchoCancellation[];
39 static const char kGoogExperimentalEchoCancellation[];
40 static const char kGoogAutoGainControl[];
41 static const char kGoogExperimentalAutoGainControl[];
42 static const char kGoogNoiseSuppression[];
43 static const char kGoogExperimentalNoiseSuppression[];
44 static const char kGoogBeamforming[];
45 static const char kGoogHighpassFilter[];
46 static const char kGoogTypingNoiseDetection[];
47 static const char kGoogAudioMirroring[];
49 // Merge |constraints| with |kDefaultAudioConstraints|. For any key which
50 // exists in both, the value from |constraints| is maintained, including its
51 // mandatory/optional status. New values from |kDefaultAudioConstraints| will
52 // be added with optional status.
53 static void ApplyFixedAudioConstraints(RTCMediaConstraints* constraints);
55 // |effects| is the bitmasks telling whether certain platform
56 // hardware audio effects are enabled, like hardware echo cancellation. If
57 // some hardware effect is enabled, the corresponding software audio
58 // processing will be disabled.
59 MediaAudioConstraints(const blink::WebMediaConstraints& constraints,
60 int effects);
61 virtual ~MediaAudioConstraints();
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 // Note, for constraint of |kEchoCancellation| or |kGoogEchoCancellation|,
67 // clients should use GetEchoCancellationProperty().
68 bool GetProperty(const std::string& key);
70 // Gets the property of echo cancellation defined in |constraints_|. The
71 // returned value depends on a combination of |effects_|, |kEchoCancellation|
72 // and |kGoogEchoCancellation| in |constraints_|.
73 bool GetEchoCancellationProperty();
75 // Returns true if all the mandatory constraints in |constraints_| are valid;
76 // Otherwise return false.
77 bool IsValid();
79 private:
80 // Gets the default value of constraint named by |key| in |constraints|.
81 bool GetDefaultValueForConstraint(
82 const blink::WebMediaConstraints& constraints, const std::string& key);
84 const blink::WebMediaConstraints constraints_;
85 const int effects_;
86 bool default_audio_processing_constraint_value_;
89 // A helper class to log echo information in general and Echo Cancellation
90 // quality in particular.
91 class CONTENT_EXPORT EchoInformation {
92 public:
93 EchoInformation();
94 virtual ~EchoInformation();
96 void UpdateAecDelayStats(webrtc::EchoCancellation* echo_cancellation);
98 private:
99 // Updates UMA histograms with an interval of 5 seconds.
100 void LogAecDelayStats();
102 // Counters to be able to aquire a 5 second aggregated metric out of 1 second
103 // aggregated webrtc::EchoCancellation::GetEchoDelayMetrics() queries.
104 int num_chunks_;
105 int num_queries_;
106 float echo_fraction_poor_delays_;
108 DISALLOW_COPY_AND_ASSIGN(EchoInformation);
111 // Enables the echo cancellation in |audio_processing|.
112 void EnableEchoCancellation(AudioProcessing* audio_processing);
114 // Enables the noise suppression in |audio_processing|.
115 void EnableNoiseSuppression(AudioProcessing* audio_processing);
117 // Enables the high pass filter in |audio_processing|.
118 void EnableHighPassFilter(AudioProcessing* audio_processing);
120 // Enables the typing detection in |audio_processing|.
121 void EnableTypingDetection(AudioProcessing* audio_processing,
122 webrtc::TypingDetection* typing_detector);
124 // Starts the echo cancellation dump in |audio_processing|.
125 void StartEchoCancellationDump(AudioProcessing* audio_processing,
126 base::File aec_dump_file);
128 // Stops the echo cancellation dump in |audio_processing|.
129 // This method has no impact if echo cancellation dump has not been started on
130 // |audio_processing|.
131 void StopEchoCancellationDump(AudioProcessing* audio_processing);
133 void EnableAutomaticGainControl(AudioProcessing* audio_processing);
135 void GetAecStats(webrtc::EchoCancellation* echo_cancellation,
136 webrtc::AudioProcessorInterface::AudioProcessorStats* stats);
138 } // namespace content
140 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_