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

media / mojo / mojom / audio_processing.mojom [blame]

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module media.mojom;

// Stats from software audio processing in the audio service. Are passed upon
// request from the renderer, see AudioProcessorControls::GetStats() in this
// file.
struct AudioProcessingStats {

  // TODO(crbug.com/40489779): Numeric values cannot be optional, so add
  // flags for each of them.
  bool has_echo_return_loss;
  double echo_return_loss;

  bool has_echo_return_loss_enhancement;
  double echo_return_loss_enhancement;
};

// Settings for the software audio processing performed in the audio service.
// The settings are determined in the renderer from media constraints passed by
// JavaScript clients and platform capabilities, and are passed to the audio
// service where the actual processing is applied.
struct AudioProcessingSettings {
  bool echo_cancellation;
  bool noise_suppression;
  bool automatic_gain_control;
  bool multi_channel_capture_processing;
};

// This interface is hosted in the audio service and called from the renderer.
// It is only used when the audio processing is performed in the audio service.
interface AudioProcessorControls {

  // Request the latest stats from the audio processor. At the farthest level,
  // this is triggered by calls from JavaScript, through some levels of
  // indirection. (See: https://www.w3.org/TR/webrtc-stats/). Since there are no
  // guarantees in the standard about the rate at which stats change, it is
  // reasonable to let multiple user-facing calls result in just one call to
  // this function.
  GetStats() => (AudioProcessingStats stats);

  // Sets a preferred number of capture audio channels. This allows the audio
  // processor to avoid unnecessary computational load when the number of input
  // audio channels exceeds what is used by the input consumers.
  // Values less than 1 and greater than the input stream capacity are adjusted
  // to the nearest valid number.
  SetPreferredNumCaptureChannels(int32 num_preferred_channels);
};

struct AudioProcessingConfig {
  // Used for getting stats and controlling diagnostic audio recordings (AEC
  // dumps).
  pending_receiver<AudioProcessorControls> controls_receiver;

  // Used for determining which kind of audio processing is enabled.
  AudioProcessingSettings settings;
};