| 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 PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ | 5 #ifndef PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ |
| 6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ | 6 #define PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Used by the impl. | 34 // Used by the impl. |
| 35 explicit PPB_AudioInput_Shared(PP_Instance instance); | 35 explicit PPB_AudioInput_Shared(PP_Instance instance); |
| 36 virtual ~PPB_AudioInput_Shared(); | 36 virtual ~PPB_AudioInput_Shared(); |
| 37 | 37 |
| 38 // Resource overrides. | 38 // Resource overrides. |
| 39 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; | 39 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; |
| 40 | 40 |
| 41 // Implementation of PPB_AudioInput_API non-trusted methods. | 41 // Implementation of PPB_AudioInput_API non-trusted methods. |
| 42 virtual int32_t EnumerateDevices( | 42 virtual int32_t EnumerateDevices( |
| 43 PP_Resource* devices, | 43 PP_Resource* devices, |
| 44 const PP_CompletionCallback& callback) OVERRIDE; | 44 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 45 virtual int32_t Open(const std::string& device_id, | 45 virtual int32_t Open(const std::string& device_id, |
| 46 PP_Resource config, | 46 PP_Resource config, |
| 47 PPB_AudioInput_Callback audio_input_callback, | 47 PPB_AudioInput_Callback audio_input_callback, |
| 48 void* user_data, | 48 void* user_data, |
| 49 const PP_CompletionCallback& callback) OVERRIDE; | 49 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 50 virtual PP_Resource GetCurrentConfig() OVERRIDE; | 50 virtual PP_Resource GetCurrentConfig() OVERRIDE; |
| 51 virtual PP_Bool StartCapture() OVERRIDE; | 51 virtual PP_Bool StartCapture() OVERRIDE; |
| 52 virtual PP_Bool StopCapture() OVERRIDE; | 52 virtual PP_Bool StopCapture() OVERRIDE; |
| 53 virtual void Close() OVERRIDE; | 53 virtual void Close() OVERRIDE; |
| 54 | 54 |
| 55 void OnEnumerateDevicesComplete(int32_t result, | 55 void OnEnumerateDevicesComplete(int32_t result, |
| 56 const std::vector<DeviceRefData>& devices); | 56 const std::vector<DeviceRefData>& devices); |
| 57 void OnOpenComplete(int32_t result, | 57 void OnOpenComplete(int32_t result, |
| 58 base::SharedMemoryHandle shared_memory_handle, | 58 base::SharedMemoryHandle shared_memory_handle, |
| 59 size_t shared_memory_size, | 59 size_t shared_memory_size, |
| 60 base::SyncSocket::Handle socket_handle); | 60 base::SyncSocket::Handle socket_handle); |
| 61 | 61 |
| 62 static PP_CompletionCallback MakeIgnoredCompletionCallback(); | 62 static scoped_refptr<TrackedCallback> MakeIgnoredCompletionCallback( |
| 63 Resource* resource); |
| 63 | 64 |
| 64 protected: | 65 protected: |
| 65 enum OpenState { | 66 enum OpenState { |
| 66 BEFORE_OPEN, | 67 BEFORE_OPEN, |
| 67 OPENED, | 68 OPENED, |
| 68 CLOSED | 69 CLOSED |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 // Subclasses should implement these methods to do impl- and proxy-specific | 72 // Subclasses should implement these methods to do impl- and proxy-specific |
| 72 // work. | 73 // work. |
| 73 virtual int32_t InternalEnumerateDevices(PP_Resource* devices, | 74 virtual int32_t InternalEnumerateDevices( |
| 74 PP_CompletionCallback callback) = 0; | 75 PP_Resource* devices, |
| 76 scoped_refptr<TrackedCallback> callback) = 0; |
| 75 virtual int32_t InternalOpen(const std::string& device_id, | 77 virtual int32_t InternalOpen(const std::string& device_id, |
| 76 PP_AudioSampleRate sample_rate, | 78 PP_AudioSampleRate sample_rate, |
| 77 uint32_t sample_frame_count, | 79 uint32_t sample_frame_count, |
| 78 PP_CompletionCallback callback) = 0; | 80 scoped_refptr<TrackedCallback> callback) = 0; |
| 79 virtual PP_Bool InternalStartCapture() = 0; | 81 virtual PP_Bool InternalStartCapture() = 0; |
| 80 virtual PP_Bool InternalStopCapture() = 0; | 82 virtual PP_Bool InternalStopCapture() = 0; |
| 81 virtual void InternalClose() = 0; | 83 virtual void InternalClose() = 0; |
| 82 | 84 |
| 83 // Configures the current state to be capturing or not. The caller is | 85 // Configures the current state to be capturing or not. The caller is |
| 84 // responsible for ensuring the new state is the opposite of the current one. | 86 // responsible for ensuring the new state is the opposite of the current one. |
| 85 // | 87 // |
| 86 // This is the implementation for PPB_AudioInput.Start/StopCapture, except | 88 // This is the implementation for PPB_AudioInput.Start/StopCapture, except |
| 87 // that it does not actually notify the audio system to stop capture, it just | 89 // that it does not actually notify the audio system to stop capture, it just |
| 88 // configures our object to stop generating callbacks. The actual stop | 90 // configures our object to stop generating callbacks. The actual stop |
| (...skipping 21 matching lines...) Expand all Loading... |
| 110 // The common implementation of OpenTrusted() and Open(). It will call | 112 // The common implementation of OpenTrusted() and Open(). It will call |
| 111 // InternalOpen() to do impl- and proxy-specific work. | 113 // InternalOpen() to do impl- and proxy-specific work. |
| 112 // OpenTrusted() will call this methods with a NULL |audio_input_callback|, | 114 // OpenTrusted() will call this methods with a NULL |audio_input_callback|, |
| 113 // in this case, the thread will not be run. This non-callback mode is used in | 115 // in this case, the thread will not be run. This non-callback mode is used in |
| 114 // the renderer with the proxy, since the proxy handles the callback entirely | 116 // the renderer with the proxy, since the proxy handles the callback entirely |
| 115 // within the plugin process. | 117 // within the plugin process. |
| 116 int32_t CommonOpen(const std::string& device_id, | 118 int32_t CommonOpen(const std::string& device_id, |
| 117 PP_Resource config, | 119 PP_Resource config, |
| 118 PPB_AudioInput_Callback audio_input_callback, | 120 PPB_AudioInput_Callback audio_input_callback, |
| 119 void* user_data, | 121 void* user_data, |
| 120 PP_CompletionCallback callback); | 122 scoped_refptr<TrackedCallback> callback); |
| 121 | 123 |
| 122 OpenState open_state_; | 124 OpenState open_state_; |
| 123 | 125 |
| 124 // True if capturing the stream. | 126 // True if capturing the stream. |
| 125 bool capturing_; | 127 bool capturing_; |
| 126 | 128 |
| 127 // Socket used to notify us when new samples are available. This pointer is | 129 // Socket used to notify us when new samples are available. This pointer is |
| 128 // created in SetStreamInfo(). | 130 // created in SetStreamInfo(). |
| 129 scoped_ptr<base::CancelableSyncSocket> socket_; | 131 scoped_ptr<base::CancelableSyncSocket> socket_; |
| 130 | 132 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 157 PP_Resource* devices_; | 159 PP_Resource* devices_; |
| 158 | 160 |
| 159 ResourceObjectType resource_object_type_; | 161 ResourceObjectType resource_object_type_; |
| 160 | 162 |
| 161 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Shared); | 163 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Shared); |
| 162 }; | 164 }; |
| 163 | 165 |
| 164 } // namespace ppapi | 166 } // namespace ppapi |
| 165 | 167 |
| 166 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ | 168 #endif // PPAPI_SHARED_IMPL_PPB_AUDIO_INPUT_SHARED_H_ |
| OLD | NEW |