Chromium Code Reviews| Index: content/renderer/media/html_audio_element_capturer_source.h |
| diff --git a/content/renderer/media/html_audio_element_capturer_source.h b/content/renderer/media/html_audio_element_capturer_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb6ecac63af268ad83b7b6dadc4cc190d07666c8 |
| --- /dev/null |
| +++ b/content/renderer/media/html_audio_element_capturer_source.h |
| @@ -0,0 +1,90 @@ |
| +// Copyright 2016 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 CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ |
| +#define CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "content/common/content_export.h" |
| +#include "media/base/audio_capturer_source.h" |
| +#include "media/base/audio_converter.h" |
| +#include "media/blink/webaudiosourceprovider_impl.h" |
| + |
| +#if !defined(ENABLE_WEBRTC) |
| +#error "Testing testing" |
| +#endif |
| + |
| +namespace blink { |
| +class WebMediaPlayer; |
| +} // namespace blink |
| + |
| +namespace media { |
| +class AudioBus; |
| +class AudioFifo; |
| +} // namespace media |
| + |
| +namespace content { |
| + |
| +// This class is an AudioCapturerSource registering to the constructor-passed |
| +// weak WebAudioSourceProviderImpl to receive a copy of the audio data intended |
| +// for rendering. This copied data is received on OnAudioBus(), converted and |
| +// sent to |capture_callback_| |
| +class CONTENT_EXPORT HtmlAudioElementCapturerSource final |
| + : NON_EXPORTED_BASE(public media::AudioCapturerSource), |
| + NON_EXPORTED_BASE(public media::AudioConverter::InputCallback) { |
| + public: |
| + static scoped_refptr<HtmlAudioElementCapturerSource> |
| + CreateFromWebMediaPlayerImpl(blink::WebMediaPlayer* player); |
| + |
| + explicit HtmlAudioElementCapturerSource( |
| + const base::WeakPtr<media::WebAudioSourceProviderImpl>& audio_source); |
| + |
| + // media::AudioCapturerSource Implementation. |
| + void Initialize(const media::AudioParameters& params, |
| + CaptureCallback* callback, |
| + int session_id) override; |
| + void Start() override; |
| + void Stop() override; |
| + void SetVolume(double volume) override; |
| + void SetAutomaticGainControl(bool enable) override; |
| + |
| + // To act as an WebAudioSourceProviderImpl::CopyAudioCB. |
| + void OnAudioBus(std::unique_ptr<media::AudioBus> audio_bus, |
|
miu
2016/05/13 23:40:35
Seems like this should be a private method since i
mcasas
2016/05/14 02:23:47
Done.
|
| + uint32_t delay_milliseconds, |
| + int sample_rate); |
| + |
| + // media::AudioConverted::InputCallback implementation. |
| + double ProvideInput(media::AudioBus* audio_bus, |
|
miu
2016/05/13 23:40:35
Looks like this is for exclusive use by |converter
mcasas
2016/05/14 02:23:47
Done.
|
| + base::TimeDelta buffer_delay) override; |
| + |
| + private: |
| + ~HtmlAudioElementCapturerSource() override; |
| + void CreateConverter(); |
| + |
| + const media::WebAudioSourceProviderImpl::CopyAudioCB audio_input_cb_; |
| + |
| + base::WeakPtr<media::WebAudioSourceProviderImpl> audio_source_; |
| + |
| + media::AudioParameters input_params_; // Format we see ingressing. |
| + media::AudioParameters output_params_; // Format we need to egress. |
| + |
| + // Sampling rate adapter between |input_params_| and |output_params_|. |
| + std::unique_ptr<media::AudioConverter> converter_; |
| + std::unique_ptr<media::AudioFifo> fifo_; |
| + int min_fifo_frames_for_conversion_; |
| + |
| + CaptureCallback* capture_callback_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HtmlAudioElementCapturerSource); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ |