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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "chrome/common/extensions/api/audio.h"
12 namespace extensions
{
14 typedef std::vector
<linked_ptr
<api::audio::OutputDeviceInfo
> > OutputInfo
;
15 typedef std::vector
<linked_ptr
<api::audio::InputDeviceInfo
> > InputInfo
;
16 typedef std::vector
<std::string
> DeviceIdList
;
22 // Called when anything changes to the audio device configuration.
23 virtual void OnDeviceChanged() = 0;
26 virtual ~Observer() {}
29 // Callback type for completing to get audio device information.
30 typedef base::Callback
<void(const OutputInfo
&, const InputInfo
&, bool)>
33 // Creates a platform-specific AudioService instance.
34 static AudioService
* CreateInstance();
36 virtual ~AudioService() {}
38 // Called by listeners to this service to add/remove themselves as observers.
39 virtual void AddObserver(Observer
* observer
) = 0;
40 virtual void RemoveObserver(Observer
* observer
) = 0;
42 // Start to query audio device information. Should be called on UI thread.
43 // The |callback| will be invoked once the query is completed.
44 virtual void StartGetInfo(const GetInfoCallback
& callback
) = 0;
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;
50 // Set the muted and volume/gain properties of a device.
51 virtual bool SetDeviceProperties(const std::string
& device_id
,
59 DISALLOW_COPY_AND_ASSIGN(AudioService
);
63 } // namespace extensions
65 #endif // CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_