Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ppapi / proxy / ppb_audio_proxy.h
blobcc8af6cb9daeafb728143d3448e7dcc383e57c3c
1 // Copyright (c) 2012 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.
5 #ifndef PPAPI_PROXY_PPB_AUDIO_PROXY_H_
6 #define PPAPI_PROXY_PPB_AUDIO_PROXY_H_
8 #include <utility>
10 #include "base/basictypes.h"
11 #include "base/memory/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_resource.h"
16 #include "ppapi/c/ppb_audio.h"
17 #include "ppapi/c/ppb_audio_config.h"
18 #include "ppapi/proxy/interface_proxy.h"
19 #include "ppapi/proxy/proxy_completion_callback_factory.h"
20 #include "ppapi/utility/completion_callback_factory.h"
22 namespace ppapi {
24 class AudioCallbackCombined;
25 class HostResource;
27 namespace proxy {
29 class SerializedHandle;
31 class PPB_Audio_Proxy : public InterfaceProxy {
32 public:
33 PPB_Audio_Proxy(Dispatcher* dispatcher);
34 virtual ~PPB_Audio_Proxy();
36 // Creates an Audio object in the plugin process.
37 static PP_Resource CreateProxyResource(
38 PP_Instance instance_id,
39 PP_Resource config_id,
40 const AudioCallbackCombined& audio_callback,
41 void* user_data);
43 // InterfaceProxy implementation.
44 virtual bool OnMessageReceived(const IPC::Message& msg);
46 static const ApiID kApiID = API_ID_PPB_AUDIO;
48 private:
49 // Plugin->renderer message handlers.
50 void OnMsgCreate(PP_Instance instance_id,
51 int32_t sample_rate,
52 uint32_t sample_frame_count,
53 ppapi::HostResource* result);
54 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play);
56 // Renderer->plugin message handlers.
57 void OnMsgNotifyAudioStreamCreated(
58 const ppapi::HostResource& audio_id,
59 int32_t result_code,
60 ppapi::proxy::SerializedHandle socket_handle,
61 ppapi::proxy::SerializedHandle handle);
63 void AudioChannelConnected(int32_t result,
64 const ppapi::HostResource& resource);
66 // In the renderer, this is called in response to a stream created message.
67 // It will retrieve the shared memory and socket handles and place them into
68 // the given out params. The return value is a PPAPI error code.
70 // The input arguments should be initialized to 0 or -1, depending on the
71 // platform's default invalid handle values. On error, some of these
72 // arguments may be written to, and others may be untouched, depending on
73 // where the error occurred.
74 int32_t GetAudioConnectedHandles(
75 const ppapi::HostResource& resource,
76 IPC::PlatformFileForTransit* foreign_socket_handle,
77 base::SharedMemoryHandle* foreign_shared_memory_handle,
78 uint32_t* shared_memory_length);
80 ProxyCompletionCallbackFactory<PPB_Audio_Proxy> callback_factory_;
82 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy);
85 } // namespace proxy
86 } // namespace ppapi
88 #endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_