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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // to the users of this class (via the PlatformAudioInputClient interface) are | 29 // to the users of this class (via the PlatformAudioInputClient interface) are |
30 // also sent on the main thread. Internally, this class sends audio input IPC | 30 // also sent on the main thread. Internally, this class sends audio input IPC |
31 // messages and receives AudioInputMessageFilter::Delegate notifications on the | 31 // messages and receives AudioInputMessageFilter::Delegate notifications on the |
32 // I/O thread. | 32 // I/O thread. |
33 | 33 |
34 class PepperPlatformAudioInputImpl | 34 class PepperPlatformAudioInputImpl |
35 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, | 35 : public webkit::ppapi::PluginDelegate::PlatformAudioInput, |
36 public AudioInputMessageFilter::Delegate, | 36 public AudioInputMessageFilter::Delegate, |
37 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { | 37 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { |
38 public: | 38 public: |
39 virtual ~PepperPlatformAudioInputImpl(); | |
40 | |
41 // Factory function, returns NULL on failure. StreamCreated() will be called | 39 // Factory function, returns NULL on failure. StreamCreated() will be called |
42 // when the stream is created. | 40 // when the stream is created. |
43 static PepperPlatformAudioInputImpl* Create( | 41 static PepperPlatformAudioInputImpl* Create( |
44 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, | 42 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, |
45 const std::string& device_id, | 43 const std::string& device_id, |
46 int sample_rate, | 44 int sample_rate, |
47 int frames_per_buffer, | 45 int frames_per_buffer, |
48 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); | 46 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); |
49 | 47 |
50 // PlatformAudioInput implementation (called on main thread). | 48 // PlatformAudioInput implementation (called on main thread). |
51 virtual void StartCapture() OVERRIDE; | 49 virtual void StartCapture() OVERRIDE; |
52 virtual void StopCapture() OVERRIDE; | 50 virtual void StopCapture() OVERRIDE; |
53 virtual void ShutDown() OVERRIDE; | 51 virtual void ShutDown() OVERRIDE; |
54 | 52 |
| 53 // AudioInputMessageFilter::Delegate. |
| 54 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
| 55 base::SyncSocket::Handle socket_handle, |
| 56 uint32 length) OVERRIDE; |
| 57 virtual void OnVolume(double volume) OVERRIDE; |
| 58 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; |
| 59 virtual void OnDeviceReady(const std::string&) OVERRIDE; |
| 60 |
| 61 protected: |
| 62 virtual ~PepperPlatformAudioInputImpl(); |
| 63 |
55 private: | 64 private: |
| 65 friend class base::RefCountedThreadSafe<PepperPlatformAudioInputImpl>; |
| 66 |
56 PepperPlatformAudioInputImpl(); | 67 PepperPlatformAudioInputImpl(); |
57 | 68 |
58 bool Initialize( | 69 bool Initialize( |
59 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, | 70 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, |
60 const std::string& device_id, | 71 const std::string& device_id, |
61 int sample_rate, | 72 int sample_rate, |
62 int frames_per_buffer, | 73 int frames_per_buffer, |
63 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); | 74 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); |
64 | 75 |
65 // I/O thread backends to above functions. | 76 // I/O thread backends to above functions. |
66 void InitializeOnIOThread(int session_id); | 77 void InitializeOnIOThread(int session_id); |
67 void StartCaptureOnIOThread(); | 78 void StartCaptureOnIOThread(); |
68 void StopCaptureOnIOThread(); | 79 void StopCaptureOnIOThread(); |
69 void ShutDownOnIOThread(); | 80 void ShutDownOnIOThread(); |
70 | 81 |
71 // AudioInputMessageFilter::Delegate. | |
72 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | |
73 base::SyncSocket::Handle socket_handle, | |
74 uint32 length) OVERRIDE; | |
75 virtual void OnVolume(double volume) OVERRIDE; | |
76 virtual void OnStateChanged(AudioStreamState state) OVERRIDE; | |
77 virtual void OnDeviceReady(const std::string&) OVERRIDE; | |
78 | |
79 void OnDeviceOpened(int request_id, | 82 void OnDeviceOpened(int request_id, |
80 bool succeeded, | 83 bool succeeded, |
81 const std::string& label); | 84 const std::string& label); |
82 void CloseDevice(); | 85 void CloseDevice(); |
83 void NotifyStreamCreationFailed(); | 86 void NotifyStreamCreationFailed(); |
84 | 87 |
85 // The client to notify when the stream is created. THIS MUST ONLY BE | 88 // The client to notify when the stream is created. THIS MUST ONLY BE |
86 // ACCESSED ON THE MAIN THREAD. | 89 // ACCESSED ON THE MAIN THREAD. |
87 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; | 90 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; |
88 | 91 |
(...skipping 20 matching lines...) Expand all Loading... |
109 | 112 |
110 // Initialized on the main thread and accessed on the I/O thread afterwards. | 113 // Initialized on the main thread and accessed on the I/O thread afterwards. |
111 media::AudioParameters params_; | 114 media::AudioParameters params_; |
112 | 115 |
113 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); | 116 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); |
114 }; | 117 }; |
115 | 118 |
116 } // namespace content | 119 } // namespace content |
117 | 120 |
118 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ | 121 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ |
OLD | NEW |