Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: remoting/host/audio_capturer_win.h

Issue 2840773004: [Chromoting] Add AudioVolumeApplier to reduce the complexity and the dependency of kChannels (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
10 #include <mmdeviceapi.h> 9 #include <mmdeviceapi.h>
11 10
12 #include <memory> 11 #include <memory>
13 12
14 #include "base/macros.h" 13 #include "base/macros.h"
15 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
16 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
17 #include "base/win/scoped_co_mem.h" 16 #include "base/win/scoped_co_mem.h"
18 #include "base/win/scoped_comptr.h" 17 #include "base/win/scoped_comptr.h"
19 #include "remoting/host/audio_capturer.h" 18 #include "remoting/host/audio_capturer.h"
20 #include "remoting/host/audio_silence_detector.h" 19 #include "remoting/host/win/audio_volume_applier_win.h"
21 #include "remoting/proto/audio.pb.h" 20 #include "remoting/proto/audio.pb.h"
22 21
23 namespace remoting { 22 namespace remoting {
24 23
25 class DefaultAudioDeviceChangeDetector; 24 class DefaultAudioDeviceChangeDetector;
26 25
27 class AudioCapturerWin : public AudioCapturer { 26 class AudioCapturerWin : public AudioCapturer {
28 public: 27 public:
29 AudioCapturerWin(); 28 AudioCapturerWin();
30 ~AudioCapturerWin() override; 29 ~AudioCapturerWin() override;
(...skipping 18 matching lines...) Expand all
49 48
50 // Whether all components are correctly initialized. If last 49 // Whether all components are correctly initialized. If last
51 // Initialize() function call failed, this function will return false. 50 // Initialize() function call failed, this function will return false.
52 // Otherwise this function will return true. 51 // Otherwise this function will return true.
53 bool is_initialized() const; 52 bool is_initialized() const;
54 53
55 // Receives all packets from the audio capture endpoint buffer and pushes them 54 // Receives all packets from the audio capture endpoint buffer and pushes them
56 // to the network. 55 // to the network.
57 void DoCapture(); 56 void DoCapture();
58 57
59 // Returns current volume setting of the host, in range [0.0, 1.0]. If the
60 // audio has been muted, this function returns 0. If Windows API returns error
61 // (such as audio device has been disabled or unpluged), this function ignores
62 // host volume setting, and returns 1.0.
63 float GetAudioLevel();
64
65 // Processes a series of samples, and executes callback if the packet is
66 // qualified to be sent to client.
67 void ProcessSamples(uint8_t* data, size_t frames);
68
69 PacketCapturedCallback callback_; 58 PacketCapturedCallback callback_;
70 59
71 AudioPacket::SamplingRate sampling_rate_; 60 AudioPacket::SamplingRate sampling_rate_;
72 61
73 std::unique_ptr<base::RepeatingTimer> capture_timer_; 62 std::unique_ptr<base::RepeatingTimer> capture_timer_;
74 base::TimeDelta audio_device_period_; 63 base::TimeDelta audio_device_period_;
75 64
76 AudioSilenceDetector silence_detector_; 65 AudioVolumeApplierWin volume_applier_;
77 66
78 base::win::ScopedCoMem<WAVEFORMATEX> wave_format_ex_; 67 base::win::ScopedCoMem<WAVEFORMATEX> wave_format_ex_;
79 base::win::ScopedComPtr<IAudioCaptureClient> audio_capture_client_; 68 base::win::ScopedComPtr<IAudioCaptureClient> audio_capture_client_;
80 base::win::ScopedComPtr<IAudioClient> audio_client_; 69 base::win::ScopedComPtr<IAudioClient> audio_client_;
81 base::win::ScopedComPtr<IMMDevice> mm_device_; 70 base::win::ScopedComPtr<IMMDevice> mm_device_;
82 base::win::ScopedComPtr<IAudioEndpointVolume> audio_volume_;
83 71
84 std::unique_ptr<DefaultAudioDeviceChangeDetector> default_device_detector_; 72 std::unique_ptr<DefaultAudioDeviceChangeDetector> default_device_detector_;
85 73
86 HRESULT last_capture_error_; 74 HRESULT last_capture_error_;
87 75
88 base::ThreadChecker thread_checker_; 76 base::ThreadChecker thread_checker_;
89 77
90 DISALLOW_COPY_AND_ASSIGN(AudioCapturerWin); 78 DISALLOW_COPY_AND_ASSIGN(AudioCapturerWin);
91 }; 79 };
92 80
93 } // namespace remoting 81 } // namespace remoting
94 82
95 #endif // REMOTING_HOST_AUDIO_CAPTURER_WIN_H_ 83 #endif // REMOTING_HOST_AUDIO_CAPTURER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698