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 EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
6 #define EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/memory/linked_ptr.h"
14 #include "extensions/common/api/audio.h"
16 namespace extensions
{
18 using OutputInfo
= std::vector
<linked_ptr
<core_api::audio::OutputDeviceInfo
>>;
19 using InputInfo
= std::vector
<linked_ptr
<core_api::audio::InputDeviceInfo
>>;
20 using DeviceIdList
= std::vector
<std::string
>;
26 // Called when anything changes to the audio device configuration.
27 virtual void OnDeviceChanged() = 0;
30 virtual ~Observer() {}
33 // Callback type for completing to get audio device information.
34 typedef base::Callback
<void(const OutputInfo
&, const InputInfo
&, bool)>
37 // Creates a platform-specific AudioService instance.
38 static AudioService
* CreateInstance();
40 virtual ~AudioService() {}
42 // Called by listeners to this service to add/remove themselves as observers.
43 virtual void AddObserver(Observer
* observer
) = 0;
44 virtual void RemoveObserver(Observer
* observer
) = 0;
46 // Start to query audio device information. Should be called on UI thread.
47 // The |callback| will be invoked once the query is completed.
48 virtual void StartGetInfo(const GetInfoCallback
& callback
) = 0;
50 // Sets the active nodes to the nodes specified by |device_list|.
51 // It can pass in the "complete" active node list of either input
52 // nodes, or output nodes, or both. If only input nodes are passed in,
53 // it will only change the input nodes' active status, output nodes will NOT
54 // be changed; similarly for the case if only output nodes are passed.
55 // If the nodes specified in |new_active_ids| are already active, they will
56 // remain active. Otherwise, the old active nodes will be de-activated before
57 // we activate the new nodes with the same type(input/output).
58 virtual void SetActiveDevices(const DeviceIdList
& device_list
) = 0;
60 // Set the muted and volume/gain properties of a device.
61 virtual bool SetDeviceProperties(const std::string
& device_id
,
70 DISALLOW_COPY_AND_ASSIGN(AudioService
);
73 } // namespace extensions
75 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_