| 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/weak_ptr.h" | 
 |  10 #include "base/threading/thread_checker.h" | 
 |  11 #include "content/common/content_export.h" | 
 |  12 #include "content/renderer/media/media_stream_audio_source.h" | 
 |  13  | 
 |  14 namespace blink { | 
 |  15 class WebMediaPlayer; | 
 |  16 }  // namespace blink | 
 |  17  | 
 |  18 namespace media { | 
 |  19 class AudioBus; | 
 |  20 class WebAudioSourceProviderImpl; | 
 |  21 }  // namespace media | 
 |  22  | 
 |  23 namespace content { | 
 |  24  | 
 |  25 // This class is a MediaStreamAudioSource that registers to the constructor- | 
 |  26 // passed weak WebAudioSourceProviderImpl to receive a copy of the audio data | 
 |  27 // intended for rendering. This copied data is received on OnAudioBus() and sent | 
 |  28 // to all the registered Tracks. | 
 |  29 class CONTENT_EXPORT HtmlAudioElementCapturerSource final | 
 |  30     : NON_EXPORTED_BASE(public MediaStreamAudioSource) { | 
 |  31  public: | 
 |  32   static HtmlAudioElementCapturerSource* | 
 |  33   CreateFromWebMediaPlayerImpl(blink::WebMediaPlayer* player); | 
 |  34  | 
 |  35   explicit HtmlAudioElementCapturerSource( | 
 |  36       media::WebAudioSourceProviderImpl* audio_source); | 
 |  37   ~HtmlAudioElementCapturerSource() override; | 
 |  38  | 
 |  39  private: | 
 |  40   // MediaStreamAudioSource implementation. | 
 |  41   bool EnsureSourceIsStarted() final; | 
 |  42   void EnsureSourceIsStopped() final; | 
 |  43  | 
 |  44   // To act as an WebAudioSourceProviderImpl::CopyAudioCB. | 
 |  45   void OnAudioBus(std::unique_ptr<media::AudioBus> audio_bus, | 
 |  46                   uint32_t delay_milliseconds, | 
 |  47                   int sample_rate); | 
 |  48  | 
 |  49   scoped_refptr<media::WebAudioSourceProviderImpl> audio_source_; | 
 |  50  | 
 |  51   bool is_started_; | 
 |  52   int last_sample_rate_; | 
 |  53   int last_num_channels_; | 
 |  54   int last_bus_frames_; | 
 |  55  | 
 |  56   base::ThreadChecker thread_checker_; | 
 |  57  | 
 |  58   DISALLOW_COPY_AND_ASSIGN(HtmlAudioElementCapturerSource); | 
 |  59 }; | 
 |  60  | 
 |  61 }  // namespace content | 
 |  62  | 
 |  63 #endif  // CONTENT_RENDERER_MEDIA_HTML_AUDIO_ELEMENT_CAPTURER_SOURCE_H_ | 
| OLD | NEW |