// Copyright 2018 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; import "media/mojo/mojom/audio_data_pipe.mojom"; import "media/mojo/mojom/audio_input_stream.mojom"; import "media/mojo/mojom/audio_logging.mojom"; import "media/mojo/mojom/audio_output_stream.mojom"; import "media/mojo/mojom/audio_parameters.mojom"; import "media/mojo/mojom/audio_processing.mojom"; import "mojo/public/mojom/base/shared_memory.mojom"; import "mojo/public/mojom/base/unguessable_token.mojom"; // Mutes a group of AudioOutputStreams while at least one binding to an instance // exists. Once the last binding is dropped, all streams in the group are // un-muted. interface LocalMuter {}; // This interface is exposed by the audio service to allow trusted clients // (like the browser process) to create streams. Note that while the factory // interface itself is only for trusted clients, the created streams and data // pipes may be forwarded to untrusted clients. // // The client must keep the connection to the factory while streams are // running. interface AudioStreamFactory { // Creates an AudioInputStream and returns the AudioDataPipe it writes data to // and a bool indicating whether the stream is initially muted. |data_pipe| is // null, |initially_muted| is false and |stream_id| is empty in case stream // creation failed. // |device_id| is either the |unique_id| field from an AudioDeviceDescription // obtained from the audio.mojom.SystemInfo interface, or "default". // |shared_memory_count| indicates how many buffer segments can the input // stream client read at once, to avoid data overwriting. |enable_agc| is used // for enabling automatic gain control. |key_press_count_buffer| is an // optional readonly shared memory handle for reading the current key press // count, updated by browser process in media::UserInputMonitor // implementation. When |processing_config| is passed, audio processing is // requested (described by |processing_config|), and the audio service will // apply it, on supported platforms (Win, Mac so far). CreateInputStream( pending_receiver stream, pending_remote client, pending_remote? observer, pending_remote? log, string device_id, media.mojom.AudioParameters params, uint32 shared_memory_count, bool enable_agc, mojo_base.mojom.ReadOnlySharedMemoryRegion? key_press_count_buffer, media.mojom.AudioProcessingConfig? processing_config) => (media.mojom.ReadOnlyAudioDataPipe? data_pipe, bool initially_muted, mojo_base.mojom.UnguessableToken? stream_id); // Associates an output device with an input stream, so that the input knows // which output device to cancel echo from. |input_stream_id| is the id // returned when the stream was created. |output_device_id| is a raw device // id. In case either of the parameters are invalid, the operation will // silently fail. AssociateInputAndOutputForAec( mojo_base.mojom.UnguessableToken input_stream_id, string output_device_id); // Creates an AudioOutputStream and returns the AudioDataPipe it reads data // from. |data_pipe| is null in case stream creation failed. |device_id| is // either the |unique_id| field from an AudioDeviceDescription obtained from // the audio.mojom.SystemInfo interface, or "default". The stream |group_id| // is used for muting streams or capturing them for loopback. CreateOutputStream( pending_receiver stream, pending_associated_remote? observer, pending_remote? log, string device_id, media.mojom.AudioParameters params, mojo_base.mojom.UnguessableToken group_id) => (media.mojom.ReadWriteAudioDataPipe? data_pipe); // Binds the request to the LocalMuter associated with the given |group_id|. // While one or more bindings to a group's LocalMuter exists, all local audio // playout for the streams in that group is muted. // // It is the responsibility of the client to bind to a muter before creating // any output streams that should be started muted. Likewise, if existing // output streams must remain muted until they are shut down, the binding to // the muter must not be closed until after all other streams' binding. (This // is the reason for the associated request argument.) BindMuter(pending_associated_receiver receiver, mojo_base.mojom.UnguessableToken group_id); // Creates an AudioInputStream that provides the result of looping-back and // mixing-together all current and future AudioOutputStreams tagged with the // given |group_id|. The loopback re-mixes audio, if necessary, so that the // resulting data stream format matches the specified |params|. All other args // and the result are as described in CreateInputStream() above, except for // |stream_id|. Loopback streams have no ID, since they cannot be used in // echo cancellation. CreateLoopbackStream( pending_receiver receiver, pending_remote client, pending_remote observer, media.mojom.AudioParameters params, uint32 shared_memory_count, mojo_base.mojom.UnguessableToken group_id) => (media.mojom.ReadOnlyAudioDataPipe? data_pipe); };