blob: 2082c7e6ed1098e0468e75f02717f1c8d9006d53 [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
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
[email protected]55cdf6052011-05-13 19:22:5310#include <utility>
11
avie029c4132015-12-23 06:45:2212#include "base/macros.h"
Alexandr Ilin20f2841c2018-06-01 11:56:1813#include "base/memory/unsafe_shared_memory_region.h"
[email protected]5d84d012010-12-02 17:17:2114#include "base/sync_socket.h"
15#include "ipc/ipc_platform_file.h"
16#include "ppapi/c/pp_instance.h"
[email protected]5d84d012010-12-02 17:17:2117#include "ppapi/c/pp_resource.h"
[email protected]55cdf6052011-05-13 19:22:5318#include "ppapi/c/ppb_audio.h"
[email protected]ae5ff9ae2012-01-06 22:50:3319#include "ppapi/c/ppb_audio_config.h"
[email protected]5d84d012010-12-02 17:17:2120#include "ppapi/proxy/interface_proxy.h"
[email protected]47a961c2012-07-13 19:18:5221#include "ppapi/proxy/proxy_completion_callback_factory.h"
[email protected]ae5ff9ae2012-01-06 22:50:3322#include "ppapi/utility/completion_callback_factory.h"
[email protected]5d84d012010-12-02 17:17:2123
[email protected]be0a84b2011-08-13 04:18:4424namespace ppapi {
[email protected]be0a84b2011-08-13 04:18:4425
[email protected]6b1511262013-09-06 21:46:3426class AudioCallbackCombined;
[email protected]4d2efd22011-08-18 21:58:0227class HostResource;
28
[email protected]5d84d012010-12-02 17:17:2129namespace proxy {
30
[email protected]eb5960da2013-01-16 23:23:5331class SerializedHandle;
32
[email protected]5d84d012010-12-02 17:17:2133class PPB_Audio_Proxy : public InterfaceProxy {
34 public:
Lei Zhang94f57fe32017-08-30 23:58:2435 explicit PPB_Audio_Proxy(Dispatcher* dispatcher);
36 ~PPB_Audio_Proxy() override;
[email protected]5d84d012010-12-02 17:17:2137
[email protected]55cdf6052011-05-13 19:22:5338 // Creates an Audio object in the plugin process.
[email protected]6b1511262013-09-06 21:46:3439 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]55cdf6052011-05-13 19:22:5344
[email protected]5d84d012010-12-02 17:17:2145 // InterfaceProxy implementation.
Lei Zhang94f57fe32017-08-30 23:58:2446 bool OnMessageReceived(const IPC::Message& msg) override;
[email protected]5d84d012010-12-02 17:17:2147
[email protected]ac4b54d2011-10-20 23:09:2848 static const ApiID kApiID = API_ID_PPB_AUDIO;
[email protected]5c966022011-09-13 18:09:3749
[email protected]5d84d012010-12-02 17:17:2150 private:
51 // Plugin->renderer message handlers.
52 void OnMsgCreate(PP_Instance instance_id,
[email protected]55cdf6052011-05-13 19:22:5353 int32_t sample_rate,
54 uint32_t sample_frame_count,
[email protected]be0a84b2011-08-13 04:18:4455 ppapi::HostResource* result);
56 void OnMsgStartOrStop(const ppapi::HostResource& audio_id, bool play);
[email protected]5d84d012010-12-02 17:17:2157
58 // Renderer->plugin message handlers.
[email protected]246fc492012-08-27 20:28:1859 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]5d84d012010-12-02 17:17:2164
[email protected]f24448db2011-01-27 20:40:3965 void AudioChannelConnected(int32_t result,
[email protected]be0a84b2011-08-13 04:18:4466 const ppapi::HostResource& resource);
[email protected]5d84d012010-12-02 17:17:2167
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]be0a84b2011-08-13 04:18:4477 const ppapi::HostResource& resource,
[email protected]5d84d012010-12-02 17:17:2178 IPC::PlatformFileForTransit* foreign_socket_handle,
Alexandr Ilin20f2841c2018-06-01 11:56:1879 base::UnsafeSharedMemoryRegion* foreign_shared_memory_region);
[email protected]5d84d012010-12-02 17:17:2180
[email protected]47a961c2012-07-13 19:18:5281 ProxyCompletionCallbackFactory<PPB_Audio_Proxy> callback_factory_;
[email protected]5d84d012010-12-02 17:17:2182
83 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Proxy);
84};
85
86} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0287} // namespace ppapi
[email protected]5d84d012010-12-02 17:17:2188
89#endif // PPAPI_PROXY_PPB_AUDIO_PROXY_H_