blob: 830e87b92c97864744be8a704e7aecd2171d7e27 [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
Kalvin Leebc3754ae2023-10-01 22:37:3411#include "base/memory/raw_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1512#include "base/memory/ref_counted.h"
Alexandr Ilin20f2841c2018-06-01 11:56:1813#include "base/memory/unsafe_shared_memory_region.h"
[email protected]937df95112010-07-30 21:24:3914#include "base/sync_socket.h"
[email protected]20790a222013-07-25 02:23:0515#include "content/renderer/pepper/audio_helper.h"
[email protected]06417272010-11-25 00:29:2516#include "ppapi/c/pp_completion_callback.h"
[email protected]b9a59842011-01-15 01:04:0017#include "ppapi/c/ppb_audio.h"
18#include "ppapi/c/ppb_audio_config.h"
[email protected]9a578392011-12-07 18:59:2719#include "ppapi/shared_impl/ppb_audio_config_shared.h"
20#include "ppapi/shared_impl/ppb_audio_shared.h"
[email protected]56d7ad42011-12-07 00:01:3021#include "ppapi/shared_impl/resource.h"
[email protected]9a578392011-12-07 18:59:2722#include "ppapi/shared_impl/scoped_pp_resource.h"
[email protected]937df95112010-07-30 21:24:3923
[email protected]adab2332013-07-25 18:04:3224namespace content {
[email protected]c0cf2f12013-07-28 21:22:3025class PepperPlatformAudioOutput;
[email protected]937df95112010-07-30 21:24:3926
[email protected]5d84d012010-12-02 17:17:2127// Some of the backend functionality of this class is implemented by the
[email protected]9a578392011-12-07 18:59:2728// PPB_Audio_Shared so it can be shared with the proxy.
[email protected]79d816c2014-02-25 09:49:2029//
30// TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up
31// to look more like typical HostResource implementations.
[email protected]49323b32013-08-09 16:05:0632class PPB_Audio_Impl : public ppapi::Resource,
33 public ppapi::PPB_Audio_Shared,
Dave Tapuskaa361ec82020-11-02 18:08:3834 public AudioHelper {
[email protected]937df95112010-07-30 21:24:3935 public:
[email protected]bbf076f12011-08-24 15:19:3736 explicit PPB_Audio_Impl(PP_Instance instance);
[email protected]6328a5b2011-06-22 21:48:3637
Peter Boström9b036532021-10-28 23:37:2838 PPB_Audio_Impl(const PPB_Audio_Impl&) = delete;
39 PPB_Audio_Impl& operator=(const PPB_Audio_Impl&) = delete;
40
[email protected]7f8b26b2011-08-18 15:41:0141 // Resource overrides.
dcheng6d18e402014-10-21 12:32:5242 ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API() override;
[email protected]5d84d012010-12-02 17:17:2143
[email protected]55cdf6052011-05-13 19:22:5344 // PPB_Audio_API implementation.
dcheng6d18e402014-10-21 12:32:5245 PP_Resource GetCurrentConfig() override;
46 PP_Bool StartPlayback() override;
47 PP_Bool StopPlayback() override;
48 int32_t Open(PP_Resource config_id,
49 scoped_refptr<ppapi::TrackedCallback> create_callback) override;
50 int32_t GetSyncSocket(int* sync_socket) override;
Alexandr Ilin20f2841c2018-06-01 11:56:1851 int32_t GetSharedMemory(base::UnsafeSharedMemoryRegion** shm) override;
[email protected]937df95112010-07-30 21:24:3952
zqzhangc885f6b2016-06-23 19:44:4653 void SetVolume(double volume);
54
[email protected]937df95112010-07-30 21:24:3955 private:
dcheng6d18e402014-10-21 12:32:5256 ~PPB_Audio_Impl() override;
[email protected]20790a222013-07-25 02:23:0557
[email protected]1f8a0892011-11-18 00:14:2458 // AudioHelper implementation.
Alexandr Ilin20f2841c2018-06-01 11:56:1859 void OnSetStreamInfo(base::UnsafeSharedMemoryRegion shared_memory_region,
Robert Sesek8dd06452020-02-19 01:10:4960 base::SyncSocket::ScopedHandle socket) override;
[email protected]b0deb152010-08-31 17:37:3561
[email protected]55cdf6052011-05-13 19:22:5362 // AudioConfig used for creating this Audio object. We own a ref.
[email protected]49323b32013-08-09 16:05:0663 ppapi::ScopedPPResource config_;
[email protected]937df95112010-07-30 21:24:3964
[email protected]9ca245e2011-03-18 01:50:3165 // PluginDelegate audio object that we delegate audio IPC through. We don't
66 // own this pointer but are responsible for calling Shutdown on it.
Bartek Nowierskif473c24b2024-02-20 17:51:1567 raw_ptr<PepperPlatformAudioOutput> audio_;
[email protected]937df95112010-07-30 21:24:3968};
69
[email protected]adab2332013-07-25 18:04:3270} // namespace content
[email protected]937df95112010-07-30 21:24:3971
[email protected]20790a222013-07-25 02:23:0572#endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_