1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_
6 #define CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/shared_memory.h"
11 #include "base/sync_socket.h"
12 #include "content/renderer/pepper/audio_helper.h"
13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/ppb_audio.h"
15 #include "ppapi/c/ppb_audio_config.h"
16 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
17 #include "ppapi/shared_impl/ppb_audio_shared.h"
18 #include "ppapi/shared_impl/resource.h"
19 #include "ppapi/shared_impl/scoped_pp_resource.h"
22 class PepperPlatformAudioOutput
;
24 // Some of the backend functionality of this class is implemented by the
25 // PPB_Audio_Shared so it can be shared with the proxy.
27 // TODO(teravest): PPB_Audio is no longer supported in-process. Clean this up
28 // to look more like typical HostResource implementations.
29 class PPB_Audio_Impl
: public ppapi::Resource
,
30 public ppapi::PPB_Audio_Shared
,
33 explicit PPB_Audio_Impl(PP_Instance instance
);
35 // Resource overrides.
36 virtual ppapi::thunk::PPB_Audio_API
* AsPPB_Audio_API() OVERRIDE
;
38 // PPB_Audio_API implementation.
39 virtual PP_Resource
GetCurrentConfig() OVERRIDE
;
40 virtual PP_Bool
StartPlayback() OVERRIDE
;
41 virtual PP_Bool
StopPlayback() OVERRIDE
;
42 virtual int32_t Open(PP_Resource config_id
,
43 scoped_refptr
<ppapi::TrackedCallback
> create_callback
)
45 virtual int32_t GetSyncSocket(int* sync_socket
) OVERRIDE
;
46 virtual int32_t GetSharedMemory(int* shm_handle
, uint32_t* shm_size
) OVERRIDE
;
49 virtual ~PPB_Audio_Impl();
51 // AudioHelper implementation.
52 virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle
,
53 size_t shared_memory_size_
,
54 base::SyncSocket::Handle socket
) OVERRIDE
;
56 // AudioConfig used for creating this Audio object. We own a ref.
57 ppapi::ScopedPPResource config_
;
59 // PluginDelegate audio object that we delegate audio IPC through. We don't
60 // own this pointer but are responsible for calling Shutdown on it.
61 PepperPlatformAudioOutput
* audio_
;
63 DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl
);
66 } // namespace content
68 #endif // CONTENT_RENDERER_PEPPER_PPB_AUDIO_IMPL_H_