Home | History | Annotate | Download | only in api
      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.
      4 
      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.
      8 namespace audio {
      9 
     10   dictionary OutputDeviceInfo {
     11     // The unique identifier of the audio output device.
     12     DOMString id;
     13     // The user-friendly name (e.g. "Bose Amplifier").
     14     DOMString name;
     15     // True if this is the current active device.
     16     boolean isActive;
     17     // True if this is muted.
     18     boolean isMuted;
     19     // The output volume ranging from 0.0 to 1.0.
     20     double volume;
     21   };
     22 
     23   dictionary InputDeviceInfo {
     24     // The unique identifier of the audio input device.
     25     DOMString id;
     26     // The user-friendly name (e.g. "USB Microphone").
     27     DOMString name;
     28     // True if this is the current active device.
     29     boolean isActive;
     30     // True if this is muted.
     31     boolean isMuted;
     32     // The input gain ranging from 0.0 to 1.0.
     33     double gain;
     34   };
     35 
     36   dictionary DeviceProperties {
     37     // True if this is muted.
     38     boolean isMuted;
     39     // If this is an output device then this field indicates the output volume.
     40     // If this is an input device then this field is ignored.
     41     double? volume;
     42     // If this is an input device then this field indicates the input gain.
     43     // If this is an output device then this field is ignored.
     44     double? gain;
     45   };
     46 
     47   callback GetInfoCallback = void(OutputDeviceInfo[] outputInfo,
     48                                   InputDeviceInfo[] inputInfo);
     49   callback SetActiveDevicesCallback = void();
     50   callback SetPropertiesCallback = void();
     51 
     52   interface Functions {
     53     // Get the information of all audio output and input devices.
     54     static void getInfo(GetInfoCallback callback);
     55 
     56     // Select a subset of audio devices as active.
     57     static void setActiveDevices(DOMString[] ids,
     58                                  SetActiveDevicesCallback callback);
     59 
     60     // Sets the properties for the input or output device.
     61     static void setProperties(DOMString id,
     62                               DeviceProperties properties,
     63                               SetPropertiesCallback callback);
     64   };
     65 
     66   interface Events {
     67     // Fired when anything changes to the audio device configuration.
     68     static void onDeviceChanged();
     69   };
     70 };
     71