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

Side by Side Diff: ppapi/cpp/dev/audio_input_dev.h

Issue 11366038: Rewrite PPB_AudioInput_Dev to use the new-style host/resource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 1 month 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
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_CPP_DEV_AUDIO_INPUT_DEV_H_ 5 #ifndef PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_
6 #define PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_ 6 #define PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "ppapi/c/dev/ppb_audio_input_dev.h" 10 #include "ppapi/c/dev/ppb_audio_input_dev.h"
11 #include "ppapi/cpp/audio_config.h" 11 #include "ppapi/cpp/audio_config.h"
12 #include "ppapi/cpp/completion_callback.h" 12 #include "ppapi/cpp/completion_callback.h"
13 #include "ppapi/cpp/dev/device_ref_dev.h" 13 #include "ppapi/cpp/dev/device_ref_dev.h"
14 #include "ppapi/cpp/resource.h" 14 #include "ppapi/cpp/resource.h"
15 15
16 namespace pp { 16 namespace pp {
17 17
18 class InstanceHandle; 18 class InstanceHandle;
19 19
20 class AudioInput_Dev : public Resource { 20 class AudioInput_Dev : public Resource {
21 public: 21 public:
22 /// An empty constructor for an AudioInput resource. 22 /// An empty constructor for an AudioInput resource.
23 AudioInput_Dev(); 23 AudioInput_Dev();
24 24
25 /// This constructor tries to create an audio input resource using the v0.2 25 /// Constructor to create an audio input resource.
26 /// interface, and falls back on the v0.1 interface if that is not available.
27 /// Please use the 2-parameter Open() if you used this constructor.
28 ///
29 /// Note: This constructor is deprecated. Unless your code has to deal with
30 /// browsers that only support the v0.1 interface, please use the 1-parameter
31 /// constructor instead.
32 AudioInput_Dev(const InstanceHandle& instance,
33 const AudioConfig& config,
34 PPB_AudioInput_Callback callback,
35 void* user_data);
36
37 /// This constructor uses the v0.2 interface to create an audio input
38 /// resource. Please use the 5-parameter Open() if you used this constructor.
39 explicit AudioInput_Dev(const InstanceHandle& instance); 26 explicit AudioInput_Dev(const InstanceHandle& instance);
40 27
41 virtual ~AudioInput_Dev(); 28 virtual ~AudioInput_Dev();
42 29
43 /// Static function for determining whether the browser supports the required 30 /// Static function for determining whether the browser supports the required
44 /// AudioInput interface. 31 /// AudioInput interface.
45 /// 32 ///
46 /// @return true if the interface is available, false otherwise. 33 /// @return true if the interface is available, false otherwise.
47 static bool IsAvailable(); 34 static bool IsAvailable();
48 35
49 /// Getter function for returning the internal <code>PPB_AudioConfig</code> 36 /// Getter function for returning the internal <code>PPB_AudioConfig</code>
50 /// struct. 37 /// struct.
51 /// 38 ///
52 /// @return A mutable reference to the PPB_AudioConfig struct. 39 /// @return A mutable reference to the PPB_AudioConfig struct.
53 AudioConfig& config() { return config_; } 40 AudioConfig& config() { return config_; }
54 41
55 /// Getter function for returning the internal <code>PPB_AudioConfig</code> 42 /// Getter function for returning the internal <code>PPB_AudioConfig</code>
56 /// struct. 43 /// struct.
57 /// 44 ///
58 /// @return A const reference to the internal <code>PPB_AudioConfig</code> 45 /// @return A const reference to the internal <code>PPB_AudioConfig</code>
59 /// struct. 46 /// struct.
60 const AudioConfig& config() const { return config_; } 47 const AudioConfig& config() const { return config_; }
61 48
62 int32_t EnumerateDevices( 49 int32_t EnumerateDevices(
63 const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >& 50 const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >&
64 callback); 51 callback);
65 52
66 /// If |device_ref| is null (i.e., is_null() returns true), the default device 53 /// If |device_ref| is null (i.e., is_null() returns true), the default device
67 /// will be used. 54 /// will be used.
68 /// In order to maintain backward compatibility, this method doesn't have
69 /// input parameters config, audio_input_callback and user_data. Instead, it
70 /// uses those values stored when the 4-parameter constructor was called.
71 ///
72 /// Note: This method is deprecated. Unless your code has to deal with
73 /// browsers that only support the v0.1 interface, please use the other
74 /// Open().
75 int32_t Open(const DeviceRef_Dev& device_ref,
76 const CompletionCallback& callback);
77
78 int32_t Open(const DeviceRef_Dev& device_ref, 55 int32_t Open(const DeviceRef_Dev& device_ref,
79 const AudioConfig& config, 56 const AudioConfig& config,
80 PPB_AudioInput_Callback audio_input_callback, 57 PPB_AudioInput_Callback audio_input_callback,
81 void* user_data, 58 void* user_data,
82 const CompletionCallback& callback); 59 const CompletionCallback& callback);
83 60
84 bool StartCapture(); 61 bool StartCapture();
85 bool StopCapture(); 62 bool StopCapture();
86 void Close(); 63 void Close();
87 64
88 private: 65 private:
89 AudioConfig config_; 66 AudioConfig config_;
90 67
91 // Used to store the arguments of Open() for the v0.2 interface. 68 // Used to store the arguments of Open() for the v0.2 interface.
92 PPB_AudioInput_Callback audio_input_callback_; 69 PPB_AudioInput_Callback audio_input_callback_;
93 void* user_data_; 70 void* user_data_;
94 }; 71 };
95 72
96 } // namespace pp 73 } // namespace pp
97 74
98 #endif // PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_ 75 #endif // PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698