blob: 311dfb9306c77862ddc2693c2fa8ae33706cfac1 [file] [log] [blame]
[email protected]aed96532012-06-23 14:27:421// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[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
11#include "base/macros.h"
[email protected]3b63f8f42011-03-28 01:54:1512#include "base/memory/ref_counted.h"
[email protected]8299b712013-07-17 19:55:2313#include "base/memory/shared_memory.h"
[email protected]937df95112010-07-30 21:24:3914#include "base/sync_socket.h"
tommycli43d8cc42015-03-20 17:48:1915#include "content/public/renderer/plugin_instance_throttler.h"
[email protected]20790a222013-07-25 02:23:0516#include "content/renderer/pepper/audio_helper.h"
[email protected]06417272010-11-25 00:29:2517#include "ppapi/c/pp_completion_callback.h"
[email protected]b9a59842011-01-15 01:04:0018#include "ppapi/c/ppb_audio.h"
19#include "ppapi/c/ppb_audio_config.h"
[email protected]9a578392011-12-07 18:59:2720#include "ppapi/shared_impl/ppb_audio_config_shared.h"
21#include "ppapi/shared_impl/ppb_audio_shared.h"
[email protected]56d7ad42011-12-07 00:01:3022#include "ppapi/shared_impl/resource.h"
[email protected]9a578392011-12-07 18:59:2723#include "ppapi/shared_impl/scoped_pp_resource.h"
[email protected]937df95112010-07-30 21:24:3924
[email protected]adab2332013-07-25 18:04:3225namespace content {
[email protected]c0cf2f12013-07-28 21:22:3026class PepperPlatformAudioOutput;
[email protected]937df95112010-07-30 21:24:3927
[email protected]5d84d012010-12-02 17:17:2128// Some of the backend functionality of this class is implemented by the
[email protected]9a578392011-12-07 18:59:2729// PPB_Audio_Shared so it can be shared with the proxy.
[email protected]79d816c2014-02-25 09:49:2030//
31// TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up
32// to look more like typical HostResource implementations.
[email protected]49323b32013-08-09 16:05:0633class PPB_Audio_Impl : public ppapi::Resource,
34 public ppapi::PPB_Audio_Shared,
tommycli43d8cc42015-03-20 17:48:1935 public AudioHelper,
36 public PluginInstanceThrottler::Observer {
[email protected]937df95112010-07-30 21:24:3937 public:
[email protected]bbf076f12011-08-24 15:19:3738 explicit PPB_Audio_Impl(PP_Instance instance);
[email protected]6328a5b2011-06-22 21:48:3639
[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;
erikchen4fc32d52015-06-02 02:16:3850 int32_t GetSharedMemory(base::SharedMemory** shm,
51 uint32_t* shm_size) override;
[email protected]937df95112010-07-30 21:24:3952
53 private:
dcheng6d18e402014-10-21 12:32:5254 ~PPB_Audio_Impl() override;
[email protected]20790a222013-07-25 02:23:0555
[email protected]1f8a0892011-11-18 00:14:2456 // AudioHelper implementation.
dcheng6d18e402014-10-21 12:32:5257 void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
58 size_t shared_memory_size_,
59 base::SyncSocket::Handle socket) override;
[email protected]b0deb152010-08-31 17:37:3560
tommycli43d8cc42015-03-20 17:48:1961 // PluginInstanceThrottler::Observer implementation.
62 void OnThrottleStateChange() override;
63
64 // Starts the deferred playback and unsubscribes from the throttler.
65 void StartDeferredPlayback();
66
[email protected]55cdf6052011-05-13 19:22:5367 // AudioConfig used for creating this Audio object. We own a ref.
[email protected]49323b32013-08-09 16:05:0668 ppapi::ScopedPPResource config_;
[email protected]937df95112010-07-30 21:24:3969
[email protected]9ca245e2011-03-18 01:50:3170 // PluginDelegate audio object that we delegate audio IPC through. We don't
71 // own this pointer but are responsible for calling Shutdown on it.
[email protected]c0cf2f12013-07-28 21:22:3072 PepperPlatformAudioOutput* audio_;
[email protected]937df95112010-07-30 21:24:3973
tommycli43d8cc42015-03-20 17:48:1974 // Stream is playing, but throttled due to Plugin Power Saver.
75 bool playback_throttled_;
76
[email protected]0bd753682010-12-16 18:15:5277 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl);
[email protected]937df95112010-07-30 21:24:3978};
79
[email protected]adab2332013-07-25 18:04:3280} // namespace content
[email protected]937df95112010-07-30 21:24:3981
[email protected]20790a222013-07-25 02:23:0582#endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_