OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 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 PPAPI_CPP_DEV_AUDIO_OUTPUT_DEV_H_ |
| 6 #define PPAPI_CPP_DEV_AUDIO_OUTPUT_DEV_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 |
| 10 #include <vector> |
| 11 |
| 12 #include "ppapi/c/dev/ppb_audio_output_dev.h" |
| 13 #include "ppapi/cpp/audio_config.h" |
| 14 #include "ppapi/cpp/completion_callback.h" |
| 15 #include "ppapi/cpp/dev/device_ref_dev.h" |
| 16 #include "ppapi/cpp/resource.h" |
| 17 |
| 18 namespace pp { |
| 19 |
| 20 class InstanceHandle; |
| 21 |
| 22 class AudioOutput_Dev : public Resource { |
| 23 public: |
| 24 // An empty constructor for an AudioOutput resource. |
| 25 AudioOutput_Dev(); |
| 26 |
| 27 // Constructor to create an audio output resource. |
| 28 explicit AudioOutput_Dev(const InstanceHandle& instance); |
| 29 |
| 30 virtual ~AudioOutput_Dev(); |
| 31 |
| 32 // Static function for determining whether the browser supports the required |
| 33 // AudioOutput interface. |
| 34 // |
| 35 // @return true if the interface is available, false otherwise. |
| 36 static bool IsAvailable(); |
| 37 |
| 38 int32_t EnumerateDevices( |
| 39 const CompletionCallbackWithOutput<std::vector<DeviceRef_Dev> >& cb); |
| 40 |
| 41 int32_t MonitorDeviceChange(PP_MonitorDeviceChangeCallback callback, |
| 42 void* user_data); |
| 43 |
| 44 // If |device_ref| is null (i.e., is_null() returns true), the default device |
| 45 // will be used. |
| 46 int32_t Open(const DeviceRef_Dev& device_ref, |
| 47 const AudioConfig& config, |
| 48 PPB_AudioOutput_Callback audio_output_callback, |
| 49 void* user_data, |
| 50 const CompletionCallback& callback); |
| 51 |
| 52 // Getter function for returning the internal <code>PPB_AudioConfig</code> |
| 53 // struct. |
| 54 // |
| 55 // @return A mutable reference to the PPB_AudioConfig struct. |
| 56 AudioConfig& config() { return config_; } |
| 57 |
| 58 // Getter function for returning the internal <code>PPB_AudioConfig</code> |
| 59 // struct. |
| 60 // |
| 61 // @return A const reference to the internal <code>PPB_AudioConfig</code> |
| 62 // struct. |
| 63 const AudioConfig& config() const { return config_; } |
| 64 |
| 65 // StartPlayback() starts playback of audio. |
| 66 // |
| 67 // @return true if successful, otherwise false. |
| 68 bool StartPlayback(); |
| 69 |
| 70 // StopPlayback stops playback of audio. |
| 71 // |
| 72 // @return true if successful, otherwise false. |
| 73 bool StopPlayback(); |
| 74 |
| 75 // Close closes the audio output device. |
| 76 void Close(); |
| 77 |
| 78 private: |
| 79 AudioConfig config_; |
| 80 }; |
| 81 |
| 82 } // namespace pp |
| 83 |
| 84 #endif // PPAPI_CPP_DEV_AUDIO_OUTPUT_DEV_H_ |
OLD | NEW |