Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / api / audio / audio_service.h
blob7aec3c6484ef9939e8544f482da570c5087896d0
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_
8 #include <string>
9 #include <vector>
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<api::audio::OutputDeviceInfo>>;
19 using InputInfo = std::vector<linked_ptr<api::audio::InputDeviceInfo>>;
20 using DeviceIdList = std::vector<std::string>;
21 using DeviceInfoList = std::vector<linked_ptr<api::audio::AudioDeviceInfo>>;
23 class AudioService {
24 public:
25 class Observer {
26 public:
27 // Called when anything changes to the audio device configuration.
28 virtual void OnDeviceChanged() = 0;
30 // Called when the sound level of an active audio device changes.
31 virtual void OnLevelChanged(const std::string& id, int level) = 0;
33 // Called when the mute state of audio input/output changes.
34 virtual void OnMuteChanged(bool is_input, bool is_muted) = 0;
36 // Called when the audio devices change, either new devices being added, or
37 // existing devices being removed.
38 virtual void OnDevicesChanged(const DeviceInfoList&) = 0;
40 protected:
41 virtual ~Observer() {}
44 // Callback type for completing to get audio device information.
45 typedef base::Callback<void(const OutputInfo&, const InputInfo&, bool)>
46 GetInfoCallback;
48 // Creates a platform-specific AudioService instance.
49 static AudioService* CreateInstance();
51 virtual ~AudioService() {}
53 // Called by listeners to this service to add/remove themselves as observers.
54 virtual void AddObserver(Observer* observer) = 0;
55 virtual void RemoveObserver(Observer* observer) = 0;
57 // Start to query audio device information. Should be called on UI thread.
58 // The |callback| will be invoked once the query is completed.
59 virtual void StartGetInfo(const GetInfoCallback& callback) = 0;
61 // Sets the active devices to the devices specified by |device_list|.
62 // It can pass in the "complete" active device list of either input
63 // devices, or output devices, or both. If only input devices are passed in,
64 // it will only change the input devices' active status, output devices will
65 // NOT be changed; similarly for the case if only output devices are passed.
66 // If the devices specified in |new_active_ids| are already active, they will
67 // remain active. Otherwise, the old active devices will be de-activated
68 // before we activate the new devices with the same type(input/output).
69 virtual void SetActiveDevices(const DeviceIdList& device_list) = 0;
71 // Set the muted and volume/gain properties of a device.
72 virtual bool SetDeviceProperties(const std::string& device_id,
73 bool muted,
74 int volume,
75 int gain) = 0;
77 protected:
78 AudioService() {}
80 private:
81 DISALLOW_COPY_AND_ASSIGN(AudioService);
84 } // namespace extensions
86 #endif // EXTENSIONS_BROWSER_API_AUDIO_AUDIO_SERVICE_H_