OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "content/renderer/media/audio_message_filter.h" | 10 #include "content/renderer/media/audio_message_filter.h" |
11 #include "webkit/plugins/ppapi/plugin_delegate.h" | 11 #include "webkit/plugins/ppapi/plugin_delegate.h" |
12 | 12 |
| 13 class RenderViewImpl; |
| 14 |
13 namespace media{ | 15 namespace media{ |
14 class AudioParameters; | 16 class AudioParameters; |
15 } | 17 } |
16 | 18 |
17 namespace base { | 19 namespace base { |
18 class MessageLoopProxy; | 20 class MessageLoopProxy; |
19 } | 21 } |
20 | 22 |
21 namespace content { | 23 namespace content { |
22 | 24 |
23 class PepperPlatformAudioOutputImpl | 25 class PepperPlatformAudioOutputImpl |
24 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, | 26 : public webkit::ppapi::PluginDelegate::PlatformAudioOutput, |
25 public AudioMessageFilter::Delegate, | 27 public AudioMessageFilter::Delegate, |
26 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { | 28 public base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl> { |
27 public: | 29 public: |
28 // Factory function, returns NULL on failure. StreamCreated() will be called | 30 // Factory function, returns NULL on failure. StreamCreated() will be called |
29 // when the stream is created. | 31 // when the stream is created. |
30 static PepperPlatformAudioOutputImpl* Create( | 32 static PepperPlatformAudioOutputImpl* Create( |
| 33 RenderViewImpl* render_view, |
31 int sample_rate, | 34 int sample_rate, |
32 int frames_per_buffer, | 35 int frames_per_buffer, |
33 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); | 36 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); |
34 | 37 |
35 // PlatformAudioOutput implementation (called on main thread). | 38 // PlatformAudioOutput implementation (called on main thread). |
36 virtual bool StartPlayback() OVERRIDE; | 39 virtual bool StartPlayback() OVERRIDE; |
37 virtual bool StopPlayback() OVERRIDE; | 40 virtual bool StopPlayback() OVERRIDE; |
38 virtual void ShutDown() OVERRIDE; | 41 virtual void ShutDown() OVERRIDE; |
39 | 42 |
40 // AudioMessageFilter::Delegate. | 43 // AudioMessageFilter::Delegate. |
41 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; | 44 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
42 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 45 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
43 base::SyncSocket::Handle socket_handle, | 46 base::SyncSocket::Handle socket_handle, |
44 uint32 length) OVERRIDE; | 47 uint32 length) OVERRIDE; |
45 | 48 |
46 protected: | 49 protected: |
47 virtual ~PepperPlatformAudioOutputImpl(); | 50 virtual ~PepperPlatformAudioOutputImpl(); |
48 | 51 |
49 private: | 52 private: |
50 friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>; | 53 friend class base::RefCountedThreadSafe<PepperPlatformAudioOutputImpl>; |
51 | 54 |
52 PepperPlatformAudioOutputImpl(); | 55 PepperPlatformAudioOutputImpl(); |
53 | 56 |
54 bool Initialize( | 57 bool Initialize( |
| 58 RenderViewImpl* render_view, |
55 int sample_rate, | 59 int sample_rate, |
56 int frames_per_buffer, | 60 int frames_per_buffer, |
57 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); | 61 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client); |
58 | 62 |
59 // I/O thread backends to above functions. | 63 // I/O thread backends to above functions. |
60 void InitializeOnIOThread(const media::AudioParameters& params); | 64 void InitializeOnIOThread(const media::AudioParameters& params); |
61 void StartPlaybackOnIOThread(); | 65 void StartPlaybackOnIOThread(); |
62 void StopPlaybackOnIOThread(); | 66 void StopPlaybackOnIOThread(); |
63 void ShutDownOnIOThread(); | 67 void ShutDownOnIOThread(); |
64 | 68 |
| 69 RenderViewImpl* render_view_; |
| 70 |
65 // The client to notify when the stream is created. THIS MUST ONLY BE | 71 // The client to notify when the stream is created. THIS MUST ONLY BE |
66 // ACCESSED ON THE MAIN THREAD. | 72 // ACCESSED ON THE MAIN THREAD. |
67 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_; | 73 webkit::ppapi::PluginDelegate::PlatformAudioOutputClient* client_; |
68 | 74 |
69 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 75 // MessageFilter used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
70 // I/O thread except to send messages and get the message loop. | 76 // I/O thread except to send messages and get the message loop. |
71 scoped_refptr<AudioMessageFilter> filter_; | 77 scoped_refptr<AudioMessageFilter> filter_; |
72 | 78 |
73 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 79 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD |
74 // or else you could race with the initialize function which sets it. | 80 // or else you could race with the initialize function which sets it. |
75 int32 stream_id_; | 81 int32 stream_id_; |
76 | 82 |
77 base::MessageLoopProxy* main_message_loop_proxy_; | 83 base::MessageLoopProxy* main_message_loop_proxy_; |
78 | 84 |
79 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); | 85 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioOutputImpl); |
80 }; | 86 }; |
81 | 87 |
82 } // namespace content | 88 } // namespace content |
83 | 89 |
84 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ | 90 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_OUTPUT_IMPL_H_ |
OLD | NEW |