| 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_PPB_AUDIO_INPUT_PROXY_H_ | 5 #ifndef PPAPI_PPB_AUDIO_INPUT_PROXY_H_ |
| 6 #define PPAPI_PPB_AUDIO_INPUT_PROXY_H_ | 6 #define PPAPI_PPB_AUDIO_INPUT_PROXY_H_ |
| 7 | 7 |
| 8 #include <string> |
| 8 #include <utility> | 9 #include <utility> |
| 10 #include <vector> |
| 9 | 11 |
| 10 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 11 #include "base/shared_memory.h" | 13 #include "base/shared_memory.h" |
| 12 #include "base/sync_socket.h" | 14 #include "base/sync_socket.h" |
| 13 #include "ipc/ipc_platform_file.h" | 15 #include "ipc/ipc_platform_file.h" |
| 14 #include "ppapi/c/dev/ppb_audio_input_dev.h" | 16 #include "ppapi/c/dev/ppb_audio_input_dev.h" |
| 15 #include "ppapi/c/ppb_audio_config.h" | 17 #include "ppapi/c/ppb_audio_config.h" |
| 16 #include "ppapi/proxy/interface_proxy.h" | 18 #include "ppapi/proxy/interface_proxy.h" |
| 17 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" | 19 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" |
| 18 #include "ppapi/utility/completion_callback_factory.h" | 20 #include "ppapi/utility/completion_callback_factory.h" |
| 19 | 21 |
| 20 namespace ppapi { | 22 namespace ppapi { |
| 21 | 23 |
| 22 class HostResource; | 24 class HostResource; |
| 25 struct DeviceRefData; |
| 23 | 26 |
| 24 namespace proxy { | 27 namespace proxy { |
| 25 | 28 |
| 26 class PPB_AudioInput_Proxy : public InterfaceProxy { | 29 class PPB_AudioInput_Proxy : public InterfaceProxy { |
| 27 public: | 30 public: |
| 28 explicit PPB_AudioInput_Proxy(Dispatcher* dispatcher); | 31 explicit PPB_AudioInput_Proxy(Dispatcher* dispatcher); |
| 29 virtual ~PPB_AudioInput_Proxy(); | 32 virtual ~PPB_AudioInput_Proxy(); |
| 30 | 33 |
| 31 static PP_Resource CreateProxyResource( | 34 static PP_Resource CreateProxyResource0_1( |
| 32 PP_Instance instance, | 35 PP_Instance instance, |
| 33 PP_Resource config_id, | 36 PP_Resource config, |
| 34 PPB_AudioInput_Callback audio_input_callback, | 37 PPB_AudioInput_Callback audio_input_callback, |
| 35 void* user_data); | 38 void* user_data); |
| 36 | 39 |
| 40 static PP_Resource CreateProxyResource(PP_Instance instance); |
| 41 |
| 37 // InterfaceProxy implementation. | 42 // InterfaceProxy implementation. |
| 38 virtual bool OnMessageReceived(const IPC::Message& msg); | 43 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 39 | 44 |
| 40 static const ApiID kApiID = API_ID_PPB_AUDIO_INPUT_DEV; | 45 static const ApiID kApiID = API_ID_PPB_AUDIO_INPUT_DEV; |
| 41 | 46 |
| 42 private: | 47 private: |
| 43 // Message handlers. | 48 // Message handlers. |
| 44 // Plugin->renderer message handlers. | 49 // Plugin->renderer message handlers. |
| 45 void OnMsgCreate(PP_Instance instance_id, | 50 void OnMsgCreate(PP_Instance instance, ppapi::HostResource* result); |
| 46 int32_t sample_rate, | 51 void OnMsgEnumerateDevices(const ppapi::HostResource& audio_input); |
| 47 uint32_t sample_frame_count, | 52 void OnMsgOpen(const ppapi::HostResource& audio_input, |
| 48 ppapi::HostResource* result); | 53 const std::string& device_id, |
| 49 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool capture); | 54 int32_t sample_rate, |
| 55 uint32_t sample_frame_count); |
| 56 void OnMsgStartOrStop(const ppapi::HostResource& audio_input, bool capture); |
| 57 void OnMsgClose(const ppapi::HostResource& audio_input); |
| 50 | 58 |
| 51 // Renderer->plugin message handlers. | 59 // Renderer->plugin message handlers. |
| 52 void OnMsgNotifyAudioStreamCreated(const ppapi::HostResource& audio_id, | 60 void OnMsgEnumerateDevicesACK( |
| 53 int32_t result_code, | 61 const ppapi::HostResource& audio_input, |
| 54 IPC::PlatformFileForTransit socket_handle, | 62 int32_t result, |
| 55 base::SharedMemoryHandle handle, | 63 const std::vector<ppapi::DeviceRefData>& devices); |
| 56 uint32_t length); | 64 void OnMsgOpenACK(const ppapi::HostResource& audio_input, |
| 65 int32_t result, |
| 66 IPC::PlatformFileForTransit socket_handle, |
| 67 base::SharedMemoryHandle handle, |
| 68 uint32_t length); |
| 57 | 69 |
| 58 void AudioInputChannelConnected(int32_t result, | 70 void EnumerateDevicesACKInHost(int32_t result, |
| 59 const ppapi::HostResource& resource); | 71 const ppapi::HostResource& audio_input); |
| 72 void OpenACKInHost(int32_t result, const ppapi::HostResource& audio_input); |
| 60 | 73 |
| 61 // In the renderer, this is called in response to a stream created message. | 74 // In the renderer, this is called in response to an OpenACK message. |
| 62 // It will retrieve the shared memory and socket handles and place them into | 75 // It will retrieve the shared memory and socket handles and place them into |
| 63 // the given out params. The return value is a PPAPI error code. | 76 // the given out params. The return value is a PPAPI error code. |
| 64 // | 77 // |
| 65 // The input arguments should be initialized to 0 or -1, depending on the | 78 // The input arguments should be initialized to 0 or -1, depending on the |
| 66 // platform's default invalid handle values. On error, some of these | 79 // platform's default invalid handle values. On error, some of these |
| 67 // arguments may be written to, and others may be untouched, depending on | 80 // arguments may be written to, and others may be untouched, depending on |
| 68 // where the error occurred. | 81 // where the error occurred. |
| 69 int32_t GetAudioInputConnectedHandles( | 82 int32_t GetAudioInputConnectedHandles( |
| 70 const ppapi::HostResource& resource, | 83 const ppapi::HostResource& resource, |
| 71 IPC::PlatformFileForTransit* foreign_socket_handle, | 84 IPC::PlatformFileForTransit* foreign_socket_handle, |
| 72 base::SharedMemoryHandle* foreign_shared_memory_handle, | 85 base::SharedMemoryHandle* foreign_shared_memory_handle, |
| 73 uint32_t* shared_memory_length); | 86 uint32_t* shared_memory_length); |
| 74 | 87 |
| 75 pp::CompletionCallbackFactory<PPB_AudioInput_Proxy, | 88 pp::CompletionCallbackFactory<PPB_AudioInput_Proxy, |
| 76 ProxyNonThreadSafeRefCount> callback_factory_; | 89 ProxyNonThreadSafeRefCount> callback_factory_; |
| 77 | 90 |
| 78 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Proxy); | 91 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Proxy); |
| 79 }; | 92 }; |
| 80 | 93 |
| 81 } // namespace proxy | 94 } // namespace proxy |
| 82 } // namespace ppapi | 95 } // namespace ppapi |
| 83 | 96 |
| 84 #endif // PPAPI_PPB_AUDIO_INPUT_PROXY_H_ | 97 #endif // PPAPI_PPB_AUDIO_INPUT_PROXY_H_ |
| OLD | NEW |