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 21 matching lines...) Expand all Loading... | |
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 media::AudioInputIPCDelegate, | 36 public media::AudioInputIPCDelegate, |
37 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { | 37 public base::RefCountedThreadSafe<PepperPlatformAudioInputImpl> { |
38 public: | 38 public: |
39 // Factory function, returns NULL on failure. StreamCreated() will be called | 39 // Factory function, returns NULL on failure. StreamCreated() will be called |
40 // when the stream is created. | 40 // when the stream is created. |
41 static PepperPlatformAudioInputImpl* Create( | 41 static PepperPlatformAudioInputImpl* Create( |
42 int render_view_id, | |
jamesr
2012/10/29 22:51:02
you don't need this - you're passing in a WeakPtr
| |
42 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, | 43 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, |
43 const std::string& device_id, | 44 const std::string& device_id, |
44 int sample_rate, | 45 int sample_rate, |
45 int frames_per_buffer, | 46 int frames_per_buffer, |
46 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); | 47 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); |
47 | 48 |
48 // PlatformAudioInput implementation (called on main thread). | 49 // PlatformAudioInput implementation (called on main thread). |
49 virtual void StartCapture() OVERRIDE; | 50 virtual void StartCapture() OVERRIDE; |
50 virtual void StopCapture() OVERRIDE; | 51 virtual void StopCapture() OVERRIDE; |
51 virtual void ShutDown() OVERRIDE; | 52 virtual void ShutDown() OVERRIDE; |
52 | 53 |
53 // media::AudioInputIPCDelegate. | 54 // media::AudioInputIPCDelegate. |
54 virtual void OnStreamCreated(base::SharedMemoryHandle handle, | 55 virtual void OnStreamCreated(base::SharedMemoryHandle handle, |
55 base::SyncSocket::Handle socket_handle, | 56 base::SyncSocket::Handle socket_handle, |
56 int length) OVERRIDE; | 57 int length) OVERRIDE; |
57 virtual void OnVolume(double volume) OVERRIDE; | 58 virtual void OnVolume(double volume) OVERRIDE; |
58 virtual void OnStateChanged( | 59 virtual void OnStateChanged( |
59 media::AudioInputIPCDelegate::State state) OVERRIDE; | 60 media::AudioInputIPCDelegate::State state) OVERRIDE; |
60 virtual void OnDeviceReady(const std::string&) OVERRIDE; | 61 virtual void OnDeviceReady(const std::string&) OVERRIDE; |
61 virtual void OnIPCClosed() OVERRIDE; | 62 virtual void OnIPCClosed() OVERRIDE; |
62 | 63 |
63 protected: | 64 protected: |
64 virtual ~PepperPlatformAudioInputImpl(); | 65 virtual ~PepperPlatformAudioInputImpl(); |
65 | 66 |
66 private: | 67 private: |
67 friend class base::RefCountedThreadSafe<PepperPlatformAudioInputImpl>; | 68 friend class base::RefCountedThreadSafe<PepperPlatformAudioInputImpl>; |
68 | 69 |
69 PepperPlatformAudioInputImpl(); | 70 explicit PepperPlatformAudioInputImpl(int render_view_id); |
jamesr
2012/10/29 22:51:02
Unnecessary
| |
70 | 71 |
71 bool Initialize( | 72 bool Initialize( |
72 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, | 73 const base::WeakPtr<PepperPluginDelegateImpl>& plugin_delegate, |
73 const std::string& device_id, | 74 const std::string& device_id, |
74 int sample_rate, | 75 int sample_rate, |
75 int frames_per_buffer, | 76 int frames_per_buffer, |
76 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); | 77 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client); |
77 | 78 |
78 // I/O thread backends to above functions. | 79 // I/O thread backends to above functions. |
79 void InitializeOnIOThread(int session_id); | 80 void InitializeOnIOThread(int session_id); |
80 void StartCaptureOnIOThread(); | 81 void StartCaptureOnIOThread(); |
81 void StopCaptureOnIOThread(); | 82 void StopCaptureOnIOThread(); |
82 void ShutDownOnIOThread(); | 83 void ShutDownOnIOThread(); |
83 | 84 |
84 void OnDeviceOpened(int request_id, | 85 void OnDeviceOpened(int request_id, |
85 bool succeeded, | 86 bool succeeded, |
86 const std::string& label); | 87 const std::string& label); |
87 void CloseDevice(); | 88 void CloseDevice(); |
88 void NotifyStreamCreationFailed(); | 89 void NotifyStreamCreationFailed(); |
89 | 90 |
90 // The client to notify when the stream is created. THIS MUST ONLY BE | 91 // The client to notify when the stream is created. THIS MUST ONLY BE |
91 // ACCESSED ON THE MAIN THREAD. | 92 // ACCESSED ON THE MAIN THREAD. |
92 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; | 93 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; |
93 | 94 |
94 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 95 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
95 // I/O thread except to send messages and get the message loop. | 96 // I/O thread except to send messages and get the message loop. |
96 media::AudioInputIPC* ipc_; | 97 scoped_ptr<media::AudioInputIPC> ipc_; |
97 | 98 |
98 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | 99 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD |
99 // or else you could race with the initialize function which sets it. | 100 // or else you could race with the initialize function which sets it. |
100 int32 stream_id_; | 101 int32 stream_id_; |
101 | 102 |
102 base::MessageLoopProxy* main_message_loop_proxy_; | 103 base::MessageLoopProxy* main_message_loop_proxy_; |
103 | 104 |
104 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. | 105 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. |
105 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; | 106 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; |
106 | 107 |
107 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON | 108 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON |
108 // THE MAIN THREAD. | 109 // THE MAIN THREAD. |
109 std::string label_; | 110 std::string label_; |
110 | 111 |
111 // Whether ShutDownOnIOThread() has been called. THIS MUST ONLY BE ACCESSED ON | 112 // Whether ShutDownOnIOThread() has been called. THIS MUST ONLY BE ACCESSED ON |
112 // THE I/O THREAD. | 113 // THE I/O THREAD. |
113 bool shutdown_called_; | 114 bool shutdown_called_; |
114 | 115 |
115 // Initialized on the main thread and accessed on the I/O thread afterwards. | 116 // Initialized on the main thread and accessed on the I/O thread afterwards. |
116 media::AudioParameters params_; | 117 media::AudioParameters params_; |
117 | 118 |
118 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); | 119 DISALLOW_IMPLICIT_CONSTRUCTORS(PepperPlatformAudioInputImpl); |
119 }; | 120 }; |
120 | 121 |
121 } // namespace content | 122 } // namespace content |
122 | 123 |
123 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ | 124 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ |
OLD | NEW |