diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 07:48:48 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-07 07:48:48 +0000 |
commit | eed24562b1e6a431fc726195e1114eed01b1694f (patch) | |
tree | 2ae570b6f55f7043e62bc25dca335d03ba75bb52 /ppapi/cpp/dev/audio_input_dev.h | |
parent | e974ad29d8f31b1f86bb551dc99ad4e5e62b002c (diff) | |
download | chromium_src-eed24562b1e6a431fc726195e1114eed01b1694f.zip chromium_src-eed24562b1e6a431fc726195e1114eed01b1694f.tar.gz chromium_src-eed24562b1e6a431fc726195e1114eed01b1694f.tar.bz2 |
PPB_AudioInput_Dev: support multiple audio input devices - Part 1.
- This CL implements PPB_AudioInput_Dev v0.2 and extends examples/audio_input.
- This CL doesn't actually open devices other than the default one. That will be in a separate CL.
BUG=None
TEST=examples/audio_input
Review URL: http://codereview.chromium.org/9557007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/cpp/dev/audio_input_dev.h')
-rw-r--r-- | ppapi/cpp/dev/audio_input_dev.h | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/ppapi/cpp/dev/audio_input_dev.h b/ppapi/cpp/dev/audio_input_dev.h index 2761437..2bcccc3 100644 --- a/ppapi/cpp/dev/audio_input_dev.h +++ b/ppapi/cpp/dev/audio_input_dev.h @@ -1,28 +1,49 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_ #define PPAPI_CPP_DEV_AUDIO_INPUT_DEV_H_ +#include <vector> + #include "ppapi/c/dev/ppb_audio_input_dev.h" #include "ppapi/cpp/audio_config.h" #include "ppapi/cpp/resource.h" namespace pp { +class CompletionCallback; +class DeviceRef_Dev; class InstanceHandle; class AudioInput_Dev : public Resource { public: /// An empty constructor for an AudioInput resource. - AudioInput_Dev() {} + AudioInput_Dev(); + /// This constructor tries to create an audio input resource using the v0.2 + /// interface, and falls back on the v0.1 interface if that is not available. + /// Please use the 2-parameter Open() if you used this constructor. + /// + /// Note: This constructor is deprecated. Unless your code has to deal with + /// browsers that only support the v0.1 interface, please use the 1-parameter + /// constructor instead. AudioInput_Dev(const InstanceHandle& instance, const AudioConfig& config, PPB_AudioInput_Callback callback, void* user_data); + /// This constructor uses the v0.2 interface to create an audio input + /// resource. Please use the 5-parameter Open() if you used this constructor. + explicit AudioInput_Dev(const InstanceHandle& instance); + + AudioInput_Dev(const AudioInput_Dev& other); + + virtual ~AudioInput_Dev(); + + AudioInput_Dev& operator=(const AudioInput_Dev& other); + /// Static function for determining whether the browser supports the required /// AudioInput interface. /// @@ -42,11 +63,52 @@ class AudioInput_Dev : public Resource { /// struct. const AudioConfig& config() const { return config_; } + /// |devices| must stay alive until either this AudioInput_Dev object goes + /// away or |callback| is run, if this method returns PP_OK_COMPLETIONPENDING. + int32_t EnumerateDevices(std::vector<DeviceRef_Dev>* devices, + const CompletionCallback& callback); + + /// If |device_ref| is null (i.e., is_null() returns true), the default device + /// will be used. + /// In order to maintain backward compatibility, this method doesn't have + /// input parameters config, audio_input_callback and user_data. Instead, it + /// uses those values stored when the 4-parameter constructor was called. + /// + /// Note: This method is deprecated. Unless your code has to deal with + /// browsers that only support the v0.1 interface, please use the other + /// Open(). + int32_t Open(const DeviceRef_Dev& device_ref, + const CompletionCallback& callback); + + int32_t Open(const DeviceRef_Dev& device_ref, + const AudioConfig& config, + PPB_AudioInput_Callback audio_input_callback, + void* user_data, + const CompletionCallback& callback); + bool StartCapture(); bool StopCapture(); + void Close(); private: + struct EnumerateDevicesState; + + void AbortEnumerateDevices(); + + // |user_data| is an EnumerateDevicesState object. It is this method's + // responsibility to delete it. + static void OnEnumerateDevicesComplete(void* user_data, int32_t result); + AudioConfig config_; + + // It is set in EnumerateDevices(), and cleared in AbortEnumerateDevices() or + // OnEnumerateDevicesComplete(). The object will be deleted by + // OnEnumerateDevicesComplete(). + EnumerateDevicesState* enum_state_; + + // Used to store the arguments of Open() for the v0.2 interface. + PPB_AudioInput_Callback audio_input_callback_; + void* user_data_; }; } // namespace pp |