| 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 struct AudioParameters; | 14 class AudioParameters; |
| 15 | 15 |
| 16 class PepperPlatformAudioInputImpl | 16 class PepperPlatformAudioInputImpl |
| 17 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, | 17 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, |
| 18 public AudioInputMessageFilter::Delegate, | 18 public AudioInputMessageFilter::Delegate, |
| 19 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { | 19 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { |
| 20 public: | 20 public: |
| 21 virtual ~PepperPlatformAudioInputImpl(); | 21 virtual ~PepperPlatformAudioInputImpl(); |
| 22 | 22 |
| 23 // Factory function, returns NULL on failure. StreamCreated() will be called | 23 // Factory function, returns NULL on failure. StreamCreated() will be called |
| 24 // when the stream is created. | 24 // when the stream is created. |
| 25 static PepperPlatformAudioInputImpl* Create( | 25 static PepperPlatformAudioInputImpl* Create( |
| 26 uint32_t sample_rate, | 26 int sample_rate, |
| 27 uint32_t sample_count, | 27 int frames_per_buffer, |
| 28 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 28 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
| 29 | 29 |
| 30 // PlatformAudioInput implementation (called on main thread). | 30 // PlatformAudioInput implementation (called on main thread). |
| 31 virtual bool StartCapture() OVERRIDE; | 31 virtual bool StartCapture() OVERRIDE; |
| 32 virtual bool StopCapture() OVERRIDE; | 32 virtual bool StopCapture() OVERRIDE; |
| 33 virtual void ShutDown() OVERRIDE; | 33 virtual void ShutDown() OVERRIDE; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 PepperPlatformAudioInputImpl(); | 36 PepperPlatformAudioInputImpl(); |
| 37 | 37 |
| 38 bool Initialize( | 38 bool Initialize( |
| 39 uint32_t sample_rate, | 39 int sample_rate, |
| 40 uint32_t sample_count, | 40 int frames_per_buffer, |
| 41 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); | 41 webkit::ppapi::PluginDelegate::PlatformAudioCommonClient* client); |
| 42 | 42 |
| 43 // I/O thread backends to above functions. | 43 // I/O thread backends to above functions. |
| 44 void InitializeOnIOThread(const AudioParameters& params); | 44 void InitializeOnIOThread(const AudioParameters& params); |
| 45 void StartCaptureOnIOThread(); | 45 void StartCaptureOnIOThread(); |
| 46 void StopCaptureOnIOThread(); | 46 void StopCaptureOnIOThread(); |
| 47 void ShutDownOnIOThread(); | 47 void ShutDownOnIOThread(); |
| 48 | 48 |
| 49 // AudioInputMessageFilter::Delegate. | 49 // AudioInputMessageFilter::Delegate. |
| 50 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 50 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 65 // 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. | 66 // or else you could race with the initialize function which sets it. |
| 67 int32 stream_id_; | 67 int32 stream_id_; |
| 68 | 68 |
| 69 base::MessageLoopProxy* main_message_loop_proxy_; | 69 base::MessageLoopProxy* main_message_loop_proxy_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); | 71 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ | 74 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ |
| OLD | NEW |