Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: content/renderer/render_audiosourceprovider.h

Issue 8980008: Integrate HTMLMediaElement with Web Audio API's MediaElementAudioSourceNode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // RenderAudioSourceProvider provides a bridge between classes:
6 // WebKit::WebAudioSourceProvider <---> media::AudioRendererSink
7 //
8 // RenderAudioSourceProvider is a "sink" of audio, and uses a default
9 // AudioDevice if a client has not explicitly been set.
10 //
11 // WebKit optionally sets a client, and then periodically calls provideInput()
12 // to render a certain number of audio sample-frames. provideInput()
13 // uses the renderer to get this data, and then massages it into the form
14 // required by provideInput(). In this case, the default AudioDevice
15 // is no longer used.
16 //
17 // THREAD SAFETY:
18 // It is assumed that the callers to setClient() and provideInput()
19 // implement appropriate locking for thread safety when making
20 // these calls. This happens in WebKit.
21
22 #ifndef CONTENT_RENDERER_RENDER_AUDIOSOURCEPROVIDER_H_
23 #define CONTENT_RENDERER_RENDER_AUDIOSOURCEPROVIDER_H_
24
25 #include <vector>
26
27 #include "content/renderer/media/audio_device.h"
28 #include "media/base/audio_renderer_sink.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide r.h"
31
32 namespace WebKit {
33 class WebAudioSourceProviderClient;
34 }
35
36 class RenderAudioSourceProvider
37 : public WebKit::WebAudioSourceProvider,
38 public media::AudioRendererSink {
39 public:
40 RenderAudioSourceProvider();
41 virtual ~RenderAudioSourceProvider();
42
43 // WebKit::WebAudioSourceProvider implementation.
44
45 // WebKit calls setClient() if it desires to take control of the rendered
46 // audio stream. We call client's setFormat() when the audio stream format
47 // is known.
48 virtual void setClient(WebKit::WebAudioSourceProviderClient* client);
49
50 // If setClient() has been called, then WebKit calls provideInput()
51 // periodically to get the rendered audio stream.
52 virtual void provideInput(const WebKit::WebVector<float*>& audio_data,
53 size_t number_of_frames);
54
55 // AudioRendererSink implementation.
56 virtual void Start() OVERRIDE;
57 virtual void Stop() OVERRIDE;
58 virtual void Play() OVERRIDE;
59 virtual void Pause(bool flush) OVERRIDE;
60 virtual bool SetVolume(double volume) OVERRIDE;
61 virtual void GetVolume(double* volume) OVERRIDE;
62 virtual void Initialize(size_t buffer_size,
63 int channels,
64 double sample_rate,
65 AudioParameters::Format latency_format,
66 RenderCallback* renderer) OVERRIDE;
67
68 private:
69 // Set to true when Initialize() is called.
70 bool is_initialized_;
71 int channels_;
72 double sample_rate_;
73
74 bool is_running_;
75 double volume_;
76 media::AudioRendererSink::RenderCallback* renderer_;
77 WebKit::WebAudioSourceProviderClient* client_;
78
79 // Protects access to sink_
80 base::Lock sink_lock_;
81
82 // default_sink_ is the default sink.
83 scoped_refptr<media::AudioRendererSink> default_sink_;
84
85 DISALLOW_COPY_AND_ASSIGN(RenderAudioSourceProvider);
86 };
87
88 #endif // CONTENT_RENDERER_RENDER_AUDIOSOURCEPROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698