1 // Copyright 2017 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.
4 
5 #ifndef REMOTING_HOST_WIN_AUDIO_VOLUME_FILTER_WIN_H_
6 #define REMOTING_HOST_WIN_AUDIO_VOLUME_FILTER_WIN_H_
7 
8 #include <endpointvolume.h>
9 #include <mmdeviceapi.h>
10 #include <wrl/client.h>
11 
12 #include "remoting/host/audio_volume_filter.h"
13 
14 namespace remoting {
15 
16 // An implementation of AudioVolumeFilter for Windows only.
17 class AudioVolumeFilterWin : public AudioVolumeFilter {
18  public:
19   explicit AudioVolumeFilterWin(int silence_threshold);
20   ~AudioVolumeFilterWin() override;
21 
22   // Initializes |audio_volume_|. Returns false if Windows APIs fail.
23   bool ActivateBy(IMMDevice* mm_device);
24 
25  protected:
26   // Returns current audio level from |audio_volume_|. If the initialization
27   // failed, this function returns 1.
28   float GetAudioLevel() override;
29 
30  private:
31   Microsoft::WRL::ComPtr<IAudioEndpointVolume> audio_volume_;
32 };
33 
34 }  // namespace remoting
35 
36 #endif  // REMOTING_HOST_WIN_AUDIO_VOLUME_FILTER_WIN_H_
37