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