blob: 3a43c1ef1ee4d0e9b02b1844c95a55c6f10b7f87 [file] [log] [blame]
Avi Drissman4e1b7bc32022-09-15 14:03:501// Copyright 2012 The Chromium Authors
[email protected]937df95112010-07-30 21:24:392// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]20790a222013-07-25 02:23:055#ifndef CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_
6#define CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_
[email protected]6f2e3912010-11-05 14:45:447
avi1023d012015-12-25 02:39:148#include <stddef.h>
9#include <stdint.h>
10
[email protected]3b63f8f42011-03-28 01:54:1511#include "base/memory/ref_counted.h"
Alexandr Ilin20f2841c2018-06-01 11:56:1812#include "base/memory/unsafe_shared_memory_region.h"
[email protected]937df95112010-07-30 21:24:3913#include "base/sync_socket.h"
[email protected]20790a222013-07-25 02:23:0514#include "content/renderer/pepper/audio_helper.h"
[email protected]06417272010-11-25 00:29:2515#include "ppapi/c/pp_completion_callback.h"
[email protected]b9a59842011-01-15 01:04:0016#include "ppapi/c/ppb_audio.h"
17#include "ppapi/c/ppb_audio_config.h"
[email protected]9a578392011-12-07 18:59:2718#include "ppapi/shared_impl/ppb_audio_config_shared.h"
19#include "ppapi/shared_impl/ppb_audio_shared.h"
[email protected]56d7ad42011-12-07 00:01:3020#include "ppapi/shared_impl/resource.h"
[email protected]9a578392011-12-07 18:59:2721#include "ppapi/shared_impl/scoped_pp_resource.h"
[email protected]937df95112010-07-30 21:24:3922
[email protected]adab2332013-07-25 18:04:3223namespace content {
[email protected]c0cf2f12013-07-28 21:22:3024class PepperPlatformAudioOutput;
[email protected]937df95112010-07-30 21:24:3925
[email protected]5d84d012010-12-02 17:17:2126// Some of the backend functionality of this class is implemented by the
[email protected]9a578392011-12-07 18:59:2727// PPB_Audio_Shared so it can be shared with the proxy.
[email protected]79d816c2014-02-25 09:49:2028//
29// TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up
30// to look more like typical HostResource implementations.
[email protected]49323b32013-08-09 16:05:0631class PPB_Audio_Impl : public ppapi::Resource,
32 public ppapi::PPB_Audio_Shared,
Dave Tapuskaa361ec82020-11-02 18:08:3833 public AudioHelper {
[email protected]937df95112010-07-30 21:24:3934 public:
[email protected]bbf076f12011-08-24 15:19:3735 explicit PPB_Audio_Impl(PP_Instance instance);
[email protected]6328a5b2011-06-22 21:48:3636
Peter Boström9b036532021-10-28 23:37:2837 PPB_Audio_Impl(const PPB_Audio_Impl&) = delete;
38 PPB_Audio_Impl& operator=(const PPB_Audio_Impl&) = delete;
39
[email protected]7f8b26b2011-08-18 15:41:0140 // Resource overrides.
dcheng6d18e402014-10-21 12:32:5241 ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API() override;
[email protected]5d84d012010-12-02 17:17:2142
[email protected]55cdf6052011-05-13 19:22:5343 // PPB_Audio_API implementation.
dcheng6d18e402014-10-21 12:32:5244 PP_Resource GetCurrentConfig() override;
45 PP_Bool StartPlayback() override;
46 PP_Bool StopPlayback() override;
47 int32_t Open(PP_Resource config_id,
48 scoped_refptr<ppapi::TrackedCallback> create_callback) override;
49 int32_t GetSyncSocket(int* sync_socket) override;
Alexandr Ilin20f2841c2018-06-01 11:56:1850 int32_t GetSharedMemory(base::UnsafeSharedMemoryRegion** shm) override;
[email protected]937df95112010-07-30 21:24:3951
zqzhangc885f6b2016-06-23 19:44:4652 void SetVolume(double volume);
53
[email protected]937df95112010-07-30 21:24:3954 private:
dcheng6d18e402014-10-21 12:32:5255 ~PPB_Audio_Impl() override;
[email protected]20790a222013-07-25 02:23:0556
[email protected]1f8a0892011-11-18 00:14:2457 // AudioHelper implementation.
Alexandr Ilin20f2841c2018-06-01 11:56:1858 void OnSetStreamInfo(base::UnsafeSharedMemoryRegion shared_memory_region,
Robert Sesek8dd06452020-02-19 01:10:4959 base::SyncSocket::ScopedHandle socket) override;
[email protected]b0deb152010-08-31 17:37:3560
[email protected]55cdf6052011-05-13 19:22:5361 // AudioConfig used for creating this Audio object. We own a ref.
[email protected]49323b32013-08-09 16:05:0662 ppapi::ScopedPPResource config_;
[email protected]937df95112010-07-30 21:24:3963
[email protected]9ca245e2011-03-18 01:50:3164 // PluginDelegate audio object that we delegate audio IPC through. We don't
65 // own this pointer but are responsible for calling Shutdown on it.
[email protected]c0cf2f12013-07-28 21:22:3066 PepperPlatformAudioOutput* audio_;
[email protected]937df95112010-07-30 21:24:3967};
68
[email protected]adab2332013-07-25 18:04:3269} // namespace content
[email protected]937df95112010-07-30 21:24:3970
[email protected]20790a222013-07-25 02:23:0571#endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_