Chromium Code Reviews| Index: remoting/host/audio_volume_applier.h |
| diff --git a/remoting/host/audio_volume_applier.h b/remoting/host/audio_volume_applier.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..049d12a668c3af553a0f0aebae706283a4fd3ddc |
| --- /dev/null |
| +++ b/remoting/host/audio_volume_applier.h |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef REMOTING_HOST_AUDIO_VOLUME_APPLIER_H_ |
| +#define REMOTING_HOST_AUDIO_VOLUME_APPLIER_H_ |
| + |
| +#include "remoting/host/audio_silence_detector.h" |
| + |
| +namespace remoting { |
| + |
| +// A component to modify input audio sample to apply the audio level. This class |
| +// is used on platforms which returns non-adjusted audio samples, e.g. Windows. |
| +// This class supports frames with 16 bits per sample only. |
| +class AudioVolumeApplier { |
|
Sergey Ulanov
2017/04/26 19:57:35
AudioVolumeFilter?
Sergey Ulanov
2017/04/26 19:57:36
What's the plan to integrate this class with downm
Hzj_jie
2017/04/28 03:53:34
Done.
Hzj_jie
2017/04/28 03:53:34
IMO, downmixer should be placed out of AudioCaptur
|
| + public: |
| + // See AudioSilenceDetector for the meaning of |silence_threshold|. |
| + explicit AudioVolumeApplier(int silence_threshold); |
| + virtual ~AudioVolumeApplier(); |
| + |
| + // Adjusts audio samples in |data|. If the samples are silent before or after |
| + // applying the volume level, this function returns false. If |frames| is 0, |
| + // this function also returns false. |
| + bool Apply(int16_t* data, size_t frames); |
| + |
| + // Updates the sampling rate and channels. |
| + void Initialize(int sampling_rate, int channels); |
| + |
| + protected: |
| + // Returns the volume level in [0, 1]. |
| + virtual float GetAudioLevel() = 0; |
| + |
| + private: |
| + bool ApplyVolumeLevel(int16_t* data, size_t frames); |
| + |
| + AudioSilenceDetector silence_detector_before_; |
| + AudioSilenceDetector silence_detector_after_; |
| +}; |
| + |
| +} // namespace remoting |
| + |
| +#endif // REMOTING_HOST_AUDIO_VOLUME_APPLIER_H_ |