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

Side by Side Diff: ppapi/proxy/audio_input_resource.h

Issue 11411047: Introduce PPB_AudioInput_Dev v0.3 and refactor the device enumeration code: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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 | « ppapi/ppapi_tests.gypi ('k') | ppapi/proxy/audio_input_resource.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) 2012 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 PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ 5 #ifndef PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_
6 #define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ 6 #define PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_
7 7
8 #include <vector>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
14 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
15 #include "base/sync_socket.h" 13 #include "base/sync_socket.h"
16 #include "base/threading/simple_thread.h" 14 #include "base/threading/simple_thread.h"
15 #include "ppapi/proxy/device_enumeration_resource_helper.h"
17 #include "ppapi/proxy/plugin_resource.h" 16 #include "ppapi/proxy/plugin_resource.h"
18 #include "ppapi/shared_impl/scoped_pp_resource.h" 17 #include "ppapi/shared_impl/scoped_pp_resource.h"
19 #include "ppapi/thunk/ppb_audio_input_api.h" 18 #include "ppapi/thunk/ppb_audio_input_api.h"
20 19
21 namespace ppapi { 20 namespace ppapi {
22
23 struct DeviceRefData;
24
25 namespace proxy { 21 namespace proxy {
26 22
27 class ResourceMessageReplyParams; 23 class ResourceMessageReplyParams;
28 class SerializedHandle; 24 class SerializedHandle;
29 25
30 class AudioInputResource : public PluginResource, 26 class AudioInputResource : public PluginResource,
31 public thunk::PPB_AudioInput_API, 27 public thunk::PPB_AudioInput_API,
32 public base::DelegateSimpleThread::Delegate { 28 public base::DelegateSimpleThread::Delegate {
33 public: 29 public:
34 AudioInputResource(Connection connection, PP_Instance instance); 30 AudioInputResource(Connection connection, PP_Instance instance);
35 virtual ~AudioInputResource(); 31 virtual ~AudioInputResource();
36 32
37 // Resource overrides. 33 // Resource overrides.
38 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE; 34 virtual thunk::PPB_AudioInput_API* AsPPB_AudioInput_API() OVERRIDE;
35 virtual void OnReplyReceived(const ResourceMessageReplyParams& params,
36 const IPC::Message& msg) OVERRIDE;
39 37
40 // PPB_AudioInput_API implementation. 38 // PPB_AudioInput_API implementation.
41 virtual int32_t EnumerateDevices( 39 virtual int32_t EnumerateDevices0_2(
42 PP_Resource* devices, 40 PP_Resource* devices,
43 scoped_refptr<TrackedCallback> callback) OVERRIDE; 41 scoped_refptr<TrackedCallback> callback) OVERRIDE;
42 virtual int32_t EnumerateDevices(
43 const PP_ArrayOutput& output,
44 scoped_refptr<TrackedCallback> callback) OVERRIDE;
45 virtual int32_t MonitorDeviceChange(
46 PP_MonitorDeviceChangeCallback callback,
47 void* user_data) OVERRIDE;
44 virtual int32_t Open(const std::string& device_id, 48 virtual int32_t Open(const std::string& device_id,
45 PP_Resource config, 49 PP_Resource config,
46 PPB_AudioInput_Callback audio_input_callback, 50 PPB_AudioInput_Callback audio_input_callback,
47 void* user_data, 51 void* user_data,
48 scoped_refptr<TrackedCallback> callback) OVERRIDE; 52 scoped_refptr<TrackedCallback> callback) OVERRIDE;
49 virtual PP_Resource GetCurrentConfig() OVERRIDE; 53 virtual PP_Resource GetCurrentConfig() OVERRIDE;
50 virtual PP_Bool StartCapture() OVERRIDE; 54 virtual PP_Bool StartCapture() OVERRIDE;
51 virtual PP_Bool StopCapture() OVERRIDE; 55 virtual PP_Bool StopCapture() OVERRIDE;
52 virtual void Close() OVERRIDE; 56 virtual void Close() OVERRIDE;
53 57
58 protected:
59 // Resource override.
60 virtual void LastPluginRefWasDeleted() OVERRIDE;
61
54 private: 62 private:
55 enum OpenState { 63 enum OpenState {
56 BEFORE_OPEN, 64 BEFORE_OPEN,
57 OPENED, 65 OPENED,
58 CLOSED 66 CLOSED
59 }; 67 };
60 68
61 void OnPluginMsgEnumerateDevicesReply(
62 PP_Resource* devices_resource,
63 scoped_refptr<TrackedCallback> callback,
64 const ResourceMessageReplyParams& params,
65 const std::vector<DeviceRefData>& devices);
66 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params); 69 void OnPluginMsgOpenReply(const ResourceMessageReplyParams& params);
67 70
68 // Sets the shared memory and socket handles. This will automatically start 71 // Sets the shared memory and socket handles. This will automatically start
69 // capture if we're currently set to capture. 72 // capture if we're currently set to capture.
70 void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle, 73 void SetStreamInfo(base::SharedMemoryHandle shared_memory_handle,
71 size_t shared_memory_size, 74 size_t shared_memory_size,
72 base::SyncSocket::Handle socket_handle); 75 base::SyncSocket::Handle socket_handle);
73 76
74 // Starts execution of the audio input thread. 77 // Starts execution of the audio input thread.
75 void StartThread(); 78 void StartThread();
(...skipping 24 matching lines...) Expand all
100 103
101 // When the callback is set, this thread is spawned for calling it. 104 // When the callback is set, this thread is spawned for calling it.
102 scoped_ptr<base::DelegateSimpleThread> audio_input_thread_; 105 scoped_ptr<base::DelegateSimpleThread> audio_input_thread_;
103 106
104 // Callback to call when new samples are available. 107 // Callback to call when new samples are available.
105 PPB_AudioInput_Callback audio_input_callback_; 108 PPB_AudioInput_Callback audio_input_callback_;
106 109
107 // User data pointer passed verbatim to the callback function. 110 // User data pointer passed verbatim to the callback function.
108 void* user_data_; 111 void* user_data_;
109 112
110 bool pending_enumerate_devices_;
111 // The callback is not directly passed to OnPluginMsgOpenReply() because we 113 // The callback is not directly passed to OnPluginMsgOpenReply() because we
112 // would like to be able to cancel it early in Close(). 114 // would like to be able to cancel it early in Close().
113 scoped_refptr<TrackedCallback> open_callback_; 115 scoped_refptr<TrackedCallback> open_callback_;
114 116
115 // Owning reference to the current config object. This isn't actually used, 117 // Owning reference to the current config object. This isn't actually used,
116 // we just dish it out as requested by the plugin. 118 // we just dish it out as requested by the plugin.
117 ScopedPPResource config_; 119 ScopedPPResource config_;
118 120
121 DeviceEnumerationResourceHelper enumeration_helper_;
122
119 DISALLOW_COPY_AND_ASSIGN(AudioInputResource); 123 DISALLOW_COPY_AND_ASSIGN(AudioInputResource);
120 }; 124 };
121 125
122 } // namespace proxy 126 } // namespace proxy
123 } // namespace ppapi 127 } // namespace ppapi
124 128
125 #endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_ 129 #endif // PPAPI_PROXY_AUDIO_INPUT_RESOURCE_H_
OLDNEW
« no previous file with comments | « ppapi/ppapi_tests.gypi ('k') | ppapi/proxy/audio_input_resource.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698