Avi Drissman | d387f092 | 2022-09-14 20:51:31 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Thomas Guilbert | a3e0d57 | 2022-02-08 19:26:42 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | module media.mojom; |
| 6 | |
Sam Zackrisson | 0ed2381 | 2022-02-23 11:43:23 | [diff] [blame] | 7 | // Stats from software audio processing in the audio service. Are passed upon |
| 8 | // request from the renderer, see AudioProcessorControls::GetStats() in this |
| 9 | // file. |
| 10 | struct AudioProcessingStats { |
| 11 | |
| 12 | // TODO(https://crbug.com/657632): Numeric values cannot be optional, so add |
| 13 | // flags for each of them. |
| 14 | bool has_echo_return_loss; |
| 15 | double echo_return_loss; |
| 16 | |
| 17 | bool has_echo_return_loss_enhancement; |
| 18 | double echo_return_loss_enhancement; |
| 19 | }; |
Thomas Guilbert | a3e0d57 | 2022-02-08 19:26:42 | [diff] [blame] | 20 | |
| 21 | // Settings for the software audio processing performed in the audio service. |
| 22 | // The settings are determined in the renderer from media constraints passed by |
| 23 | // JavaScript clients and platform capabilities, and are passed to the audio |
| 24 | // service where the actual processing is applied. |
| 25 | struct AudioProcessingSettings { |
| 26 | bool echo_cancellation; |
| 27 | bool noise_suppression; |
| 28 | bool transient_noise_suppression; |
| 29 | bool automatic_gain_control; |
Thomas Guilbert | a3e0d57 | 2022-02-08 19:26:42 | [diff] [blame] | 30 | bool high_pass_filter; |
| 31 | bool multi_channel_capture_processing; |
| 32 | bool stereo_mirroring; |
| 33 | bool force_apm_creation; |
| 34 | }; |
| 35 | |
| 36 | // This interface is hosted in the audio service and called from the renderer. |
Sam Zackrisson | 0ed2381 | 2022-02-23 11:43:23 | [diff] [blame] | 37 | // It is only used when the audio processing is performed in the audio service. |
Thomas Guilbert | a3e0d57 | 2022-02-08 19:26:42 | [diff] [blame] | 38 | interface AudioProcessorControls { |
Sam Zackrisson | 0ed2381 | 2022-02-23 11:43:23 | [diff] [blame] | 39 | |
| 40 | // Request the latest stats from the audio processor. At the farthest level, |
| 41 | // this is triggered by calls from JavaScript, through some levels of |
| 42 | // indirection. (See: https://www.w3.org/TR/webrtc-stats/). Since there are no |
| 43 | // guarantees in the standard about the rate at which stats change, it is |
| 44 | // reasonable to let multiple user-facing calls result in just one call to |
| 45 | // this function. |
| 46 | GetStats() => (AudioProcessingStats stats); |
| 47 | |
| 48 | // Sets a preferred number of capture audio channels. This allows the audio |
| 49 | // processor to avoid unnecessary computational load when the number of input |
| 50 | // audio channels exceeds what is used by the input consumers. |
| 51 | // Values less than 1 and greater than the input stream capacity are adjusted |
| 52 | // to the nearest valid number. |
| 53 | SetPreferredNumCaptureChannels(int32 num_preferred_channels); |
Thomas Guilbert | a3e0d57 | 2022-02-08 19:26:42 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct AudioProcessingConfig { |
| 57 | // Used for getting stats and controlling diagnostic audio recordings (AEC |
| 58 | // dumps). |
| 59 | pending_receiver<AudioProcessorControls> controls_receiver; |
| 60 | |
| 61 | // Used for determining which kind of audio processing is enabled. |
| 62 | AudioProcessingSettings settings; |
| 63 | }; |