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

Side by Side Diff: webkit/renderer/media/webaudiosourceprovider_impl.h

Issue 18123002: Migrate webkit/renderer/media/ to content/renderer/media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: delegates Created 7 years, 5 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 2013 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 WEBKIT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_
6 #define WEBKIT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_
7
8 #include "base/synchronization/lock.h"
9 #include "media/base/audio_renderer_sink.h"
10 #include "third_party/WebKit/public/platform/WebVector.h"
11 #include "third_party/WebKit/public/web/WebAudioSourceProvider.h"
12
13 namespace WebKit {
14 class WebAudioSourceProviderClient;
15 }
16
17 namespace webkit_media {
18
19 // WebAudioSourceProviderImpl provides a bridge between classes:
20 // WebKit::WebAudioSourceProvider <---> media::AudioRendererSink
21 //
22 // WebAudioSourceProviderImpl wraps an existing audio sink that is used unless
23 // WebKit has set a client via setClient(). While a client is set WebKit will
24 // periodically call provideInput() to render a certain number of audio
25 // sample-frames using the sink's RenderCallback to get the data.
26 //
27 // All calls are protected by a lock.
28 class WebAudioSourceProviderImpl
29 : public WebKit::WebAudioSourceProvider,
30 public media::AudioRendererSink {
31 public:
32 explicit WebAudioSourceProviderImpl(
33 const scoped_refptr<media::AudioRendererSink>& sink);
34
35 // WebKit::WebAudioSourceProvider implementation.
36 virtual void setClient(WebKit::WebAudioSourceProviderClient* client);
37 virtual void provideInput(const WebKit::WebVector<float*>& audio_data,
38 size_t number_of_frames);
39
40 // media::AudioRendererSink implementation.
41 virtual void Start() OVERRIDE;
42 virtual void Stop() OVERRIDE;
43 virtual void Play() OVERRIDE;
44 virtual void Pause() OVERRIDE;
45 virtual bool SetVolume(double volume) OVERRIDE;
46 virtual void Initialize(const media::AudioParameters& params,
47 RenderCallback* renderer) OVERRIDE;
48
49 protected:
50 virtual ~WebAudioSourceProviderImpl();
51
52 private:
53 // Set to true when Initialize() is called.
54 int channels_;
55 int sample_rate_;
56 double volume_;
57
58 // Tracks the current playback state.
59 enum PlaybackState { kStopped, kStarted, kPlaying };
60 PlaybackState state_;
61
62 // Where audio comes from.
63 media::AudioRendererSink::RenderCallback* renderer_;
64
65 // When set via setClient() it overrides |sink_| for consuming audio.
66 WebKit::WebAudioSourceProviderClient* client_;
67
68 // Where audio ends up unless overridden by |client_|.
69 base::Lock sink_lock_;
70 scoped_refptr<media::AudioRendererSink> sink_;
71 scoped_ptr<media::AudioBus> bus_wrapper_;
72
73 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl);
74 };
75
76 } // namespace webkit_media
77
78 #endif // WEBKIT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698