1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.audio</code> API is provided to allow users to
// get information about and control the audio devices attached to the
// system. This API is currently only implemented for ChromeOS.
namespace audio {
dictionary OutputDeviceInfo {
// The unique identifier of the audio output device.
DOMString id;
// The user-friendly name (e.g. "Bose Amplifier").
DOMString name;
// True if this is the current active device.
boolean isActive;
// True if this is muted.
boolean isMuted;
// The output volume ranging from 0.0 to 100.0.
double volume;
};
dictionary InputDeviceInfo {
// The unique identifier of the audio input device.
DOMString id;
// The user-friendly name (e.g. "USB Microphone").
DOMString name;
// True if this is the current active device.
boolean isActive;
// True if this is muted.
boolean isMuted;
// The input gain ranging from 0.0 to 100.0.
double gain;
};
dictionary AudioDeviceInfo {
// The unique identifier of the audio device.
DOMString id;
// True for input device; false for output device.
boolean isInput;
// Type of the device, including "INTERNAL_SPEAKER", "INTERNAL_MIC",
// "HEADPHONE", "USB", "BLUETOOTH", "HDMI", "MIC", "KEYBOARD_MIC",
// "AOKR", and "OTHER".
DOMString deviceType;
// The user-friendly name (e.g. "USB Microphone").
DOMString displayName;
// Device name.
DOMString deviceName;
// True if this is the current active device.
boolean isActive;
// True if this is muted.
boolean isMuted;
// The sound level of the device, volume for output, gain for input.
long level;
// The stable/persisted device id string when available.
DOMString? stableDeviceId;
};
dictionary DeviceProperties {
// True if this is muted.
boolean isMuted;
// If this is an output device then this field indicates the output volume.
// If this is an input device then this field is ignored.
double? volume;
// If this is an input device then this field indicates the input gain.
// If this is an output device then this field is ignored.
double? gain;
};
callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo,
InputDeviceInfo[] inputInfo);
callback SetActiveDevicesCallback = void();
callback SetPropertiesCallback = void();
interface Functions {
// Gets the information of all audio output and input devices.
static void getInfo(GetInfoCallback callback);
// Sets the active devices to the devices specified by |ids|.
// It can pass in the "complete" active device id list of either input
// devices, or output devices, or both. If only input device ids are passed
// in, it will only change the input devices' active status, output devices will
// NOT be changed; similarly for the case if only output devices are passed.
// If the devices specified in |new_active_ids| are already active, they will
// remain active. Otherwise, the old active devices will be de-activated
// before we activate the new devices with the same type(input/output).
static void setActiveDevices(DOMString[] ids,
SetActiveDevicesCallback callback);
// Sets the properties for the input or output device.
static void setProperties(DOMString id,
DeviceProperties properties,
SetPropertiesCallback callback);
};
interface Events {
// Fired when anything changes to the audio device configuration.
static void onDeviceChanged();
// Fired when sound level changes for an active audio device.
// |id|: id of the audio device.
// |level|: new sound level of device(volume for output, gain for input).
static void OnLevelChanged(DOMString id, long level);
// Fired when the mute state of the audio input or output changes.
// |isInput|: true indicating audio input; false indicating audio output.
// |isMuted|: new value of mute state.
static void OnMuteChanged(boolean isInput, boolean isMuted);
// Fired when audio devices change, either new devices being added, or
// existing devices being removed.
// |devices|: List of all present audio devices after the change.
static void OnDevicesChanged(AudioDeviceInfo[] devices);
};
};
|