| 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_PROXY_AUDIO_INPUT_RESOURCE_H_ | 5 #ifndef PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ |
| 6 #define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ | 6 #define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_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 17 matching lines...) Expand all Loading... |
| 28 public: | 28 public: |
| 29 AudioInputResource(Connection connection, PP_Instance instance); | 29 AudioInputResource(Connection connection, PP_Instance instance); |
| 30 virtual ~AudioInputResource(); | 30 virtual ~AudioInputResource(); |
| 31 | 31 |
| 32 // Resource overrides. | 32 // Resource overrides. |
| 33 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; | 33 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; |
| 34 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, | 34 virtual void OnReplyReceived(const ResourceMessageReplyParams& params, |
| 35 const IPC::Message& msg) OVERRIDE; | 35 const IPC::Message& msg) OVERRIDE; |
| 36 | 36 |
| 37 // PPB_AudioInput_API implementation. | 37 // PPB_AudioInput_API implementation. |
| 38 virtual int32_t EnumerateDevices0_2( | |
| 39 PP_Resource* devices, | |
| 40 scoped_refptr<TrackedCallback> callback) OVERRIDE; | |
| 41 virtual int32_t EnumerateDevices( | 38 virtual int32_t EnumerateDevices( |
| 42 const PP_ArrayOutput& output, | 39 const PP_ArrayOutput& output, |
| 43 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 40 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 44 virtual int32_t MonitorDeviceChange( | 41 virtual int32_t MonitorDeviceChange( |
| 45 PP_MonitorDeviceChangeCallback callback, | 42 PP_MonitorDeviceChangeCallback callback, |
| 46 void* user_data) OVERRIDE; | 43 void* user_data) OVERRIDE; |
| 47 virtual int32_t Open0_2(PP_Resource device_ref, | 44 virtual int32_t Open0_3(PP_Resource device_ref, |
| 48 PP_Resource config, | 45 PP_Resource config, |
| 49 PPB_AudioInput_Callback_0_2 audio_input_callback_0_2, | 46 PPB_AudioInput_Callback_0_3 audio_input_callback_0_3, |
| 50 void* user_data, | 47 void* user_data, |
| 51 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 48 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 52 virtual int32_t Open(PP_Resource device_ref, | 49 virtual int32_t Open(PP_Resource device_ref, |
| 53 PP_Resource config, | 50 PP_Resource config, |
| 54 PPB_AudioInput_Callback audio_input_callback, | 51 PPB_AudioInput_Callback audio_input_callback, |
| 55 void* user_data, | 52 void* user_data, |
| 56 scoped_refptr<TrackedCallback> callback) OVERRIDE; | 53 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 57 virtual PP_Resource GetCurrentConfig() OVERRIDE; | 54 virtual PP_Resource GetCurrentConfig() OVERRIDE; |
| 58 virtual PP_Bool StartCapture() OVERRIDE; | 55 virtual PP_Bool StartCapture() OVERRIDE; |
| 59 virtual PP_Bool StopCapture() OVERRIDE; | 56 virtual PP_Bool StopCapture() OVERRIDE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 83 | 80 |
| 84 // Stops execution of the audio input thread. | 81 // Stops execution of the audio input thread. |
| 85 void StopThread(); | 82 void StopThread(); |
| 86 | 83 |
| 87 // DelegateSimpleThread::Delegate implementation. | 84 // DelegateSimpleThread::Delegate implementation. |
| 88 // Run on the audio input thread. | 85 // Run on the audio input thread. |
| 89 virtual void Run() OVERRIDE; | 86 virtual void Run() OVERRIDE; |
| 90 | 87 |
| 91 int32_t CommonOpen(PP_Resource device_ref, | 88 int32_t CommonOpen(PP_Resource device_ref, |
| 92 PP_Resource config, | 89 PP_Resource config, |
| 93 PPB_AudioInput_Callback_0_2 audio_input_callback_0_2, | 90 PPB_AudioInput_Callback_0_3 audio_input_callback_0_3, |
| 94 PPB_AudioInput_Callback audio_input_callback, | 91 PPB_AudioInput_Callback audio_input_callback, |
| 95 void* user_data, | 92 void* user_data, |
| 96 scoped_refptr<TrackedCallback> callback); | 93 scoped_refptr<TrackedCallback> callback); |
| 97 | 94 |
| 98 OpenState open_state_; | 95 OpenState open_state_; |
| 99 | 96 |
| 100 // True if capturing the stream. | 97 // True if capturing the stream. |
| 101 bool capturing_; | 98 bool capturing_; |
| 102 | 99 |
| 103 // Socket used to notify us when new samples are available. This pointer is | 100 // Socket used to notify us when new samples are available. This pointer is |
| 104 // created in SetStreamInfo(). | 101 // created in SetStreamInfo(). |
| 105 scoped_ptr<base::CancelableSyncSocket> socket_; | 102 scoped_ptr<base::CancelableSyncSocket> socket_; |
| 106 | 103 |
| 107 // Sample buffer in shared memory. This pointer is created in | 104 // Sample buffer in shared memory. This pointer is created in |
| 108 // SetStreamInfo(). The memory is only mapped when the audio thread is | 105 // SetStreamInfo(). The memory is only mapped when the audio thread is |
| 109 // created. | 106 // created. |
| 110 scoped_ptr<base::SharedMemory> shared_memory_; | 107 scoped_ptr<base::SharedMemory> shared_memory_; |
| 111 | 108 |
| 112 // The size of the sample buffer in bytes. | 109 // The size of the sample buffer in bytes. |
| 113 size_t shared_memory_size_; | 110 size_t shared_memory_size_; |
| 114 | 111 |
| 115 // When the callback is set, this thread is spawned for calling it. | 112 // When the callback is set, this thread is spawned for calling it. |
| 116 scoped_ptr<base::DelegateSimpleThread> audio_input_thread_; | 113 scoped_ptr<base::DelegateSimpleThread> audio_input_thread_; |
| 117 | 114 |
| 118 // Callback to call when new samples are available. | 115 // Callback to call when new samples are available. |
| 119 PPB_AudioInput_Callback_0_2 audio_input_callback_0_2_; | 116 PPB_AudioInput_Callback_0_3 audio_input_callback_0_3_; |
| 120 PPB_AudioInput_Callback audio_input_callback_; | 117 PPB_AudioInput_Callback audio_input_callback_; |
| 121 | 118 |
| 122 // User data pointer passed verbatim to the callback function. | 119 // User data pointer passed verbatim to the callback function. |
| 123 void* user_data_; | 120 void* user_data_; |
| 124 | 121 |
| 125 // The callback is not directly passed to OnPluginMsgOpenReply() because we | 122 // The callback is not directly passed to OnPluginMsgOpenReply() because we |
| 126 // would like to be able to cancel it early in Close(). | 123 // would like to be able to cancel it early in Close(). |
| 127 scoped_refptr<TrackedCallback> open_callback_; | 124 scoped_refptr<TrackedCallback> open_callback_; |
| 128 | 125 |
| 129 // Owning reference to the current config object. This isn't actually used, | 126 // Owning reference to the current config object. This isn't actually used, |
| 130 // we just dish it out as requested by the plugin. | 127 // we just dish it out as requested by the plugin. |
| 131 ScopedPPResource config_; | 128 ScopedPPResource config_; |
| 132 | 129 |
| 133 DeviceEnumerationResourceHelper enumeration_helper_; | 130 DeviceEnumerationResourceHelper enumeration_helper_; |
| 134 | 131 |
| 135 // The data size (in bytes) of one second of audio input. Used to calculate | 132 // The data size (in bytes) of one second of audio input. Used to calculate |
| 136 // latency. | 133 // latency. |
| 137 size_t bytes_per_second_; | 134 size_t bytes_per_second_; |
| 138 | 135 |
| 139 DISALLOW_COPY_AND_ASSIGN(AudioInputResource); | 136 DISALLOW_COPY_AND_ASSIGN(AudioInputResource); |
| 140 }; | 137 }; |
| 141 | 138 |
| 142 } // namespace proxy | 139 } // namespace proxy |
| 143 } // namespace ppapi | 140 } // namespace ppapi |
| 144 | 141 |
| 145 #endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ | 142 #endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ |
| OLD | NEW |