| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 // True if this is the current active device. | 74 // True if this is the current active device. |
| 75 boolean isActive; | 75 boolean isActive; |
| 76 // True if this is muted. | 76 // True if this is muted. |
| 77 boolean isMuted; | 77 boolean isMuted; |
| 78 // The sound level of the device, volume for output, gain for input. | 78 // The sound level of the device, volume for output, gain for input. |
| 79 long level; | 79 long level; |
| 80 // The stable/persisted device id string when available. | 80 // The stable/persisted device id string when available. |
| 81 DOMString? stableDeviceId; | 81 DOMString? stableDeviceId; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 dictionary DeviceFilter { |
| 85 // If set, only audio devices whose stream type is included in this list |
| 86 // will satisfy the filter. |
| 87 StreamType[]? streamTypes; |
| 88 |
| 89 // If set, only audio devices whose active state matches this value will |
| 90 // satisfy the filter. |
| 91 boolean? isActive; |
| 92 }; |
| 93 |
| 84 dictionary DeviceProperties { | 94 dictionary DeviceProperties { |
| 85 // True if this is muted. | 95 // True if this is muted. |
| 86 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; | 96 [deprecated="Use $(ref:setMute) to set mute state."] boolean? isMuted; |
| 97 |
| 87 // If this is an output device then this field indicates the output volume. | 98 // 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. | 99 // If this is an input device then this field is ignored. |
| 89 double? volume; | 100 [deprecated="Use |level| to set output volume."] double? volume; |
| 101 |
| 90 // If this is an input device then this field indicates the input gain. | 102 // 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. | 103 // If this is an output device then this field is ignored. |
| 92 double? gain; | 104 [deprecated="Use |level| to set input gain."] double? gain; |
| 105 |
| 106 // <p> |
| 107 // The audio device's desired sound level. Defaults to the device's |
| 108 // current sound level. |
| 109 // </p> |
| 110 // <p>If used with audio input device, represents audio device gain.</p> |
| 111 // <p>If used with audio output device, represents audio device volume.</p> |
| 112 long? level; |
| 93 }; | 113 }; |
| 94 | 114 |
| 95 dictionary DeviceIdLists { | 115 dictionary DeviceIdLists { |
| 96 // <p>List of input devices specified by their ID.</p> | 116 // <p>List of input devices specified by their ID.</p> |
| 97 // <p>To indicate input devices should be unaffected, leave this property | 117 // <p>To indicate input devices should be unaffected, leave this property |
| 98 // unset.</p> | 118 // unset.</p> |
| 99 DOMString[]? input; | 119 DOMString[]? input; |
| 100 | 120 |
| 101 // <p>List of output devices specified by their ID.</p> | 121 // <p>List of output devices specified by their ID.</p> |
| 102 // <p>To indicate output devices should be unaffected, leave this property | 122 // <p>To indicate output devices should be unaffected, leave this property |
| 103 // unset.</p> | 123 // unset.</p> |
| 104 DOMString[]? output; | 124 DOMString[]? output; |
| 105 }; | 125 }; |
| 106 | 126 |
| 107 dictionary MuteChangedEvent { | 127 dictionary MuteChangedEvent { |
| 108 // The type of the stream for which the mute value changed. The updated mute | 128 // The type of the stream for which the mute value changed. The updated mute |
| 109 // value applies to all devices with this stream type. | 129 // value applies to all devices with this stream type. |
| 110 StreamType streamType; | 130 StreamType streamType; |
| 111 | 131 |
| 112 // Whether or not the stream is now muted. | 132 // Whether or not the stream is now muted. |
| 113 boolean isMuted; | 133 boolean isMuted; |
| 114 }; | 134 }; |
| 115 | 135 |
| 136 dictionary LevelChangedEvent { |
| 137 // ID of device whose sound level has changed. |
| 138 DOMString deviceId; |
| 139 |
| 140 // The device's new sound level. |
| 141 long level; |
| 142 }; |
| 143 |
| 116 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, | 144 callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo, |
| 117 InputDeviceInfo[] inputInfo); | 145 InputDeviceInfo[] inputInfo); |
| 146 callback GetDevicesCallback = void(AudioDeviceInfo[] devices); |
| 147 callback GetMuteCallback = void(boolean value); |
| 118 callback EmptyCallback = void(); | 148 callback EmptyCallback = void(); |
| 119 callback GetMuteCallback = void(boolean value); | |
| 120 | 149 |
| 121 interface Functions { | 150 interface Functions { |
| 122 // Gets the information of all audio output and input devices. | 151 // Gets the information of all audio output and input devices. |
| 123 static void getInfo(GetInfoCallback callback); | 152 static void getInfo(GetInfoCallback callback); |
| 124 | 153 |
| 154 // Gets a list of audio devices filtered based on |filter|. |
| 155 // |filter|: Device properties by which to filter the list of returned |
| 156 // audio devices. Use <code>{}</code> to get all available audio |
| 157 // devices. |
| 158 // |callback|: Reports the requested list of audio devices. |
| 159 static void getDevices(DeviceFilter filter, GetDevicesCallback callback); |
| 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. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 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); |
| 157 }; | 193 }; |
| 158 | 194 |
| 159 interface Events { | 195 interface Events { |
| 160 // Fired when anything changes to the audio device configuration. | 196 // Fired when anything changes to the audio device configuration. |
| 161 static void onDeviceChanged(); | 197 static void onDeviceChanged(); |
| 162 | 198 |
| 163 // Fired when sound level changes for an active audio device. | 199 // Fired when sound level changes for an active audio device. |
| 164 // |id|: id of the audio device. | 200 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 | 201 |
| 168 // Fired when the mute state of the audio input or output changes. | 202 // 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 | 203 // Note that mute state is system-wide and the new value applies to every |
| 170 // audio device with specified stream type. | 204 // audio device with specified stream type. |
| 171 static void onMuteChanged(MuteChangedEvent event); | 205 static void onMuteChanged(MuteChangedEvent event); |
| 172 | 206 |
| 173 // Fired when audio devices change, either new devices being added, or | 207 // Fired when audio devices change, either new devices being added, or |
| 174 // existing devices being removed. | 208 // existing devices being removed. |
| 175 // |devices|: List of all present audio devices after the change. | 209 // |devices|: List of all present audio devices after the change. |
| 176 static void OnDevicesChanged(AudioDeviceInfo[] devices); | 210 static void onDeviceListChanged(AudioDeviceInfo[] devices); |
| 177 }; | 211 }; |
| 178 }; | 212 }; |
| OLD | NEW |