OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef WEBRTC_TOOLS_AGC_AGC_MANAGER_H_ | |
12 #define WEBRTC_TOOLS_AGC_AGC_MANAGER_H_ | |
13 | |
14 #include "webrtc/base/scoped_ptr.h" | |
15 #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h" | |
16 | |
17 namespace webrtc { | |
18 | |
19 class Agc; | |
20 class AudioProcessing; | |
21 class CriticalSectionWrapper; | |
22 class MediaCallback; | |
23 class PreprocCallback; | |
24 class VoEExternalMedia; | |
25 class VoEVolumeControl; | |
26 class VoiceEngine; | |
27 class VolumeCallbacks; | |
28 | |
29 // Handles the interaction between VoiceEngine and the internal AGC. It hooks | |
30 // into the capture stream through VoiceEngine's external media interface and | |
31 // sends the audio to the AGC for analysis. It forwards requests for a capture | |
32 // volume change from the AGC to the VoiceEngine volume interface. | |
33 class AgcManager { | |
34 public: | |
35 explicit AgcManager(VoiceEngine* voe); | |
36 // Dependency injection for testing. Don't delete |agc| or |audioproc| as the | |
37 // memory is owned by the manager. If |media| or |volume| are non-fake | |
38 // reference counted classes, don't release them as this is handled by the | |
39 // manager. | |
40 AgcManager(VoEExternalMedia* media, VoEVolumeControl* volume, Agc* agc, | |
41 AudioProcessing* audioproc); | |
42 virtual ~AgcManager(); | |
43 | |
44 // When enabled, registers external media processing callbacks with | |
45 // VoiceEngine to hook into the capture stream. Disabling deregisters the | |
46 // callbacks. | |
47 virtual int Enable(bool enable); | |
48 virtual bool enabled() const { return enabled_; } | |
49 | |
50 // Call when the capture device has changed. This will trigger a retrieval of | |
51 // the initial capture volume on the next audio frame. | |
52 virtual void CaptureDeviceChanged(); | |
53 | |
54 // Call when the capture stream has been muted/unmuted. This causes the | |
55 // manager to disregard all incoming audio; chances are good it's background | |
56 // noise to which we'd like to avoid adapting. | |
57 virtual void SetCaptureMuted(bool muted); | |
58 virtual bool capture_muted() const { return direct_->capture_muted(); } | |
59 | |
60 protected: | |
61 // Provide a default constructor for testing. | |
62 AgcManager(); | |
63 | |
64 private: | |
65 int DeregisterCallbacks(); | |
66 int CheckVolumeAndReset(); | |
67 | |
68 VoEExternalMedia* media_; | |
69 rtc::scoped_ptr<VolumeCallbacks> volume_callbacks_; | |
70 rtc::scoped_ptr<CriticalSectionWrapper> crit_; | |
71 rtc::scoped_ptr<AudioProcessing> audioproc_; | |
72 rtc::scoped_ptr<AgcManagerDirect> direct_; | |
73 rtc::scoped_ptr<MediaCallback> media_callback_; | |
74 rtc::scoped_ptr<PreprocCallback> preproc_callback_; | |
75 bool enabled_; | |
76 bool initialized_; | |
77 }; | |
78 | |
79 } // namespace webrtc | |
80 | |
81 #endif // WEBRTC_TOOLS_AGC_AGC_MANAGER_H_ | |
OLD | NEW |