blob: 7948b9cb8804116a14cb9de97caf0592088c3f35 [file] [log] [blame]
[email protected]f24448db2011-01-27 20:40:391// Copyright (c) 2011 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"
15#include "ppapi/c/pp_module.h"
16#include "ppapi/c/pp_resource.h"
[email protected]55cdf6052011-05-13 19:22:5317#include "ppapi/c/ppb_audio.h"
18#include "ppapi/c/ppb_audio_config.h"
[email protected]5d84d012010-12-02 17:17:2119#include "ppapi/cpp/completion_callback.h"
20#include "ppapi/proxy/interface_proxy.h"
21#include "ppapi/proxy/proxy_non_thread_safe_ref_count.h"
22
[email protected]b9a59842011-01-15 01:04:0023struct PPB_Audio;
[email protected]5d84d012010-12-02 17:17:2124
[email protected]be0a84b2011-08-13 04:18:4425namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4426
[email protected]4d2efd22011-08-18 21:58:0227class HostResource;
28
[email protected]5d84d012010-12-02 17:17:2129namespace proxy {
30
31class PPB_Audio_Proxy : public InterfaceProxy {
32 public:
33 PPB_Audio_Proxy(Dispatcher* dispatcher, const void* target_interface);
34 virtual ~PPB_Audio_Proxy();
35
[email protected]465faa22011-02-08 16:31:4636 static const Info* GetInfo();
37
[email protected]55cdf6052011-05-13 19:22:5338 // Creates an Audio object in the plugin process.
39 static PP_Resource CreateProxyResource(PP_Instance instance_id,
40 PP_Resource config_id,
41 PPB_Audio_Callback audio_callback,
42 void* user_data);
43
44
[email protected]b9a59842011-01-15 01:04:0045 const PPB_Audio* ppb_audio_target() const {
46 return static_cast<const PPB_Audio*>(target_interface());
[email protected]5d84d012010-12-02 17:17:2147 }
48
49 // InterfaceProxy implementation.
[email protected]a95986a82010-12-24 06:19:2850 virtual bool OnMessageReceived(const IPC::Message& msg);
[email protected]5d84d012010-12-02 17:17:2151
52 private:
53 // Plugin->renderer message handlers.
54 void OnMsgCreate(PP_Instance instance_id,
[email protected]55cdf6052011-05-13 19:22:5355 int32_t sample_rate,
56 uint32_t sample_frame_count,
[email protected]be0a84b2011-08-13 04:18:4457 ppapi::HostResource* result);
58 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play);
[email protected]5d84d012010-12-02 17:17:2159
60 // Renderer->plugin message handlers.
[email protected]be0a84b2011-08-13 04:18:4461 void OnMsgNotifyAudioStreamCreated(const ppapi::HostResource& audio_id,
[email protected]2031aeb2011-01-28 20:01:1662 int32_t result_code,
63 IPC::PlatformFileForTransit socket_handle,
64 base::SharedMemoryHandle handle,
65 uint32_t length);
[email protected]5d84d012010-12-02 17:17:2166
[email protected]f24448db2011-01-27 20:40:3967 void AudioChannelConnected(int32_t result,
[email protected]be0a84b2011-08-13 04:18:4468 const ppapi::HostResource& resource);
[email protected]5d84d012010-12-02 17:17:2169
70 // In the renderer, this is called in response to a stream created message.
71 // It will retrieve the shared memory and socket handles and place them into
72 // the given out params. The return value is a PPAPI error code.
73 //
74 // The input arguments should be initialized to 0 or -1, depending on the
75 // platform's default invalid handle values. On error, some of these
76 // arguments may be written to, and others may be untouched, depending on
77 // where the error occurred.
78 int32_t GetAudioConnectedHandles(
[email protected]be0a84b2011-08-13 04:18:4479 const ppapi::HostResource& resource,
[email protected]5d84d012010-12-02 17:17:2180 IPC::PlatformFileForTransit* foreign_socket_handle,
81 base::SharedMemoryHandle* foreign_shared_memory_handle,
82 uint32_t* shared_memory_length);
83
[email protected]4d2efd22011-08-18 21:58:0284 pp::CompletionCallbackFactory<PPB_Audio_Proxy,
85 ProxyNonThreadSafeRefCount> callback_factory_;
[email protected]5d84d012010-12-02 17:17:2186
87 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy);
88};
89
90} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0291} // namespace ppapi
[email protected]5d84d012010-12-02 17:17:2192
93#endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_