| 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. | 10 // Type of stream an audio device provides. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 FRONT_MIC, | 25 FRONT_MIC, |
| 26 REAR_MIC, | 26 REAR_MIC, |
| 27 KEYBOARD_MIC, | 27 KEYBOARD_MIC, |
| 28 HOTWORD, | 28 HOTWORD, |
| 29 LINEOUT, | 29 LINEOUT, |
| 30 POST_MIX_LOOPBACK, | 30 POST_MIX_LOOPBACK, |
| 31 POST_DSP_LOOPBACK, | 31 POST_DSP_LOOPBACK, |
| 32 OTHER | 32 OTHER |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 [deprecated = "Used only with the deprecated $(ref:getInfo)."] |
| 35 dictionary OutputDeviceInfo { | 36 dictionary OutputDeviceInfo { |
| 36 // The unique identifier of the audio output device. | 37 // The unique identifier of the audio output device. |
| 37 DOMString id; | 38 DOMString id; |
| 38 // The user-friendly name (e.g. "Bose Amplifier"). | 39 // The user-friendly name (e.g. "Bose Amplifier"). |
| 39 DOMString name; | 40 DOMString name; |
| 40 // True if this is the current active device. | 41 // True if this is the current active device. |
| 41 boolean isActive; | 42 boolean isActive; |
| 42 // True if this is muted. | 43 // True if this is muted. |
| 43 boolean isMuted; | 44 boolean isMuted; |
| 44 // The output volume ranging from 0.0 to 100.0. | 45 // The output volume ranging from 0.0 to 100.0. |
| 45 double volume; | 46 double volume; |
| 46 }; | 47 }; |
| 47 | 48 |
| 49 [deprecated = "Used only with the deprecated $(ref:getInfo)."] |
| 48 dictionary InputDeviceInfo { | 50 dictionary InputDeviceInfo { |
| 49 // The unique identifier of the audio input device. | 51 // The unique identifier of the audio input device. |
| 50 DOMString id; | 52 DOMString id; |
| 51 // The user-friendly name (e.g. "USB Microphone"). | 53 // The user-friendly name (e.g. "USB Microphone"). |
| 52 DOMString name; | 54 DOMString name; |
| 53 // True if this is the current active device. | 55 // True if this is the current active device. |
| 54 boolean isActive; | 56 boolean isActive; |
| 55 // True if this is muted. | 57 // True if this is muted. |
| 56 boolean isMuted; | 58 boolean isMuted; |
| 57 // The input gain ranging from 0.0 to 100.0. | 59 // The input gain ranging from 0.0 to 100.0. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 // True if this is the current active device. | 76 // True if this is the current active device. |
| 75 boolean isActive; | 77 boolean isActive; |
| 76 // True if this is muted. | 78 // True if this is muted. |
| 77 boolean isMuted; | 79 boolean isMuted; |
| 78 // The sound level of the device, volume for output, gain for input. | 80 // The sound level of the device, volume for output, gain for input. |
| 79 long level; | 81 long level; |
| 80 // The stable/persisted device id string when available. | 82 // The stable/persisted device id string when available. |
| 81 DOMString? stableDeviceId; | 83 DOMString? stableDeviceId; |
| 82 }; | 84 }; |
| 83 | 85 |
| 86 dictionary DeviceFilter { |
| 87 // If set, only audio devices whose stream type is included in this list |
| 88 // will satisfy the filter. |
| 89 StreamType[]? streamTypes; |
| 90 |
| 91 // If set, only audio devices whose active state matches this value will |
| 92 // satisfy the filter. |
| 93 boolean? isActive; |
| 94 }; |
| 95 |
| 84 dictionary DeviceProperties { | 96 dictionary DeviceProperties { |
| 85 // True if this is muted. | 97 // True if this is muted. |
| 86 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; | 98 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; |
| 99 |
| 87 // If this is an output device then this field indicates the output volume. | 100 // If this is an output device then this field indicates the output volume. |
| 88 // If this is an input device then this field is ignored. | 101 // If this is an input device then this field is ignored. |
| 89 double? volume; | 102 [deprecated="Use |level| to set output volume."] double? volume; |
| 103 |
| 90 // If this is an input device then this field indicates the input gain. | 104 // If this is an input device then this field indicates the input gain. |
| 91 // If this is an output device then this field is ignored. | 105 // If this is an output device then this field is ignored. |
| 92 double? gain; | 106 [deprecated="Use |level| to set input gain."] double? gain; |
| 107 |
| 108 // <p> |
| 109 // The audio device's desired sound level. Defaults to the device's |
| 110 // current sound level. |
| 111 // </p> |
| 112 // <p>If used with audio input device, represents audio device gain.</p> |
| 113 // <p>If used with audio output device, represents audio device volume.</p> |
| 114 long? level; |
| 93 }; | 115 }; |
| 94 | 116 |
| 95 dictionary DeviceIdLists { | 117 dictionary DeviceIdLists { |
| 96 // <p>List of input devices specified by their ID.</p> | 118 // <p>List of input devices specified by their ID.</p> |
| 97 // <p>To indicate input devices should be unaffected, leave this property | 119 // <p>To indicate input devices should be unaffected, leave this property |
| 98 // unset.</p> | 120 // unset.</p> |
| 99 DOMString[]? input; | 121 DOMString[]? input; |
| 100 | 122 |
| 101 // <p>List of output devices specified by their ID.</p> | 123 // <p>List of output devices specified by their ID.</p> |
| 102 // <p>To indicate output devices should be unaffected, leave this property | 124 // <p>To indicate output devices should be unaffected, leave this property |
| 103 // unset.</p> | 125 // unset.</p> |
| 104 DOMString[]? output; | 126 DOMString[]? output; |
| 105 }; | 127 }; |
| 106 | 128 |
| 107 dictionary MuteChangedEvent { | 129 dictionary MuteChangedEvent { |
| 108 // The type of the stream for which the mute value changed. The updated mute | 130 // The type of the stream for which the mute value changed. The updated mute |
| 109 // value applies to all devices with this stream type. | 131 // value applies to all devices with this stream type. |
| 110 StreamType streamType; | 132 StreamType streamType; |
| 111 | 133 |
| 112 // Whether or not the stream is now muted. | 134 // Whether or not the stream is now muted. |
| 113 boolean isMuted; | 135 boolean isMuted; |
| 114 }; | 136 }; |
| 115 | 137 |
| 138 dictionary LevelChangedEvent { |
| 139 // ID of device whose sound level has changed. |
| 140 DOMString deviceId; |
| 141 |
| 142 // The device's new sound level. |
| 143 long level; |
| 144 }; |
| 145 |
| 116 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, | 146 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, |
| 117 InputDeviceInfo[] inputInfo); | 147 InputDeviceInfo[] inputInfo); |
| 148 callback GetDevicesCallback = void(AudioDeviceInfo[] devices); |
| 149 callback GetMuteCallback = void(boolean value); |
| 118 callback EmptyCallback = void(); | 150 callback EmptyCallback = void(); |
| 119 callback GetMuteCallback = void(boolean value); | |
| 120 | 151 |
| 121 interface Functions { | 152 interface Functions { |
| 122 // Gets the information of all audio output and input devices. | 153 // Gets a list of audio devices filtered based on |filter|. |
| 123 static void getInfo(GetInfoCallback callback); | 154 // |filter|: Device properties by which to filter the list of returned |
| 155 // audio devices. If the filter is not set or set to <code>{}</code>, |
| 156 // returned device list will contain all available audio devices. |
| 157 // |callback|: Reports the requested list of audio devices. |
| 158 static void getDevices(optional DeviceFilter filter, |
| 159 GetDevicesCallback callback); |
| 124 | 160 |
| 125 // Sets lists of active input and/or output devices. | 161 // Sets lists of active input and/or output devices. |
| 126 // |ids|: <p>Specifies IDs of devices that should be active. If either the | 162 // |ids|: <p>Specifies IDs of devices that should be active. If either the |
| 127 // input or output list is not set, devices in that category are | 163 // input or output list is not set, devices in that category are |
| 128 // unaffected. | 164 // unaffected. |
| 129 // </p> | 165 // </p> |
| 130 // <p>It is an error to pass in a non-existent device ID.</p> | 166 // <p>It is an error to pass in a non-existent device ID.</p> |
| 131 // <p><b>NOTE:</b> While the method signature allows device IDs to be | 167 // <p><b>NOTE:</b> While the method signature allows device IDs to be |
| 132 // passed as a list of strings, this method of setting active devices | 168 // passed as a list of strings, this method of setting active devices |
| 133 // is deprecated and should not be relied upon to work. Please use | 169 // is deprecated and should not be relied upon to work. Please use |
| 134 // $(ref: DeviceIdLists) instead. | 170 // $(ref:DeviceIdLists) instead. |
| 135 // </p> | 171 // </p> |
| 136 static void setActiveDevices((DeviceIdLists or DOMString[]) ids, | 172 static void setActiveDevices((DeviceIdLists or DOMString[]) ids, |
| 137 EmptyCallback callback); | 173 EmptyCallback callback); |
| 138 | 174 |
| 139 // Sets the properties for the input or output device. | 175 // Sets the properties for the input or output device. |
| 140 static void setProperties(DOMString id, | 176 static void setProperties(DOMString id, |
| 141 DeviceProperties properties, | 177 DeviceProperties properties, |
| 142 EmptyCallback callback); | 178 EmptyCallback callback); |
| 143 | 179 |
| 144 // Gets the system-wide mute state for the specified stream type. | 180 // Gets the system-wide mute state for the specified stream type. |
| 145 // |streamType|: Stream type for which mute state should be fetched. | 181 // |streamType|: Stream type for which mute state should be fetched. |
| 146 // |callback|: Callback reporting whether mute is set or not for specified | 182 // |callback|: Callback reporting whether mute is set or not for specified |
| 147 // stream type. | 183 // stream type. |
| 148 static void getMute(StreamType streamType, GetMuteCallback callback); | 184 static void getMute(StreamType streamType, GetMuteCallback callback); |
| 149 | 185 |
| 150 // Sets mute state for a stream type. The mute state will apply to all audio | 186 // Sets mute state for a stream type. The mute state will apply to all audio |
| 151 // devices with the specified audio stream type. | 187 // devices with the specified audio stream type. |
| 152 // |streamType|: Stream type for which mute state should be set. | 188 // |streamType|: Stream type for which mute state should be set. |
| 153 // |isMuted|: New mute value. | 189 // |isMuted|: New mute value. |
| 154 static void setMute(StreamType streamType, | 190 static void setMute(StreamType streamType, |
| 155 boolean isMuted, | 191 boolean isMuted, |
| 156 optional EmptyCallback callback); | 192 optional EmptyCallback callback); |
| 193 |
| 194 // Gets the information of all audio output and input devices. |
| 195 [deprecated="Use $(ref:getDevices) instead."] |
| 196 static void getInfo(GetInfoCallback callback); |
| 157 }; | 197 }; |
| 158 | 198 |
| 159 interface Events { | 199 interface Events { |
| 160 // Fired when anything changes to the audio device configuration. | |
| 161 static void onDeviceChanged(); | |
| 162 | |
| 163 // Fired when sound level changes for an active audio device. | 200 // Fired when sound level changes for an active audio device. |
| 164 // |id|: id of the audio device. | 201 static void onLevelChanged(LevelChangedEvent event); |
| 165 // |level|: new sound level of device(volume for output, gain for input). | |
| 166 static void OnLevelChanged(DOMString id, long level); | |
| 167 | 202 |
| 168 // Fired when the mute state of the audio input or output changes. | 203 // Fired when the mute state of the audio input or output changes. |
| 169 // Note that mute state is system-wide and the new value applies to every | 204 // Note that mute state is system-wide and the new value applies to every |
| 170 // audio device with specified stream type. | 205 // audio device with specified stream type. |
| 171 static void onMuteChanged(MuteChangedEvent event); | 206 static void onMuteChanged(MuteChangedEvent event); |
| 172 | 207 |
| 173 // Fired when audio devices change, either new devices being added, or | 208 // Fired when audio devices change, either new devices being added, or |
| 174 // existing devices being removed. | 209 // existing devices being removed. |
| 175 // |devices|: List of all present audio devices after the change. | 210 // |devices|: List of all present audio devices after the change. |
| 176 static void OnDevicesChanged(AudioDeviceInfo[] devices); | 211 static void onDeviceListChanged(AudioDeviceInfo[] devices); |
| 212 |
| 213 // Fired when anything changes to the audio device configuration. |
| 214 [deprecated="Use more granular $(ref:onLevelChanged), |
| 215 $(ref:onMuteChanged) and $(ref:onDeviceListChanged) instead."] |
| 216 static void onDeviceChanged(); |
| 177 }; | 217 }; |
| 178 }; | 218 }; |
| OLD | NEW |