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 // Sets the active nodes to the nodes specified by |device_list|.
47 // It can pass in the "complete" active node list of either input
48 // nodes, or output nodes, or both. If only input nodes are passed in,
49 // it will only change the input nodes' active status, output nodes will NOT
50 // be changed; similarly for the case if only output nodes are passed.
51 // If the nodes specified in |new_active_ids| are already active, they will
52 // remain active. Otherwise, the old active nodes will be de-activated before
53 // we activate the new nodes with the same type(input/output).
54 virtual void SetActiveDevices(const DeviceIdList& device_list) = 0;
56 // Set the muted and volume/gain properties of a device.
57 virtual bool SetDeviceProperties(const std::string& device_id,
65 DISALLOW_COPY_AND_ASSIGN(AudioService);
69 } // namespace extensions
71 #endif // CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_