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

Side by Side Diff: media/blink/webaudiosourceprovider_impl.h

Issue 495353003: Move WebMediaPlayerImpl and its dependencies to media/blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ 5 #ifndef MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ 6 #define MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 #include "content/common/content_export.h"
12 #include "media/base/audio_renderer_sink.h" 11 #include "media/base/audio_renderer_sink.h"
12 #include "media/base/media_export.h"
13 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h" 13 #include "third_party/WebKit/public/platform/WebAudioSourceProvider.h"
14 #include "third_party/WebKit/public/platform/WebVector.h" 14 #include "third_party/WebKit/public/platform/WebVector.h"
15 15
16 namespace blink { 16 namespace blink {
17 class WebAudioSourceProviderClient; 17 class WebAudioSourceProviderClient;
18 } 18 }
19 19
20 namespace content { 20 namespace media {
21 21
22 // WebAudioSourceProviderImpl provides a bridge between classes: 22 // WebAudioSourceProviderImpl provides a bridge between classes:
23 // blink::WebAudioSourceProvider <---> media::AudioRendererSink 23 // blink::WebAudioSourceProvider <---> AudioRendererSink
24 // 24 //
25 // WebAudioSourceProviderImpl wraps an existing audio sink that is used unless 25 // WebAudioSourceProviderImpl wraps an existing audio sink that is used unless
26 // WebKit has set a client via setClient(). While a client is set WebKit will 26 // WebKit has set a client via setClient(). While a client is set WebKit will
27 // periodically call provideInput() to render a certain number of audio 27 // periodically call provideInput() to render a certain number of audio
28 // sample-frames using the sink's RenderCallback to get the data. 28 // sample-frames using the sink's RenderCallback to get the data.
29 // 29 //
30 // All calls are protected by a lock. 30 // All calls are protected by a lock.
31 class CONTENT_EXPORT WebAudioSourceProviderImpl 31 class MEDIA_EXPORT WebAudioSourceProviderImpl
32 : NON_EXPORTED_BASE(public blink::WebAudioSourceProvider), 32 : NON_EXPORTED_BASE(public blink::WebAudioSourceProvider),
33 NON_EXPORTED_BASE(public media::AudioRendererSink) { 33 NON_EXPORTED_BASE(public AudioRendererSink) {
34 public: 34 public:
35 explicit WebAudioSourceProviderImpl( 35 explicit WebAudioSourceProviderImpl(
36 const scoped_refptr<media::AudioRendererSink>& sink); 36 const scoped_refptr<AudioRendererSink>& sink);
37 37
38 // blink::WebAudioSourceProvider implementation. 38 // blink::WebAudioSourceProvider implementation.
39 virtual void setClient(blink::WebAudioSourceProviderClient* client); 39 virtual void setClient(blink::WebAudioSourceProviderClient* client);
40 virtual void provideInput(const blink::WebVector<float*>& audio_data, 40 virtual void provideInput(const blink::WebVector<float*>& audio_data,
41 size_t number_of_frames); 41 size_t number_of_frames);
42 42
43 // media::AudioRendererSink implementation. 43 // AudioRendererSink implementation.
44 virtual void Start() OVERRIDE; 44 virtual void Start() OVERRIDE;
45 virtual void Stop() OVERRIDE; 45 virtual void Stop() OVERRIDE;
46 virtual void Play() OVERRIDE; 46 virtual void Play() OVERRIDE;
47 virtual void Pause() OVERRIDE; 47 virtual void Pause() OVERRIDE;
48 virtual bool SetVolume(double volume) OVERRIDE; 48 virtual bool SetVolume(double volume) OVERRIDE;
49 virtual void Initialize(const media::AudioParameters& params, 49 virtual void Initialize(const AudioParameters& params,
50 RenderCallback* renderer) OVERRIDE; 50 RenderCallback* renderer) OVERRIDE;
51 51
52 protected: 52 protected:
53 virtual ~WebAudioSourceProviderImpl(); 53 virtual ~WebAudioSourceProviderImpl();
54 54
55 private: 55 private:
56 // Calls setFormat() on |client_| from the Blink renderer thread. 56 // Calls setFormat() on |client_| from the Blink renderer thread.
57 void OnSetFormat(); 57 void OnSetFormat();
58 58
59 // Closure that posts a task to call OnSetFormat() on the renderer thread. 59 // Closure that posts a task to call OnSetFormat() on the renderer thread.
60 base::Closure set_format_cb_; 60 base::Closure set_format_cb_;
61 61
62 // Set to true when Initialize() is called. 62 // Set to true when Initialize() is called.
63 int channels_; 63 int channels_;
64 int sample_rate_; 64 int sample_rate_;
65 double volume_; 65 double volume_;
66 66
67 // Tracks the current playback state. 67 // Tracks the current playback state.
68 enum PlaybackState { kStopped, kStarted, kPlaying }; 68 enum PlaybackState { kStopped, kStarted, kPlaying };
69 PlaybackState state_; 69 PlaybackState state_;
70 70
71 // Where audio comes from. 71 // Where audio comes from.
72 media::AudioRendererSink::RenderCallback* renderer_; 72 AudioRendererSink::RenderCallback* renderer_;
73 73
74 // When set via setClient() it overrides |sink_| for consuming audio. 74 // When set via setClient() it overrides |sink_| for consuming audio.
75 blink::WebAudioSourceProviderClient* client_; 75 blink::WebAudioSourceProviderClient* client_;
76 76
77 // Where audio ends up unless overridden by |client_|. 77 // Where audio ends up unless overridden by |client_|.
78 base::Lock sink_lock_; 78 base::Lock sink_lock_;
79 scoped_refptr<media::AudioRendererSink> sink_; 79 scoped_refptr<AudioRendererSink> sink_;
80 scoped_ptr<media::AudioBus> bus_wrapper_; 80 scoped_ptr<AudioBus> bus_wrapper_;
81 81
82 // NOTE: Weak pointers must be invalidated before all other member variables. 82 // NOTE: Weak pointers must be invalidated before all other member variables.
83 base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_; 83 base::WeakPtrFactory<WebAudioSourceProviderImpl> weak_factory_;
84 84
85 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl); 85 DISALLOW_IMPLICIT_CONSTRUCTORS(WebAudioSourceProviderImpl);
86 }; 86 };
87 87
88 } // namespace content 88 } // namespace media
89 89
90 #endif // CONTENT_RENDERER_MEDIA_WEBAUDIOSOURCEPROVIDER_IMPL_H_ 90 #endif // MEDIA_BLINK_WEBAUDIOSOURCEPROVIDER_IMPL_H_
OLDNEW
« no previous file with comments | « media/blink/video_frame_compositor_unittest.cc ('k') | media/blink/webaudiosourceprovider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698