OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_RENDERER_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
| 6 #define CONTENT_RENDERER_RENDERER_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "media/filters/audio_renderer_sink.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide
r.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" |
| 13 |
| 14 // RenderAudioSourceProvider provides a bridge between classes: |
| 15 // WebKit::WebAudioSourceProvider <---> media::AudioRendererSink |
| 16 // |
| 17 // The idea is that some code within WebKit periodically calls provideInput() |
| 18 // to render a certain number of audio sample-frames. provideInput() |
| 19 // uses its callback to get this data, and then massages it into the form |
| 20 // required by provideInput(). |
| 21 |
| 22 class RenderAudioSourceProvider |
| 23 : public WebKit::WebAudioSourceProvider, |
| 24 public media::AudioRendererSink { |
| 25 public: |
| 26 RenderAudioSourceProvider(media::AudioRendererSink::RenderCallback* callback); |
| 27 virtual ~RenderAudioSourceProvider() { } |
| 28 |
| 29 // WebKit::WebAudioSourceProvider implementation. |
| 30 // WebKit calls this to get the rendered audio stream. |
| 31 virtual void provideInput(const WebKit::WebVector<float*>& audio_data, |
| 32 size_t number_of_frames); |
| 33 |
| 34 // AudioSink implementation. |
| 35 virtual bool Start(); |
| 36 virtual bool Stop(); |
| 37 virtual bool SetVolume(double volume); |
| 38 |
| 39 private: |
| 40 bool is_running_; |
| 41 double volume_; |
| 42 media::AudioRendererSink::RenderCallback* callback_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(RenderAudioSourceProvider); |
| 45 }; |
| 46 |
| 47 #endif // CONTENT_RENDERER_RENDERER_WEBAUDIOSOURCEPROVIDER_IMPL_H_ |
OLD | NEW |