| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 14 #include "content/renderer/media/audio_input_message_filter.h" | 13 #include "media/audio/audio_input_ipc.h" |
| 15 #include "media/audio/audio_parameters.h" | 14 #include "media/audio/audio_parameters.h" |
| 16 #include "webkit/plugins/ppapi/plugin_delegate.h" | 15 #include "webkit/plugins/ppapi/plugin_delegate.h" |
| 17 | 16 |
| 18 namespace media { | 17 namespace media { |
| 19 class AudioParameters; | 18 class AudioParameters; |
| 20 } | 19 } |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 | 22 |
| 24 class AudioInputMessageFilter; | |
| 25 class PepperPluginDelegateImpl; | 23 class PepperPluginDelegateImpl; |
| 26 | 24 |
| 27 // PepperPlatformAudioInputImpl is operated on two threads: the main thread (the | 25 // PepperPlatformAudioInputImpl is operated on two threads: the main thread (the |
| 28 // thread on which objects are created) and the I/O thread. All public methods, | 26 // thread on which objects are created) and the I/O thread. All public methods, |
| 29 // except the destructor, must be called on the main thread. The notifications | 27 // except the destructor, must be called on the main thread. The notifications |
| 30 // to the users of this class (via the PlatformAudioInputClient interface) are | 28 // to the users of this class (via the PlatformAudioInputClient interface) are |
| 31 // also sent on the main thread. Internally, this class sends audio input IPC | 29 // also sent on the main thread. Internally, this class sends audio input IPC |
| 32 // messages and receives media::AudioInputIPCDelegate notifications on the | 30 // messages and receives media::AudioInputIPCDelegate notifications on the |
| 33 // I/O thread. | 31 // I/O thread. |
| 34 | 32 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 const std::string& label); | 85 const std::string& label); |
| 88 void CloseDevice(); | 86 void CloseDevice(); |
| 89 void NotifyStreamCreationFailed(); | 87 void NotifyStreamCreationFailed(); |
| 90 | 88 |
| 91 // The client to notify when the stream is created. THIS MUST ONLY BE | 89 // The client to notify when the stream is created. THIS MUST ONLY BE |
| 92 // ACCESSED ON THE MAIN THREAD. | 90 // ACCESSED ON THE MAIN THREAD. |
| 93 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; | 91 webkit::ppapi::PluginDelegate::PlatformAudioInputClient* client_; |
| 94 | 92 |
| 95 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE | 93 // Used to send/receive IPC. THIS MUST ONLY BE ACCESSED ON THE |
| 96 // I/O thread except to send messages and get the message loop. | 94 // I/O thread except to send messages and get the message loop. |
| 97 scoped_refptr<AudioInputMessageFilter> ipc_; | 95 scoped_ptr<media::AudioInputIPC> ipc_; |
| 98 | |
| 99 // Our ID on the MessageFilter. THIS MUST ONLY BE ACCESSED ON THE I/O THREAD | |
| 100 // or else you could race with the initialize function which sets it. | |
| 101 int32 stream_id_; | |
| 102 | |
| 103 // The render view into which the audio is sent. | |
| 104 int render_view_id_; | |
| 105 | 96 |
| 106 base::MessageLoopProxy* main_message_loop_proxy_; | 97 base::MessageLoopProxy* main_message_loop_proxy_; |
| 107 | 98 |
| 108 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. | 99 // THIS MUST ONLY BE ACCESSED ON THE MAIN THREAD. |
| 109 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; | 100 base::WeakPtr<PepperPluginDelegateImpl> plugin_delegate_; |
| 110 | 101 |
| 111 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON | 102 // The unique ID to identify the opened device. THIS MUST ONLY BE ACCESSED ON |
| 112 // THE MAIN THREAD. | 103 // THE MAIN THREAD. |
| 113 std::string label_; | 104 std::string label_; |
| 114 | 105 |
| 115 // Whether ShutDownOnIOThread() has been called. THIS MUST ONLY BE ACCESSED ON | |
| 116 // THE I/O THREAD. | |
| 117 bool shutdown_called_; | |
| 118 | |
| 119 // Initialized on the main thread and accessed on the I/O thread afterwards. | 106 // Initialized on the main thread and accessed on the I/O thread afterwards. |
| 120 media::AudioParameters params_; | 107 media::AudioParameters params_; |
| 121 | 108 |
| 122 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); | 109 DISALLOW_COPY_AND_ASSIGN(PepperPlatformAudioInputImpl); |
| 123 }; | 110 }; |
| 124 | 111 |
| 125 } // namespace content | 112 } // namespace content |
| 126 | 113 |
| 127 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ | 114 #endif // CONTENT_RENDERER_PEPPER_PEPPER_PLATFORM_AUDIO_INPUT_IMPL_H_ |
| OLD | NEW |