Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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 CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/single_thread_task_runner.h" | |
| 12 #include "base/threading/thread_checker.h" | |
| 13 #include "content/common/content_export.h" | |
| 14 #include "media/base/audio_capturer_source.h" | |
| 15 #include "media/base/audio_converter.h" | |
| 16 #include "media/blink/webaudiosourceprovider_impl.h" | |
| 17 | |
| 18 #if !defined(ENABLE_WEBRTC) | |
| 19 #error "Testing testing" | |
| 20 #endif | |
| 21 | |
| 22 namespace blink { | |
| 23 class WebMediaPlayer; | |
| 24 } // namespace blink | |
| 25 | |
| 26 namespace media { | |
| 27 class AudioBus; | |
| 28 class AudioFifo; | |
| 29 } // namespace media | |
| 30 | |
| 31 namespace content { | |
| 32 | |
| 33 // This class is an AudioCapturerSource registering to the constructor-passed | |
| 34 // weak WebAudioSourceProviderImpl to receive a copy of the audio data intended | |
| 35 // for rendering. This copied data is received on OnAudioBus(), converted and | |
| 36 // sent to |capture_callback_| | |
| 37 class CONTENT_EXPORT HtmlAudioElementCapturerSource final | |
| 38 : NON_EXPORTED_BASE(public media::AudioCapturerSource), | |
| 39 NON_EXPORTED_BASE(public media::AudioConverter::InputCallback) { | |
| 40 public: | |
| 41 static scoped_refptr<HtmlAudioElementCapturerSource> | |
| 42 CreateFromWebMediaPlayerImpl(blink::WebMediaPlayer* player); | |
| 43 | |
| 44 explicit HtmlAudioElementCapturerSource( | |
| 45 const base::WeakPtr<media::WebAudioSourceProviderImpl>& audio_source); | |
| 46 | |
| 47 // media::AudioCapturerSource Implementation. | |
| 48 void Initialize(const media::AudioParameters& params, | |
| 49 CaptureCallback* callback, | |
| 50 int session_id) override; | |
| 51 void Start() override; | |
| 52 void Stop() override; | |
| 53 void SetVolume(double volume) override; | |
| 54 void SetAutomaticGainControl(bool enable) override; | |
| 55 | |
| 56 // To act as an WebAudioSourceProviderImpl::CopyAudioCB. | |
| 57 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.
| |
| 58 uint32_t delay_milliseconds, | |
| 59 int sample_rate); | |
| 60 | |
| 61 // media::AudioConverted::InputCallback implementation. | |
| 62 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.
| |
| 63 base::TimeDelta buffer_delay) override; | |
| 64 | |
| 65 private: | |
| 66 ~HtmlAudioElementCapturerSource() override; | |
| 67 void CreateConverter(); | |
| 68 | |
| 69 const media::WebAudioSourceProviderImpl::CopyAudioCB audio_input_cb_; | |
| 70 | |
| 71 base::WeakPtr<media::WebAudioSourceProviderImpl> audio_source_; | |
| 72 | |
| 73 media::AudioParameters input_params_; // Format we see ingressing. | |
| 74 media::AudioParameters output_params_; // Format we need to egress. | |
| 75 | |
| 76 // Sampling rate adapter between |input_params_| and |output_params_|. | |
| 77 std::unique_ptr<media::AudioConverter> converter_; | |
| 78 std::unique_ptr<media::AudioFifo> fifo_; | |
| 79 int min_fifo_frames_for_conversion_; | |
| 80 | |
| 81 CaptureCallback* capture_callback_; | |
| 82 | |
| 83 base::ThreadChecker thread_checker_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(HtmlAudioElementCapturerSource); | |
| 86 }; | |
| 87 | |
| 88 } // namespace content | |
| 89 | |
| 90 #endif // CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ | |
| OLD | NEW |