OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ | |
6 #define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "ppapi/shared_impl/ppb_audio_input_shared.h" | |
15 #include "webkit/plugins/ppapi/plugin_delegate.h" | |
16 | |
17 namespace webkit { | |
18 namespace ppapi { | |
19 | |
20 // Some of the backend functionality of this class is implemented by the | |
21 // PPB_AudioInput_Shared so it can be shared with the proxy. | |
22 class PPB_AudioInput_Impl : public ::ppapi::PPB_AudioInput_Shared, | |
23 public PluginDelegate::PlatformAudioInputClient, | |
24 public base::SupportsWeakPtr<PPB_AudioInput_Impl> { | |
25 public: | |
26 typedef std::vector< ::ppapi::DeviceRefData> DeviceRefDataVector; | |
27 | |
28 explicit PPB_AudioInput_Impl(PP_Instance instance); | |
29 virtual ~PPB_AudioInput_Impl(); | |
30 | |
31 // Creation function for the v0.1 interface. This handles all initialization | |
32 // and will return 0 on failure. | |
33 static PP_Resource Create0_1(PP_Instance instance, | |
34 PP_Resource config, | |
35 PPB_AudioInput_Callback audio_input_callback, | |
36 void* user_data); | |
37 | |
38 // Implementation of PPB_AudioInput_API trusted methods. | |
39 virtual int32_t OpenTrusted( | |
40 const std::string& device_id, | |
41 PP_Resource config, | |
42 scoped_refptr< ::ppapi::TrackedCallback> create_callback) OVERRIDE; | |
43 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; | |
44 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; | |
45 virtual const DeviceRefDataVector& GetDeviceRefData() const OVERRIDE; | |
46 | |
47 // PluginDelegate::PlatformAudioInputClient implementation. | |
48 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle, | |
49 size_t shared_memory_size, | |
50 base::SyncSocket::Handle socket) OVERRIDE; | |
51 virtual void StreamCreationFailed() OVERRIDE; | |
52 | |
53 private: | |
54 // PPB_AudioInput_Shared implementation. | |
55 virtual int32_t InternalEnumerateDevices( | |
56 PP_Resource* devices, | |
57 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | |
58 virtual int32_t InternalOpen( | |
59 const std::string& device_id, | |
60 PP_AudioSampleRate sample_rate, | |
61 uint32_t sample_frame_count, | |
62 scoped_refptr< ::ppapi::TrackedCallback> callback) OVERRIDE; | |
63 virtual PP_Bool InternalStartCapture() OVERRIDE; | |
64 virtual PP_Bool InternalStopCapture() OVERRIDE; | |
65 virtual void InternalClose() OVERRIDE; | |
66 | |
67 void EnumerateDevicesCallbackFunc(int request_id, | |
68 bool succeeded, | |
69 const DeviceRefDataVector& devices); | |
70 | |
71 // PluginDelegate audio input object that we delegate audio IPC through. | |
72 // We don't own this pointer but are responsible for calling Shutdown on it. | |
73 PluginDelegate::PlatformAudioInput* audio_input_; | |
74 | |
75 DeviceRefDataVector devices_data_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Impl); | |
78 }; | |
79 | |
80 } // namespace ppapi | |
81 } // namespace webkit | |
82 | |
83 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ | |
OLD | NEW |