[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 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_PROXY_PPB_AUDIO_PROXY_H_ |
| 6 | #define PPAPI_PROXY_PPB_AUDIO_PROXY_H_ |
| 7 | |
| 8 | #include "base/basictypes.h" |
| 9 | #include "base/shared_memory.h" |
| 10 | #include "base/sync_socket.h" |
| 11 | #include "ipc/ipc_platform_file.h" |
| 12 | #include "ppapi/c/pp_instance.h" |
| 13 | #include "ppapi/c/pp_module.h" |
| 14 | #include "ppapi/c/pp_resource.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 | |
[email protected] | b9a5984 | 2011-01-15 01:04:00 | [diff] [blame] | 19 | struct PPB_Audio; |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 20 | |
| 21 | namespace pp { |
| 22 | namespace proxy { |
| 23 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame^] | 24 | struct PPBAudio_NotifyAudioStreamCreated_Params; |
| 25 | class HostResource; |
| 26 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 27 | class PPB_Audio_Proxy : public InterfaceProxy { |
| 28 | public: |
| 29 | PPB_Audio_Proxy(Dispatcher* dispatcher, const void* target_interface); |
| 30 | virtual ~PPB_Audio_Proxy(); |
| 31 | |
[email protected] | b9a5984 | 2011-01-15 01:04:00 | [diff] [blame] | 32 | const PPB_Audio* ppb_audio_target() const { |
| 33 | return static_cast<const PPB_Audio*>(target_interface()); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | // InterfaceProxy implementation. |
| 37 | virtual const void* GetSourceInterface() const; |
| 38 | virtual InterfaceID GetInterfaceId() const; |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 39 | virtual bool OnMessageReceived(const IPC::Message& msg); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 40 | |
| 41 | private: |
| 42 | // Plugin->renderer message handlers. |
| 43 | void OnMsgCreate(PP_Instance instance_id, |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame^] | 44 | const HostResource& config_id, |
| 45 | HostResource* result); |
| 46 | void OnMsgStartOrStop(const HostResource& audio_id, bool play); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 47 | |
| 48 | // Renderer->plugin message handlers. |
| 49 | void OnMsgNotifyAudioStreamCreated( |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame^] | 50 | const PPBAudio_NotifyAudioStreamCreated_Params& params); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 51 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame^] | 52 | void AudioChannelConnected(int32_t result, |
| 53 | const HostResource& resource); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 54 | |
| 55 | // In the renderer, this is called in response to a stream created message. |
| 56 | // It will retrieve the shared memory and socket handles and place them into |
| 57 | // the given out params. The return value is a PPAPI error code. |
| 58 | // |
| 59 | // The input arguments should be initialized to 0 or -1, depending on the |
| 60 | // platform's default invalid handle values. On error, some of these |
| 61 | // arguments may be written to, and others may be untouched, depending on |
| 62 | // where the error occurred. |
| 63 | int32_t GetAudioConnectedHandles( |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame^] | 64 | const HostResource& resource, |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 65 | IPC::PlatformFileForTransit* foreign_socket_handle, |
| 66 | base::SharedMemoryHandle* foreign_shared_memory_handle, |
| 67 | uint32_t* shared_memory_length); |
| 68 | |
| 69 | CompletionCallbackFactory<PPB_Audio_Proxy, |
| 70 | ProxyNonThreadSafeRefCount> callback_factory_; |
| 71 | |
| 72 | DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy); |
| 73 | }; |
| 74 | |
| 75 | } // namespace proxy |
| 76 | } // namespace pp |
| 77 | |
| 78 | #endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_ |