Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Side by Side Diff: webkit/plugins/ppapi/ppb_audio_input_impl.h

Issue 9557007: PPB_AudioInput_Dev: support multiple audio input devices - Part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes in response to Trung's comments. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/plugin_delegate.h ('k') | webkit/plugins/ppapi/ppb_audio_input_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ 5 #ifndef WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_
6 #define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ 6 #define WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_
7 7
8 #include <string>
9 #include <vector>
10
8 #include "base/basictypes.h" 11 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 12 #include "base/compiler_specific.h"
10 #include "base/shared_memory.h" 13 #include "base/memory/weak_ptr.h"
11 #include "base/sync_socket.h"
12 #include "ppapi/c/dev/ppb_audio_input_dev.h"
13 #include "ppapi/c/pp_completion_callback.h"
14 #include "ppapi/c/trusted/ppb_audio_input_trusted_dev.h"
15 #include "ppapi/shared_impl/ppb_audio_config_shared.h"
16 #include "ppapi/shared_impl/ppb_audio_input_shared.h" 14 #include "ppapi/shared_impl/ppb_audio_input_shared.h"
17 #include "ppapi/shared_impl/resource.h"
18 #include "ppapi/shared_impl/scoped_pp_resource.h"
19 #include "webkit/plugins/ppapi/audio_helper.h"
20 #include "webkit/plugins/ppapi/plugin_delegate.h" 15 #include "webkit/plugins/ppapi/plugin_delegate.h"
21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
22 16
23 namespace webkit { 17 namespace webkit {
24 namespace ppapi { 18 namespace ppapi {
25 19
26 // Some of the backend functionality of this class is implemented by the 20 // Some of the backend functionality of this class is implemented by the
27 // AudioInputImpl so it can be shared with the proxy. 21 // PPB_AudioInput_Shared so it can be shared with the proxy.
28 class PPB_AudioInput_Impl : public ::ppapi::Resource, 22 class PPB_AudioInput_Impl : public ::ppapi::PPB_AudioInput_Shared,
29 public ::ppapi::PPB_AudioInput_Shared, 23 public PluginDelegate::PlatformAudioCommonClient,
30 public AudioHelper { 24 public base::SupportsWeakPtr<PPB_AudioInput_Impl> {
31 public: 25 public:
32 // Trusted initialization. You must call Init after this. 26 typedef std::vector< ::ppapi::DeviceRefData> DeviceRefDataVector;
33 // 27
34 // Untrusted initialization should just call the static Create() function
35 // to properly create & initialize this class.
36 explicit PPB_AudioInput_Impl(PP_Instance instance); 28 explicit PPB_AudioInput_Impl(PP_Instance instance);
37
38 virtual ~PPB_AudioInput_Impl(); 29 virtual ~PPB_AudioInput_Impl();
39 30
40 // Creation function for untrusted plugins. This handles all initialization 31 // Creation function for the v0.1 interface. This handles all initialization
41 // and will return 0 on failure. 32 // and will return 0 on failure.
42 static PP_Resource Create(PP_Instance instance, 33 static PP_Resource Create0_1(PP_Instance instance,
43 PP_Resource config_id, 34 PP_Resource config,
44 PPB_AudioInput_Callback audio_input_callback, 35 PPB_AudioInput_Callback audio_input_callback,
45 void* user_data); 36 void* user_data);
46 37
47 // Initialization function for trusted init. 38 // Implementation of PPB_AudioInput_API trusted methods.
48 bool Init(PP_Resource config_id, 39 virtual int32_t OpenTrusted(const std::string& device_id,
49 PPB_AudioInput_Callback callback, 40 PP_Resource config,
50 void* user_data);
51
52 // Resource overrides.
53 virtual ::ppapi::thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE;
54
55 // PPB_AudioInput_API implementation.
56 virtual PP_Resource GetCurrentConfig() OVERRIDE;
57 virtual PP_Bool StartCapture() OVERRIDE;
58 virtual PP_Bool StopCapture() OVERRIDE;
59
60 virtual int32_t OpenTrusted(PP_Resource config_id,
61 PP_CompletionCallback create_callback) OVERRIDE; 41 PP_CompletionCallback create_callback) OVERRIDE;
62 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE; 42 virtual int32_t GetSyncSocket(int* sync_socket) OVERRIDE;
63 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE; 43 virtual int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size) OVERRIDE;
44 virtual const DeviceRefDataVector& GetDeviceRefData() const OVERRIDE;
45
46 // PluginDelegate::PlatformAudioCommonClient implementation.
47 virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
48 size_t shared_memory_size,
49 base::SyncSocket::Handle socket) OVERRIDE;
64 50
65 private: 51 private:
66 // AudioHelper implementation. 52 // PPB_AudioInput_Shared implementation.
67 virtual void OnSetStreamInfo(base::SharedMemoryHandle shared_memory_handle, 53 virtual int32_t InternalEnumerateDevices(
68 size_t shared_memory_size_, 54 PP_Resource* devices,
69 base::SyncSocket::Handle socket) OVERRIDE; 55 PP_CompletionCallback callback) OVERRIDE;
56 virtual int32_t InternalOpen(const std::string& device_id,
57 PP_AudioSampleRate sample_rate,
58 uint32_t sample_frame_count,
59 PP_CompletionCallback callback) OVERRIDE;
60 virtual PP_Bool InternalStartCapture() OVERRIDE;
61 virtual PP_Bool InternalStopCapture() OVERRIDE;
62 virtual void InternalClose() OVERRIDE;
70 63
71 // AudioConfig used for creating this AudioInput object. We own a ref. 64 void EnumerateDevicesCallbackFunc(int request_id,
72 ::ppapi::ScopedPPResource config_; 65 bool succeeded,
66 const DeviceRefDataVector& devices);
73 67
74 // PluginDelegate audio input object that we delegate audio IPC through. 68 // PluginDelegate audio input object that we delegate audio IPC through.
75 // We don't own this pointer but are responsible for calling Shutdown on it. 69 // We don't own this pointer but are responsible for calling Shutdown on it.
76 PluginDelegate::PlatformAudioInput* audio_input_; 70 PluginDelegate::PlatformAudioInput* audio_input_;
77 71
72 DeviceRefDataVector devices_data_;
73
78 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Impl); 74 DISALLOW_COPY_AND_ASSIGN(PPB_AudioInput_Impl);
79 }; 75 };
80 76
81 } // namespace ppapi 77 } // namespace ppapi
82 } // namespace webkit 78 } // namespace webkit
83 79
84 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_ 80 #endif // WEBKIT_PLUGINS_PPAPI_PPB_AUDIO_INPUT_IMPL_H_
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/plugin_delegate.h ('k') | webkit/plugins/ppapi/ppb_audio_input_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698