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 // The <code>chrome.audio</code> API is provided to allow users to
6 // get information about and control the audio devices attached to the
7 // system. This API is currently only implemented for ChromeOS.
10 dictionary OutputDeviceInfo
{
11 // The unique identifier of the audio output device.
13 // The user-friendly name (e.g. "Bose Amplifier").
15 // True if this is the current active device.
17 // True if this is muted.
19 // The output volume ranging from 0.0 to 100.0.
23 dictionary InputDeviceInfo
{
24 // The unique identifier of the audio input device.
26 // The user-friendly name (e.g. "USB Microphone").
28 // True if this is the current active device.
30 // True if this is muted.
32 // The input gain ranging from 0.0 to 100.0.
36 dictionary AudioDeviceInfo
{
37 // The unique identifier of the audio device.
39 // True for input device; false for output device.
41 // Type of the device, including "INTERNAL_SPEAKER", "INTERNAL_MIC",
42 // "HEADPHONE", "USB", "BLUETOOTH", "HDMI", "MIC", "KEYBOARD_MIC",
43 // "AOKR", and "OTHER".
45 // The user-friendly name (e.g. "USB Microphone").
46 DOMString displayName
;
49 // True if this is the current active device.
51 // True if this is muted.
53 // The sound level of the device, volume for output, gain for input.
55 // The stable/persisted device id string when available.
56 DOMString? stableDeviceId
;
59 dictionary DeviceProperties
{
60 // True if this is muted.
62 // If this is an output device then this field indicates the output volume.
63 // If this is an input device then this field is ignored.
65 // If this is an input device then this field indicates the input gain.
66 // If this is an output device then this field is ignored.
70 callback GetInfoCallback
= void(OutputDeviceInfo
[] outputInfo
,
71 InputDeviceInfo
[] inputInfo
);
72 callback SetActiveDevicesCallback
= void();
73 callback SetPropertiesCallback
= void();
76 // Gets the information of all audio output and input devices.
77 static
void getInfo
(GetInfoCallback
callback);
79 // Sets the active devices to the devices specified by |ids|.
80 // It can pass in the "complete" active device id list of either input
81 // devices, or output devices, or both. If only input device ids are passed
82 // in, it will only change the input devices' active status, output devices will
83 // NOT be changed; similarly for the case if only output devices are passed.
84 // If the devices specified in |new_active_ids| are already active, they will
85 // remain active. Otherwise, the old active devices will be de-activated
86 // before we activate the new devices with the same type(input/output).
87 static
void setActiveDevices
(DOMString
[] ids
,
88 SetActiveDevicesCallback
callback);
90 // Sets the properties for the input or output device.
91 static
void setProperties
(DOMString
id,
92 DeviceProperties properties
,
93 SetPropertiesCallback
callback);
97 // Fired when anything changes to the audio device configuration.
98 static
void onDeviceChanged
();
100 // Fired when sound level changes for an active audio device.
101 // |id|: id of the audio device.
102 // |level|: new sound level of device(volume for output, gain for input).
103 static
void OnLevelChanged
(DOMString
id, long level
);
105 // Fired when the mute state of the audio input or output changes.
106 // |isInput|: true indicating audio input; false indicating audio output.
107 // |isMuted|: new value of mute state.
108 static
void OnMuteChanged
(boolean isInput
, boolean isMuted
);
110 // Fired when audio devices change, either new devices being added, or
111 // existing devices being removed.
112 // |devices|: List of all present audio devices after the change.
113 static
void OnDevicesChanged
(AudioDeviceInfo
[] devices
);