Chromium Code Reviews| 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_RENDER_AUDIOSOURCEPROVIDER_H_ | |
| 6 #define CONTENT_RENDERER_RENDER_AUDIOSOURCEPROVIDER_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/platform/WebVector.h" | |
| 13 | |
| 14 // RenderAudioSourceProvider provides a bridge between classes: | |
| 15 // WebKit::WebAudioSourceProvider <---> media::AudioRendererSink | |
| 16 // | |
| 17 // WebKit periodically calls provideInput() | |
| 18 // to render a certain number of audio sample-frames. provideInput() | |
| 19 // uses the renderer to get this data, and then massages it into the form | |
| 20 // required by provideInput(). | |
| 21 | |
| 22 namespace WebKit { | |
| 23 class WebAudioSourceProviderClient; | |
| 24 } | |
| 25 | |
| 26 class RenderAudioSourceProvider | |
| 27 : public WebKit::WebAudioSourceProvider, | |
| 28 public media::AudioRendererSink { | |
| 29 public: | |
| 30 explicit RenderAudioSourceProvider( | |
| 31 media::AudioRendererSink::RenderCallback* callback); | |
| 32 virtual ~RenderAudioSourceProvider() { } | |
|
tommi (sloooow) - chröme
2011/12/19 15:26:24
{}
Chris Rogers
2011/12/19 21:40:35
Done.
| |
| 33 | |
| 34 // WebKit::WebAudioSourceProvider implementation. | |
| 35 | |
| 36 // WebKit calls setClient() if it desires to take control of the rendered | |
| 37 // audio stream. We call client's setFormat() when the audio stream format | |
| 38 // is known. | |
| 39 virtual void setClient(WebKit::WebAudioSourceProviderClient* client); | |
| 40 | |
| 41 // If setClient() has been called, then WebKit calls provideInput() | |
| 42 // periodically to get the rendered audio stream. | |
| 43 virtual void provideInput(const WebKit::WebVector<float*>& audio_data, | |
| 44 size_t number_of_frames); | |
| 45 | |
| 46 // AudioRendererSink implementation. | |
| 47 virtual void Start() OVERRIDE; | |
| 48 virtual void Stop() OVERRIDE; | |
| 49 virtual void Play() OVERRIDE; | |
| 50 virtual void Pause(bool flush) OVERRIDE; | |
| 51 virtual bool SetVolume(double volume) OVERRIDE; | |
| 52 virtual void Initialize(size_t buffer_size, | |
| 53 int channels, | |
| 54 double sample_rate, | |
| 55 AudioParameters::Format latency_format, | |
| 56 RenderCallback* renderer) OVERRIDE; | |
| 57 | |
| 58 private: | |
| 59 bool is_running_; | |
| 60 double volume_; | |
| 61 media::AudioRendererSink::RenderCallback* renderer_; | |
| 62 WebKit::WebAudioSourceProviderClient* client_; | |
| 63 | |
| 64 DISALLOW_COPY_AND_ASSIGN(RenderAudioSourceProvider); | |
| 65 }; | |
| 66 | |
| 67 #endif // CONTENT_RENDERER_RENDER_AUDIOSOURCEPROVIDER_H_ | |
| OLD | NEW |