blob: 757bdeb8686a381756458f58ae806bdd410e59bc [file] [log] [blame]
[email protected]256513872012-01-05 15:41:521// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]5d84d012010-12-02 17:17:212// 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
[email protected]55cdf6052011-05-13 19:22:538#include <utility>
9
[email protected]5d84d012010-12-02 17:17:2110#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/pp_instance.h"
[email protected]5d84d012010-12-02 17:17:2115#include "ppapi/c/pp_resource.h"
[email protected]55cdf6052011-05-13 19:22:5316#include "ppapi/c/ppb_audio.h"
[email protected]ae5ff9ae2012-01-06 22:50:3317#include "ppapi/c/ppb_audio_config.h"
[email protected]5d84d012010-12-02 17:17:2118#include "ppapi/proxy/interface_proxy.h"
[email protected]47a961c2012-07-13 19:18:5219#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]ae5ff9ae2012-01-06 22:50:3320#include "ppapi/utility/completion_callback_factory.h"
[email protected]5d84d012010-12-02 17:17:2121
[email protected]be0a84b2011-08-13 04:18:4422namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4423
[email protected]4d2efd22011-08-18 21:58:0224class HostResource;
25
[email protected]5d84d012010-12-02 17:17:2126namespace proxy {
27
[email protected]eb5960da2013-01-16 23:23:5328class SerializedHandle;
29
[email protected]5d84d012010-12-02 17:17:2130class PPB_Audio_Proxy : public InterfaceProxy {
31 public:
[email protected]5c966022011-09-13 18:09:3732 PPB_Audio_Proxy(Dispatcher* dispatcher);
[email protected]5d84d012010-12-02 17:17:2133 virtual ~PPB_Audio_Proxy();
34
[email protected]55cdf6052011-05-13 19:22:5335 // Creates an Audio object in the plugin process.
36 static PP_Resource CreateProxyResource(PP_Instance instance_id,
37 PP_Resource config_id,
38 PPB_Audio_Callback audio_callback,
39 void* user_data);
40
41
[email protected]5d84d012010-12-02 17:17:2142 // InterfaceProxy implementation.
[email protected]a95986a82010-12-24 06:19:2843 virtual bool OnMessageReceived(const IPC::Message& msg);
[email protected]5d84d012010-12-02 17:17:2144
[email protected]ac4b54d2011-10-20 23:09:2845 static const ApiID kApiID = API_ID_PPB_AUDIO;
[email protected]5c966022011-09-13 18:09:3746
[email protected]5d84d012010-12-02 17:17:2147 private:
48 // Plugin->renderer message handlers.
49 void OnMsgCreate(PP_Instance instance_id,
[email protected]55cdf6052011-05-13 19:22:5350 int32_t sample_rate,
51 uint32_t sample_frame_count,
[email protected]be0a84b2011-08-13 04:18:4452 ppapi::HostResource* result);
53 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play);
[email protected]5d84d012010-12-02 17:17:2154
55 // Renderer->plugin message handlers.
[email protected]246fc492012-08-27 20:28:1856 void OnMsgNotifyAudioStreamCreated(
57 const ppapi::HostResource& audio_id,
58 int32_t result_code,
59 ppapi::proxy::SerializedHandle socket_handle,
60 ppapi::proxy::SerializedHandle handle);
[email protected]5d84d012010-12-02 17:17:2161
[email protected]f24448db2011-01-27 20:40:3962 void AudioChannelConnected(int32_t result,
[email protected]be0a84b2011-08-13 04:18:4463 const ppapi::HostResource& resource);
[email protected]5d84d012010-12-02 17:17:2164
65 // In the renderer, this is called in response to a stream created message.
66 // It will retrieve the shared memory and socket handles and place them into
67 // the given out params. The return value is a PPAPI error code.
68 //
69 // The input arguments should be initialized to 0 or -1, depending on the
70 // platform's default invalid handle values. On error, some of these
71 // arguments may be written to, and others may be untouched, depending on
72 // where the error occurred.
73 int32_t GetAudioConnectedHandles(
[email protected]be0a84b2011-08-13 04:18:4474 const ppapi::HostResource& resource,
[email protected]5d84d012010-12-02 17:17:2175 IPC::PlatformFileForTransit* foreign_socket_handle,
76 base::SharedMemoryHandle* foreign_shared_memory_handle,
77 uint32_t* shared_memory_length);
78
[email protected]47a961c2012-07-13 19:18:5279 ProxyCompletionCallbackFactory<PPB_Audio_Proxy> callback_factory_;
[email protected]5d84d012010-12-02 17:17:2180
81 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy);
82};
83
84} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0285} // namespace ppapi
[email protected]5d84d012010-12-02 17:17:2186
87#endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_