| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "chrome/common/extensions/api/audio.h" | 10 #include "chrome/common/extensions/api/audio.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 typedef std::vector<linked_ptr<api::audio::OutputDeviceInfo> > OutputInfo; | 14 typedef std::vector<linked_ptr<api::audio::OutputDeviceInfo> > OutputInfo; |
| 15 typedef std::vector<linked_ptr<api::audio::InputDeviceInfo> > InputInfo; | 15 typedef std::vector<linked_ptr<api::audio::InputDeviceInfo> > InputInfo; |
| 16 typedef std::vector<std::string> DeviceIdList; | |
| 17 | 16 |
| 18 class AudioService { | 17 class AudioService { |
| 19 public: | 18 public: |
| 20 class Observer { | 19 class Observer { |
| 21 public: | 20 public: |
| 22 // Called when anything changes to the audio device configuration. | 21 // Called when anything changes to the audio device configuration. |
| 23 virtual void OnDeviceChanged() = 0; | 22 virtual void OnDeviceChanged() = 0; |
| 24 | 23 |
| 25 protected: | 24 protected: |
| 26 virtual ~Observer() {} | 25 virtual ~Observer() {} |
| 27 }; | 26 }; |
| 28 | 27 |
| 29 // Callback type for completing to get audio device information. | 28 // Callback type for completing to get audio device information. |
| 30 typedef base::Callback<void(const OutputInfo&, const InputInfo&, bool)> | 29 typedef base::Callback<void(const OutputInfo&, const InputInfo&, bool)> |
| 31 GetInfoCallback; | 30 GetInfoCallback; |
| 32 | 31 |
| 33 // Creates a platform-specific AudioService instance. | 32 // Creates a platform-specific AudioService instance. |
| 34 static AudioService* CreateInstance(); | 33 static AudioService* CreateInstance(); |
| 35 | 34 |
| 36 virtual ~AudioService() {} | 35 virtual ~AudioService() {} |
| 37 | 36 |
| 38 // Called by listeners to this service to add/remove themselves as observers. | 37 // Called by listeners to this service to add/remove themselves as observers. |
| 39 virtual void AddObserver(Observer* observer) = 0; | 38 virtual void AddObserver(Observer* observer) = 0; |
| 40 virtual void RemoveObserver(Observer* observer) = 0; | 39 virtual void RemoveObserver(Observer* observer) = 0; |
| 41 | 40 |
| 42 // Start to query audio device information. Should be called on UI thread. | 41 // Start to query audio device information. Should be called on UI thread. |
| 43 // The |callback| will be invoked once the query is completed. | 42 // The |callback| will be invoked once the query is completed. |
| 44 virtual void StartGetInfo(const GetInfoCallback& callback) = 0; | 43 virtual void StartGetInfo(const GetInfoCallback& callback) = 0; |
| 45 | 44 |
| 46 // Set the devices in the following list as active. This will only pick | |
| 47 // the first input and first active devices to set to active. | |
| 48 virtual void SetActiveDevices(const DeviceIdList& device_list) = 0; | |
| 49 | |
| 50 // Set the muted and volume/gain properties of a device. | |
| 51 virtual bool SetDeviceProperties(const std::string& device_id, | |
| 52 bool muted, | |
| 53 int volume, | |
| 54 int gain) = 0; | |
| 55 | |
| 56 protected: | 45 protected: |
| 57 AudioService() {} | 46 AudioService() {} |
| 58 | 47 |
| 59 DISALLOW_COPY_AND_ASSIGN(AudioService); | 48 DISALLOW_COPY_AND_ASSIGN(AudioService); |
| 60 }; | 49 }; |
| 61 | 50 |
| 62 | 51 |
| 63 } // namespace extensions | 52 } // namespace extensions |
| 64 | 53 |
| 65 #endif // CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_ | 54 #endif // CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_ |
| OLD | NEW |