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_INPUT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_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 "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/renderer/media/audio_input_message_filter.h" | 11 #include "content/renderer/media/audio_input_message_filter.h" |
12 #include "webkit/plugins/ppapi/plugin_delegate.h" | 12 #include "webkit/plugins/ppapi/plugin_delegate.h" |
13 | 13 |
| 14 namespace media { |
14 class AudioParameters; | 15 class AudioParameters; |
| 16 } |
15 | 17 |
16 class PepperPlatformAudioInputImpl | 18 class PepperPlatformAudioInputImpl |
17 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, | 19 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, |
18 public AudioInputMessageFilter::Delegate, | 20 public AudioInputMessageFilter::Delegate, |
19 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { | 21 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { |
20 public: | 22 public: |
21 virtual ~PepperPlatformAudioInputImpl(); | 23 virtual ~PepperPlatformAudioInputImpl(); |
22 | 24 |
23 // Factory function, returns NULL on failure. StreamCreated() will be called | 25 // Factory function, returns NULL on failure. StreamCreated() will be called |
24 // when the stream is created. | 26 // when the stream is created. |
25 static PepperPlatformAudioInputImpl* Create( | 27 static PepperPlatformAudioInputImpl* Create( |
26 int sample_rate, | 28 int sample_rate, |
27 int frames_per_buffer, | 29 int frames_per_buffer, |
28 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 30 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
29 | 31 |
30 // PlatformAudioInput implementation (called on main thread). | 32 // PlatformAudioInput implementation (called on main thread). |
31 virtual bool StartCapture() OVERRIDE; | 33 virtual bool StartCapture() OVERRIDE; |
32 virtual bool StopCapture() OVERRIDE; | 34 virtual bool StopCapture() OVERRIDE; |
33 virtual void ShutDown() OVERRIDE; | 35 virtual void ShutDown() OVERRIDE; |
34 | 36 |
35 private: | 37 private: |
36 PepperPlatformAudioInputImpl(); | 38 PepperPlatformAudioInputImpl(); |
37 | 39 |
38 bool Initialize( | 40 bool Initialize( |
39 int sample_rate, | 41 int sample_rate, |
40 int frames_per_buffer, | 42 int frames_per_buffer, |
41 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 43 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
42 | 44 |
43 // I/O thread backends to above functions. | 45 // I/O thread backends to above functions. |
44 void InitializeOnIOThread(const AudioParameters& params); | 46 void InitializeOnIOThread(const media::AudioParameters& params); |
45 void StartCaptureOnIOThread(); | 47 void StartCaptureOnIOThread(); |
46 void StopCaptureOnIOThread(); | 48 void StopCaptureOnIOThread(); |
47 void ShutDownOnIOThread(); | 49 void ShutDownOnIOThread(); |
48 | 50 |
49 // AudioInputMessageFilter::Delegate. | 51 // AudioInputMessageFilter::Delegate. |
50 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 52 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
51 base::SyncSocket::Handle socket_handle, | 53 base::SyncSocket::Handle socket_handle, |
52 uint32 length) OVERRIDE; | 54 uint32 length) OVERRIDE; |
53 virtual void OnVolume(double volume) OVERRIDE; | 55 virtual void OnVolume(double volume) OVERRIDE; |
54 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; | 56 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... |
65 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 67 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD |
66 // or else you could race with the initialize function which sets it. | 68 // or else you could race with the initialize function which sets it. |
67 int32 stream_id_; | 69 int32 stream_id_; |
68 | 70 |
69 base::MessageLoopProxy* main_message_loop_proxy_; | 71 base::MessageLoopProxy* main_message_loop_proxy_; |
70 | 72 |
71 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); | 73 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); |
72 }; | 74 }; |
73 | 75 |
74 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ | 76 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ |
OLD | NEW |