Avi Drissman | 4e1b7bc3 | 2022-09-15 14:03:50 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 20790a22 | 2013-07-25 02:23:05 | [diff] [blame] | 5 | #ifndef CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ |
6 | #define CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ | ||||
[email protected] | 6f2e391 | 2010-11-05 14:45:44 | [diff] [blame] | 7 | |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 8 | #include <stddef.h> |
9 | #include <stdint.h> | ||||
10 | |||||
Kalvin Lee | bc3754ae | 2023-10-01 22:37:34 | [diff] [blame] | 11 | #include "base/memory/raw_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 12 | #include "base/memory/ref_counted.h" |
Alexandr Ilin | 20f2841c | 2018-06-01 11:56:18 | [diff] [blame] | 13 | #include "base/memory/unsafe_shared_memory_region.h" |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 14 | #include "base/sync_socket.h" |
[email protected] | 20790a22 | 2013-07-25 02:23:05 | [diff] [blame] | 15 | #include "content/renderer/pepper/audio_helper.h" |
[email protected] | 0641727 | 2010-11-25 00:29:25 | [diff] [blame] | 16 | #include "ppapi/c/pp_completion_callback.h" |
[email protected] | b9a5984 | 2011-01-15 01:04:00 | [diff] [blame] | 17 | #include "ppapi/c/ppb_audio.h" |
18 | #include "ppapi/c/ppb_audio_config.h" | ||||
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 19 | #include "ppapi/shared_impl/ppb_audio_config_shared.h" |
20 | #include "ppapi/shared_impl/ppb_audio_shared.h" | ||||
[email protected] | 56d7ad4 | 2011-12-07 00:01:30 | [diff] [blame] | 21 | #include "ppapi/shared_impl/resource.h" |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 22 | #include "ppapi/shared_impl/scoped_pp_resource.h" |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 23 | |
[email protected] | adab233 | 2013-07-25 18:04:32 | [diff] [blame] | 24 | namespace content { |
[email protected] | c0cf2f1 | 2013-07-28 21:22:30 | [diff] [blame] | 25 | class PepperPlatformAudioOutput; |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 26 | |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 27 | // Some of the backend functionality of this class is implemented by the |
[email protected] | 9a57839 | 2011-12-07 18:59:27 | [diff] [blame] | 28 | // PPB_Audio_Shared so it can be shared with the proxy. |
[email protected] | 79d816c | 2014-02-25 09:49:20 | [diff] [blame] | 29 | // |
30 | // TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up | ||||
31 | // to look more like typical HostResource implementations. | ||||
[email protected] | 49323b3 | 2013-08-09 16:05:06 | [diff] [blame] | 32 | class PPB_Audio_Impl : public ppapi::Resource, |
33 | public ppapi::PPB_Audio_Shared, | ||||
Dave Tapuska | a361ec8 | 2020-11-02 18:08:38 | [diff] [blame] | 34 | public AudioHelper { |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 35 | public: |
[email protected] | bbf076f1 | 2011-08-24 15:19:37 | [diff] [blame] | 36 | explicit PPB_Audio_Impl(PP_Instance instance); |
[email protected] | 6328a5b | 2011-06-22 21:48:36 | [diff] [blame] | 37 | |
Peter Boström | 9b03653 | 2021-10-28 23:37:28 | [diff] [blame] | 38 | PPB_Audio_Impl(const PPB_Audio_Impl&) = delete; |
39 | PPB_Audio_Impl& operator=(const PPB_Audio_Impl&) = delete; | ||||
40 | |||||
[email protected] | 7f8b26b | 2011-08-18 15:41:01 | [diff] [blame] | 41 | // Resource overrides. |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 42 | ppapi::thunk::PPB_Audio_API* AsPPB_Audio_API() override; |
[email protected] | 5d84d01 | 2010-12-02 17:17:21 | [diff] [blame] | 43 | |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 44 | // PPB_Audio_API implementation. |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 45 | 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 Ilin | 20f2841c | 2018-06-01 11:56:18 | [diff] [blame] | 51 | int32_t GetSharedMemory(base::UnsafeSharedMemoryRegion** shm) override; |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 52 | |
zqzhang | c885f6b | 2016-06-23 19:44:46 | [diff] [blame] | 53 | void SetVolume(double volume); |
54 | |||||
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 55 | private: |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 56 | ~PPB_Audio_Impl() override; |
[email protected] | 20790a22 | 2013-07-25 02:23:05 | [diff] [blame] | 57 | |
[email protected] | 1f8a089 | 2011-11-18 00:14:24 | [diff] [blame] | 58 | // AudioHelper implementation. |
Alexandr Ilin | 20f2841c | 2018-06-01 11:56:18 | [diff] [blame] | 59 | void OnSetStreamInfo(base::UnsafeSharedMemoryRegion shared_memory_region, |
Robert Sesek | 8dd0645 | 2020-02-19 01:10:49 | [diff] [blame] | 60 | base::SyncSocket::ScopedHandle socket) override; |
[email protected] | b0deb15 | 2010-08-31 17:37:35 | [diff] [blame] | 61 | |
[email protected] | 55cdf605 | 2011-05-13 19:22:53 | [diff] [blame] | 62 | // AudioConfig used for creating this Audio object. We own a ref. |
[email protected] | 49323b3 | 2013-08-09 16:05:06 | [diff] [blame] | 63 | ppapi::ScopedPPResource config_; |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 64 | |
[email protected] | 9ca245e | 2011-03-18 01:50:31 | [diff] [blame] | 65 | // 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 Nowierski | f473c24b | 2024-02-20 17:51:15 | [diff] [blame] | 67 | raw_ptr<PepperPlatformAudioOutput> audio_; |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 68 | }; |
69 | |||||
[email protected] | adab233 | 2013-07-25 18:04:32 | [diff] [blame] | 70 | } // namespace content |
[email protected] | 937df9511 | 2010-07-30 21:24:39 | [diff] [blame] | 71 | |
[email protected] | 20790a22 | 2013-07-25 02:23:05 | [diff] [blame] | 72 | #endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_ |