Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ | 5 #ifndef REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ |
| 6 #define REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ | 6 #define REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ |
| 7 | 7 |
| 8 #include <audioclient.h> | 8 #include <audioclient.h> |
| 9 #include <endpointvolume.h> | 9 #include <endpointvolume.h> |
| 10 #include <mmdeviceapi.h> | 10 #include <mmdeviceapi.h> |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 class AudioCapturerWin : public AudioCapturer { | 25 class AudioCapturerWin : public AudioCapturer { |
| 26 public: | 26 public: |
| 27 AudioCapturerWin(); | 27 AudioCapturerWin(); |
| 28 ~AudioCapturerWin() override; | 28 ~AudioCapturerWin() override; |
| 29 | 29 |
| 30 // AudioCapturer interface. | 30 // AudioCapturer interface. |
| 31 bool Start(const PacketCapturedCallback& callback) override; | 31 bool Start(const PacketCapturedCallback& callback) override; |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 // The implementation of IMMNotificationClient, to set | |
| 35 // default_audio_device_changed_ in OnDefaultDeviceChanged function. | |
| 36 class MMNotificationClient; | |
| 37 friend class MMNotificationClient; | |
| 38 | |
| 39 // Initializes default audio device related components. These components must | |
| 40 // be recreated once the default audio device changed. Returns false if | |
| 41 // initialization failed. | |
| 42 bool Initialize(); | |
| 43 | |
| 34 // Receives all packets from the audio capture endpoint buffer and pushes them | 44 // Receives all packets from the audio capture endpoint buffer and pushes them |
| 35 // to the network. | 45 // to the network. |
| 36 void DoCapture(); | 46 void DoCapture(); |
| 37 | 47 |
| 38 // Returns current volume setting of the host, in range [0.0, 1.0]. If the | 48 // Returns current volume setting of the host, in range [0.0, 1.0]. If the |
| 39 // audio has been muted, this function returns 0. If Windows API returns error | 49 // audio has been muted, this function returns 0. If Windows API returns error |
| 40 // (such as audio device has been disabled or unpluged), this function ignores | 50 // (such as audio device has been disabled or unpluged), this function ignores |
| 41 // host volume setting, and returns 1.0. | 51 // host volume setting, and returns 1.0. |
| 42 float GetAudioLevel(); | 52 float GetAudioLevel(); |
| 43 | 53 |
| 44 // Processes a series of samples, and executes callback if the packet is | 54 // Processes a series of samples, and executes callback if the packet is |
| 45 // qualified to be sent to client. | 55 // qualified to be sent to client. |
| 46 void ProcessSamples(uint8_t* data, size_t frames); | 56 void ProcessSamples(uint8_t* data, size_t frames); |
| 47 | 57 |
| 48 PacketCapturedCallback callback_; | 58 PacketCapturedCallback callback_; |
| 49 | 59 |
| 50 AudioPacket::SamplingRate sampling_rate_; | 60 AudioPacket::SamplingRate sampling_rate_; |
| 51 | 61 |
| 52 std::unique_ptr<base::RepeatingTimer> capture_timer_; | 62 std::unique_ptr<base::RepeatingTimer> capture_timer_; |
| 53 base::TimeDelta audio_device_period_; | 63 base::TimeDelta audio_device_period_; |
| 54 | 64 |
| 55 AudioSilenceDetector silence_detector_; | 65 AudioSilenceDetector silence_detector_; |
| 56 | 66 |
| 57 base::win::ScopedCoMem<WAVEFORMATEX> wave_format_ex_; | 67 base::win::ScopedCoMem<WAVEFORMATEX> wave_format_ex_; |
| 68 base::win::ScopedComPtr<IMMDeviceEnumerator> mm_device_enumerator_; | |
| 58 base::win::ScopedComPtr<IAudioCaptureClient> audio_capture_client_; | 69 base::win::ScopedComPtr<IAudioCaptureClient> audio_capture_client_; |
| 59 base::win::ScopedComPtr<IAudioClient> audio_client_; | 70 base::win::ScopedComPtr<IAudioClient> audio_client_; |
| 60 base::win::ScopedComPtr<IMMDevice> mm_device_; | 71 base::win::ScopedComPtr<IMMDevice> mm_device_; |
| 61 base::win::ScopedComPtr<IAudioEndpointVolume> audio_volume_; | 72 base::win::ScopedComPtr<IAudioEndpointVolume> audio_volume_; |
| 62 | 73 |
| 74 // Whether the default audio device has been changed recently. If this value | |
| 75 // is true, we need to recreate all audio components; | |
| 76 bool default_audio_device_changed_; | |
|
Sergey Ulanov
2016/07/18 23:09:24
= false;
Hzj_jie
2016/07/19 02:36:40
Done.
| |
| 77 const std::unique_ptr<MMNotificationClient> notificator_; | |
| 78 | |
| 63 HRESULT last_capture_error_; | 79 HRESULT last_capture_error_; |
| 64 | 80 |
| 65 base::ThreadChecker thread_checker_; | 81 base::ThreadChecker thread_checker_; |
| 66 | 82 |
| 67 DISALLOW_COPY_AND_ASSIGN(AudioCapturerWin); | 83 DISALLOW_COPY_AND_ASSIGN(AudioCapturerWin); |
| 68 }; | 84 }; |
| 69 | 85 |
| 70 } // namespace remoting | 86 } // namespace remoting |
| 71 | 87 |
| 72 #endif // REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ | 88 #endif // REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ |
| OLD | NEW |