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/cpp/completion_callback.h" |
| 16 #include "ppapi/proxy/interface_proxy.h" |
| 17 #include "ppapi/proxy/proxy_non_thread_safe_ref_count.h" |
| 18 |
| 19 |
| 20 struct PPB_AudioInput_Dev; |
| 21 |
| 22 namespace ppapi { |
| 23 |
| 24 class HostResource; |
| 25 |
| 26 namespace proxy { |
| 27 |
| 28 class PPB_AudioInput_Proxy : public InterfaceProxy { |
| 29 public: |
| 30 PPB_AudioInput_Proxy(Dispatcher* dispatcher); |
| 31 virtual ~PPB_AudioInput_Proxy(); |
| 32 |
| 33 static PP_Resource CreateProxyResource(PP_Instance instance, |
| 34 PPB_AudioInput_Callback audio_input_cal
lback, |
| 35 void* user_data); |
| 36 |
| 37 // InterfaceProxy implementation. |
| 38 virtual bool OnMessageReceived(const IPC::Message& msg); |
| 39 |
| 40 static const InterfaceID kInterfaceID = INTERFACE_ID_PPB_AUDIO_INPUT_DEV; |
| 41 |
| 42 private: |
| 43 // Message handlers. |
| 44 // Plugin->renderer message handlers. |
| 45 void OnMsgCreate(PP_Instance instance_id, |
| 46 ppapi::HostResource* result); |
| 47 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool capture); |
| 48 |
| 49 // Renderer->plugin message handlers. |
| 50 void OnMsgNotifyAudioStreamCreated(const ppapi::HostResource& audio_id, |
| 51 int32_t result_code, |
| 52 IPC::PlatformFileForTransit socket_handle, |
| 53 base::SharedMemoryHandle handle, |
| 54 uint32_t length); |
| 55 |
| 56 void AudioInputChannelConnected(int32_t result, |
| 57 const ppapi::HostResource& resource); |
| 58 |
| 59 // In the renderer, this is called in response to a stream created message. |
| 60 // It will retrieve the shared memory and socket handles and place them into |
| 61 // the given out params. The return value is a PPAPI error code. |
| 62 // |
| 63 // The input arguments should be initialized to 0 or -1, depending on the |
| 64 // platform's default invalid handle values. On error, some of these |
| 65 // arguments may be written to, and others may be untouched, depending on |
| 66 // where the error occurred. |
| 67 int32_t GetAudioInputConnectedHandles( |
| 68 const ppapi::HostResource& resource, |
| 69 IPC::PlatformFileForTransit* foreign_socket_handle, |
| 70 base::SharedMemoryHandle* foreign_shared_memory_handle, |
| 71 uint32_t* shared_memory_length); |
| 72 |
| 73 pp::CompletionCallbackFactory<PPB_AudioInput_Proxy, |
| 74 ProxyNonThreadSafeRefCount> callback_factory_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Proxy); |
| 77 }; |
| 78 |
| 79 } // namespace proxy |
| 80 } // namespace ppapi |
| 81 |
| 82 #endif // PPAPI_PPB_AUDIO_INPUT_PROXY_H_ |
OLD | NEW |