• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_
7 
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "chrome/common/extensions/api/audio.h"
11 
12 namespace extensions {
13 
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;
17 
18 class AudioService {
19  public:
20   class Observer {
21    public:
22     // Called when anything changes to the audio device configuration.
23     virtual void OnDeviceChanged() = 0;
24 
25    protected:
~Observer()26     virtual ~Observer() {}
27   };
28 
29   // Callback type for completing to get audio device information.
30   typedef base::Callback<void(const OutputInfo&, const InputInfo&, bool)>
31       GetInfoCallback;
32 
33   // Creates a platform-specific AudioService instance.
34   static AudioService* CreateInstance();
35 
~AudioService()36   virtual ~AudioService() {}
37 
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;
41 
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;
45 
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:
AudioService()57   AudioService() {}
58 
59   DISALLOW_COPY_AND_ASSIGN(AudioService);
60 };
61 
62 
63 }  // namespace extensions
64 
65 #endif  // CHROME_BROWSER_EXTENSIONS_API_AUDIO_AUDIO_SERVICE_H_
66