[email protected] | 25651387 | 2012-01-05 15:41:52 | [diff] [blame] | 1 | // Copyright (c) 2012 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 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame^] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 10 | #include <utility> |
| 11 | |
avi | e029c413 | 2015-12-23 06:45:22 | [diff] [blame^] | 12 | #include "base/macros.h" |
[email protected] | 8299b71 | 2013-07-17 19:55:23 | [diff] [blame] | 13 | #include "base/memory/shared_memory.h" |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 14 | #include "base/sync_socket.h" |
| 15 | #include "ipc/ipc_platform_file.h" |
| 16 | #include "ppapi/c/pp_instance.h" |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 17 | #include "ppapi/c/pp_resource.h" |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 18 | #include "ppapi/c/ppb_audio.h" |
[email protected] | ae5ff9ae | 2012-01-06 22:50:33 | [diff] [blame] | 19 | #include "ppapi/c/ppb_audio_config.h" |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 20 | #include "ppapi/proxy/interface_proxy.h" |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 21 | #include "ppapi/proxy/proxy_completion_callback_factory.h" |
[email protected] | ae5ff9ae | 2012-01-06 22:50:33 | [diff] [blame] | 22 | #include "ppapi/utility/completion_callback_factory.h" |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 23 | |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 24 | namespace ppapi { |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 25 | |
[email protected] | 6b151126 | 2013-09-06 21:46:34 | [diff] [blame] | 26 | class AudioCallbackCombined; |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 27 | class HostResource; |
| 28 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 29 | namespace proxy { |
| 30 | |
[email protected] | eb5960da | 2013-01-16 23:23:53 | [diff] [blame] | 31 | class SerializedHandle; |
| 32 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 33 | class PPB_Audio_Proxy : public InterfaceProxy { |
| 34 | public: |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 35 | PPB_Audio_Proxy(Dispatcher* dispatcher); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 36 | virtual ~PPB_Audio_Proxy(); |
| 37 | |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 38 | // Creates an Audio object in the plugin process. |
[email protected] | 6b151126 | 2013-09-06 21:46:34 | [diff] [blame] | 39 | static PP_Resource CreateProxyResource( |
| 40 | PP_Instance instance_id, |
| 41 | PP_Resource config_id, |
| 42 | const AudioCallbackCombined& audio_callback, |
| 43 | void* user_data); |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 44 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 45 | // InterfaceProxy implementation. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 46 | virtual bool OnMessageReceived(const IPC::Message& msg); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 47 | |
[email protected] | ac4b54d | 2011-10-20 23:09:28 | [diff] [blame] | 48 | static const ApiID kApiID = API_ID_PPB_AUDIO; |
[email protected] | 5c96602 | 2011-09-13 18:09:37 | [diff] [blame] | 49 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 50 | private: |
| 51 | // Plugin->renderer message handlers. |
| 52 | void OnMsgCreate(PP_Instance instance_id, |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 53 | int32_t sample_rate, |
| 54 | uint32_t sample_frame_count, |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 55 | ppapi::HostResource* result); |
| 56 | void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 57 | |
| 58 | // Renderer->plugin message handlers. |
[email protected] | 246fc49 | 2012-08-27 20:28:18 | [diff] [blame] | 59 | void OnMsgNotifyAudioStreamCreated( |
| 60 | const ppapi::HostResource& audio_id, |
| 61 | int32_t result_code, |
| 62 | ppapi::proxy::SerializedHandle socket_handle, |
| 63 | ppapi::proxy::SerializedHandle handle); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 64 | |
[email protected] | f24448db | 2011-01-27 20:40:39 | [diff] [blame] | 65 | void AudioChannelConnected(int32_t result, |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 66 | const ppapi::HostResource& resource); |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 67 | |
| 68 | // In the renderer, this is called in response to a stream created message. |
| 69 | // It will retrieve the shared memory and socket handles and place them into |
| 70 | // the given out params. The return value is a PPAPI error code. |
| 71 | // |
| 72 | // The input arguments should be initialized to 0 or -1, depending on the |
| 73 | // platform's default invalid handle values. On error, some of these |
| 74 | // arguments may be written to, and others may be untouched, depending on |
| 75 | // where the error occurred. |
| 76 | int32_t GetAudioConnectedHandles( |
[email protected] | be0a84b | 2011-08-13 04:18:44 | [diff] [blame] | 77 | const ppapi::HostResource& resource, |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 78 | IPC::PlatformFileForTransit* foreign_socket_handle, |
| 79 | base::SharedMemoryHandle* foreign_shared_memory_handle, |
| 80 | uint32_t* shared_memory_length); |
| 81 | |
[email protected] | 47a961c | 2012-07-13 19:18:52 | [diff] [blame] | 82 | ProxyCompletionCallbackFactory<PPB_Audio_Proxy> callback_factory_; |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 83 | |
| 84 | DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy); |
| 85 | }; |
| 86 | |
| 87 | } // namespace proxy |
[email protected] | 4d2efd2 | 2011-08-18 21:58:02 | [diff] [blame] | 88 | } // namespace ppapi |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 89 | |
| 90 | #endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_ |