OLD | NEW |
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 // Note, for constraint of |kGoogEchoCancellation|, clients should use |
| 68 // GetEchoCancellationProperty(). |
| 69 bool GetProperty(const std::string& key); |
| 70 |
| 71 // Gets the property of |kGoogEchoCancellation| in |constraints_|. |
| 72 // The returned value will be depending on a combination of |effects_|, |
| 73 // |kEchoCancellation| and |kGoogEchoCancellation| in |constraints_|. |
| 74 bool GetEchoCancellationProperty(); |
| 75 |
| 76 // Returns true if all the mandatory constraints in |constraints_| are valid; |
| 77 // Otherwise return false. |
| 78 bool IsValid(); |
| 79 |
| 80 private: |
| 81 const blink::WebMediaConstraints constraints_; |
| 82 const int effects_; |
| 83 }; |
53 | 84 |
54 // Enables the echo cancellation in |audio_processing|. | 85 // Enables the echo cancellation in |audio_processing|. |
55 void EnableEchoCancellation(AudioProcessing* audio_processing); | 86 void EnableEchoCancellation(AudioProcessing* audio_processing); |
56 | 87 |
57 // Enables the noise suppression in |audio_processing|. | 88 // Enables the noise suppression in |audio_processing|. |
58 void EnableNoiseSuppression(AudioProcessing* audio_processing); | 89 void EnableNoiseSuppression(AudioProcessing* audio_processing); |
59 | 90 |
60 // Enables the experimental noise suppression in |audio_processing|. | 91 // Enables the experimental noise suppression in |audio_processing|. |
61 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing); | 92 void EnableExperimentalNoiseSuppression(AudioProcessing* audio_processing); |
62 | 93 |
63 // Enables the high pass filter in |audio_processing|. | 94 // Enables the high pass filter in |audio_processing|. |
64 void EnableHighPassFilter(AudioProcessing* audio_processing); | 95 void EnableHighPassFilter(AudioProcessing* audio_processing); |
65 | 96 |
66 // Enables the typing detection in |audio_processing|. | 97 // Enables the typing detection in |audio_processing|. |
67 void EnableTypingDetection(AudioProcessing* audio_processing, | 98 void EnableTypingDetection(AudioProcessing* audio_processing, |
68 webrtc::TypingDetection* typing_detector); | 99 webrtc::TypingDetection* typing_detector); |
69 | 100 |
70 // Enables the experimental echo cancellation in |audio_processing|. | 101 // Enables the experimental echo cancellation in |audio_processing|. |
71 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing); | 102 void EnableExperimentalEchoCancellation(AudioProcessing* audio_processing); |
72 | 103 |
73 // Starts the echo cancellation dump in |audio_processing|. | 104 // Starts the echo cancellation dump in |audio_processing|. |
74 void StartEchoCancellationDump(AudioProcessing* audio_processing, | 105 void StartEchoCancellationDump(AudioProcessing* audio_processing, |
75 const base::PlatformFile& aec_dump_file); | 106 const base::PlatformFile& aec_dump_file); |
76 | 107 |
77 // Stops the echo cancellation dump in |audio_processing|. | 108 // Stops the echo cancellation dump in |audio_processing|. |
78 // This method has no impact if echo cancellation dump has not been started on | 109 // This method has no impact if echo cancellation dump has not been started on |
79 // |audio_processing|. | 110 // |audio_processing|. |
80 void StopEchoCancellationDump(AudioProcessing* audio_processing); | 111 void StopEchoCancellationDump(AudioProcessing* audio_processing); |
81 | 112 |
82 void EnableAutomaticGainControl(AudioProcessing* audio_processing); | 113 void EnableAutomaticGainControl(AudioProcessing* audio_processing); |
83 | 114 |
84 void GetAecStats(AudioProcessing* audio_processing, | 115 void GetAecStats(AudioProcessing* audio_processing, |
85 webrtc::AudioProcessorInterface::AudioProcessorStats* stats); | 116 webrtc::AudioProcessorInterface::AudioProcessorStats* stats); |
86 | 117 |
87 } // namespace content | 118 } // namespace content |
88 | 119 |
89 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ | 120 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_AUDIO_PROCESSOR_OPTIONS_H_ |
OLD | NEW |