Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The <code>chrome.audio</code> API is provided to allow users to | 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 | 6 // get information about and control the audio devices attached to the |
| 7 // system. This API is currently only implemented for ChromeOS. | 7 // system. This API is currently only implemented for ChromeOS. |
| 8 namespace audio { | 8 namespace audio { |
| 9 | 9 |
| 10 // Type of stream an audio device provides. | |
| 11 enum StreamType { | |
| 12 INPUT, | |
| 13 OUTPUT | |
| 14 }; | |
| 15 | |
| 10 dictionary OutputDeviceInfo { | 16 dictionary OutputDeviceInfo { |
| 11 // The unique identifier of the audio output device. | 17 // The unique identifier of the audio output device. |
| 12 DOMString id; | 18 DOMString id; |
| 13 // The user-friendly name (e.g. "Bose Amplifier"). | 19 // The user-friendly name (e.g. "Bose Amplifier"). |
| 14 DOMString name; | 20 DOMString name; |
| 15 // True if this is the current active device. | 21 // True if this is the current active device. |
| 16 boolean isActive; | 22 boolean isActive; |
| 17 // True if this is muted. | 23 // True if this is muted. |
| 18 boolean isMuted; | 24 boolean isMuted; |
| 19 // The output volume ranging from 0.0 to 100.0. | 25 // The output volume ranging from 0.0 to 100.0. |
| 20 double volume; | 26 double volume; |
| 21 }; | 27 }; |
| 22 | 28 |
| 23 dictionary InputDeviceInfo { | 29 dictionary InputDeviceInfo { |
| 24 // The unique identifier of the audio input device. | 30 // The unique identifier of the audio input device. |
| 25 DOMString id; | 31 DOMString id; |
| 26 // The user-friendly name (e.g. "USB Microphone"). | 32 // The user-friendly name (e.g. "USB Microphone"). |
| 27 DOMString name; | 33 DOMString name; |
| 28 // True if this is the current active device. | 34 // True if this is the current active device. |
| 29 boolean isActive; | 35 boolean isActive; |
| 30 // True if this is muted. | 36 // True if this is muted. |
| 31 boolean isMuted; | 37 boolean isMuted; |
| 32 // The input gain ranging from 0.0 to 100.0. | 38 // The input gain ranging from 0.0 to 100.0. |
| 33 double gain; | 39 double gain; |
| 34 }; | 40 }; |
| 35 | 41 |
| 36 dictionary AudioDeviceInfo { | 42 dictionary AudioDeviceInfo { |
| 37 // The unique identifier of the audio device. | 43 // The unique identifier of the audio device. |
| 38 DOMString id; | 44 DOMString id; |
| 45 // Stream type associated with this device (input or output). | |
|
Devlin
2017/01/25 16:12:24
nit: given we specify what StreamType can be above
tbarzic
2017/01/25 19:32:29
Done.
| |
| 46 StreamType streamType; | |
| 39 // True for input device; false for output device. | 47 // True for input device; false for output device. |
| 40 boolean isInput; | 48 [deprecated="Use |streamType|."] boolean isInput; |
| 41 // Type of the device, including "INTERNAL_SPEAKER", "INTERNAL_MIC", | 49 // Type of the device, including "INTERNAL_SPEAKER", "INTERNAL_MIC", |
| 42 // "HEADPHONE", "USB", "BLUETOOTH", "HDMI", "MIC", "KEYBOARD_MIC", | 50 // "HEADPHONE", "USB", "BLUETOOTH", "HDMI", "MIC", "KEYBOARD_MIC", |
| 43 // "AOKR", and "OTHER". | 51 // "AOKR", and "OTHER". |
| 44 DOMString deviceType; | 52 DOMString deviceType; |
| 45 // The user-friendly name (e.g. "USB Microphone"). | 53 // The user-friendly name (e.g. "USB Microphone"). |
| 46 DOMString displayName; | 54 DOMString displayName; |
| 47 // Device name. | 55 // Device name. |
| 48 DOMString deviceName; | 56 DOMString deviceName; |
| 49 // True if this is the current active device. | 57 // True if this is the current active device. |
| 50 boolean isActive; | 58 boolean isActive; |
| 51 // True if this is muted. | 59 // True if this is muted. |
| 52 boolean isMuted; | 60 boolean isMuted; |
| 53 // The sound level of the device, volume for output, gain for input. | 61 // The sound level of the device, volume for output, gain for input. |
| 54 long level; | 62 long level; |
| 55 // The stable/persisted device id string when available. | 63 // The stable/persisted device id string when available. |
| 56 DOMString? stableDeviceId; | 64 DOMString? stableDeviceId; |
| 57 }; | 65 }; |
| 58 | 66 |
| 59 dictionary DeviceProperties { | 67 dictionary DeviceProperties { |
| 60 // True if this is muted. | 68 // True if this is muted. |
| 61 boolean isMuted; | 69 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; |
| 62 // If this is an output device then this field indicates the output volume. | 70 // 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. | 71 // If this is an input device then this field is ignored. |
| 64 double? volume; | 72 double? volume; |
| 65 // If this is an input device then this field indicates the input gain. | 73 // 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. | 74 // If this is an output device then this field is ignored. |
| 67 double? gain; | 75 double? gain; |
| 68 }; | 76 }; |
| 69 | 77 |
| 70 dictionary DeviceIdLists { | 78 dictionary DeviceIdLists { |
| 71 // <p>List of input devices specified by their ID.</p> | 79 // <p>List of input devices specified by their ID.</p> |
| 72 // <p>To indicate input devices should be unaffected, leave this property | 80 // <p>To indicate input devices should be unaffected, leave this property |
| 73 // unset.</p> | 81 // unset.</p> |
| 74 DOMString[]? input; | 82 DOMString[]? input; |
| 75 | 83 |
| 76 // <p>List of output devices specified by their ID.</p> | 84 // <p>List of output devices specified by their ID.</p> |
| 77 // <p>To indicate output devices should be unaffected, leave this property | 85 // <p>To indicate output devices should be unaffected, leave this property |
| 78 // unset.</p> | 86 // unset.</p> |
| 79 DOMString[]? output; | 87 DOMString[]? output; |
| 80 }; | 88 }; |
| 81 | 89 |
| 90 dictionary MuteChangedEvent { | |
| 91 // Type of the stream for which mute value has changed. The updated mute | |
|
Devlin
2017/01/25 16:12:23
nitty nit:
The type of the stream for which the mu
tbarzic
2017/01/25 19:32:29
Done.
| |
| 92 // value applies to all devices with this stream type. | |
| 93 StreamType streamType; | |
| 94 | |
| 95 // Value to which mute state changed. | |
|
Devlin
2017/01/25 16:12:23
nitty nit:
Whether or not the stream is now muted
tbarzic
2017/01/25 19:32:29
Done.
| |
| 96 boolean value; | |
|
Devlin
2017/01/25 16:12:23
|value| is a little less descriptive than somethin
tbarzic
2017/01/25 19:32:29
Done.
| |
| 97 }; | |
| 98 | |
| 82 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, | 99 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, |
| 83 InputDeviceInfo[] inputInfo); | 100 InputDeviceInfo[] inputInfo); |
| 84 callback EmptyCallback = void(); | 101 callback EmptyCallback = void(); |
| 102 callback GetMuteCallback = void(boolean value); | |
| 85 | 103 |
| 86 interface Functions { | 104 interface Functions { |
| 87 // Gets the information of all audio output and input devices. | 105 // Gets the information of all audio output and input devices. |
| 88 static void getInfo(GetInfoCallback callback); | 106 static void getInfo(GetInfoCallback callback); |
| 89 | 107 |
| 90 // Sets lists of active input and/or output devices. | 108 // Sets lists of active input and/or output devices. |
| 91 // |ids|: <p>Specifies IDs of devices that should be active. If either the | 109 // |ids|: <p>Specifies IDs of devices that should be active. If either the |
| 92 // input or output list is not set, devices in that category are | 110 // input or output list is not set, devices in that category are |
| 93 // unaffected. | 111 // unaffected. |
| 94 // </p> | 112 // </p> |
| 95 // <p>It is an error to pass in a non-existent device ID.</p> | 113 // <p>It is an error to pass in a non-existent device ID.</p> |
| 96 // <p><b>NOTE:</b> While the method signature allows device IDs to be | 114 // <p><b>NOTE:</b> While the method signature allows device IDs to be |
| 97 // passed as a list of strings, this method of setting active devices | 115 // passed as a list of strings, this method of setting active devices |
| 98 // is deprecated and should not be relied upon to work. Please use | 116 // is deprecated and should not be relied upon to work. Please use |
| 99 // $(ref: DeviceIdLists) instead. | 117 // $(ref: DeviceIdLists) instead. |
| 100 // </p> | 118 // </p> |
| 101 static void setActiveDevices((DeviceIdLists or DOMString[]) ids, | 119 static void setActiveDevices((DeviceIdLists or DOMString[]) ids, |
| 102 EmptyCallback callback); | 120 EmptyCallback callback); |
| 103 | 121 |
| 104 // Sets the properties for the input or output device. | 122 // Sets the properties for the input or output device. |
| 105 static void setProperties(DOMString id, | 123 static void setProperties(DOMString id, |
| 106 DeviceProperties properties, | 124 DeviceProperties properties, |
| 107 EmptyCallback callback); | 125 EmptyCallback callback); |
| 126 | |
| 127 // Gets system-wide mute state for the specified stream type. | |
| 128 // |streamType|: Stream type for which mute state should be fetched. | |
| 129 // |callback|: Callback reporting whether mute is set or not for specified | |
| 130 // stream type. | |
| 131 static void getMute(StreamType streamType, GetMuteCallback callback); | |
| 132 | |
| 133 // Sets mute state for a stream type. The mute state will apply to all audio | |
| 134 // devices with the specified audio stream type. | |
| 135 // |streamType|: Stream type for which mute status should be set. | |
| 136 // |value|: New mute value. | |
| 137 static void setMute(StreamType streamType, | |
| 138 boolean value, | |
| 139 EmptyCallback callback); | |
|
Devlin
2017/01/25 16:12:23
can this be an optional callback?
tbarzic
2017/01/25 19:32:29
Done.
| |
| 108 }; | 140 }; |
| 109 | 141 |
| 110 interface Events { | 142 interface Events { |
| 111 // Fired when anything changes to the audio device configuration. | 143 // Fired when anything changes to the audio device configuration. |
| 112 static void onDeviceChanged(); | 144 static void onDeviceChanged(); |
| 113 | 145 |
| 114 // Fired when sound level changes for an active audio device. | 146 // Fired when sound level changes for an active audio device. |
| 115 // |id|: id of the audio device. | 147 // |id|: id of the audio device. |
| 116 // |level|: new sound level of device(volume for output, gain for input). | 148 // |level|: new sound level of device(volume for output, gain for input). |
| 117 static void OnLevelChanged(DOMString id, long level); | 149 static void OnLevelChanged(DOMString id, long level); |
| 118 | 150 |
| 119 // Fired when the mute state of the audio input or output changes. | 151 // Fired when the mute state of the audio input or output changes. |
| 120 // |isInput|: true indicating audio input; false indicating audio output. | 152 // Note that mute state is system-wide and the new value applies to every |
| 121 // |isMuted|: new value of mute state. | 153 // audio device with specified stream type. |
| 122 static void OnMuteChanged(boolean isInput, boolean isMuted); | 154 static void onMuteChanged(MuteChangedEvent event); |
|
Devlin
2017/01/25 16:12:23
Are we okay with this breaking change since this A
tbarzic
2017/01/25 19:32:29
We are OK with this because the event doesn't seem
| |
| 123 | 155 |
| 124 // Fired when audio devices change, either new devices being added, or | 156 // Fired when audio devices change, either new devices being added, or |
| 125 // existing devices being removed. | 157 // existing devices being removed. |
| 126 // |devices|: List of all present audio devices after the change. | 158 // |devices|: List of all present audio devices after the change. |
| 127 static void OnDevicesChanged(AudioDeviceInfo[] devices); | 159 static void OnDevicesChanged(AudioDeviceInfo[] devices); |
| 128 }; | 160 }; |
| 129 }; | 161 }; |
| OLD | NEW |