[M120 Migration][MM] Framerate calculation
[platform/framework/web/chromium-efl.git] / media / mojo / mojom / audio_stream_factory.mojom
1 // Copyright 2018 The Chromium Authors
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
7 import "media/mojo/mojom/audio_data_pipe.mojom";
8 import "media/mojo/mojom/audio_input_stream.mojom";
9 import "media/mojo/mojom/audio_logging.mojom";
10 import "media/mojo/mojom/audio_output_stream.mojom";
11 import "media/mojo/mojom/audio_parameters.mojom";
12 import "media/mojo/mojom/audio_processing.mojom";
13 import "mojo/public/mojom/base/shared_memory.mojom";
14 import "mojo/public/mojom/base/unguessable_token.mojom";
15
16 // Mutes a group of AudioOutputStreams while at least one binding to an instance
17 // exists. Once the last binding is dropped, all streams in the group are
18 // un-muted.
19 interface LocalMuter {};
20
21 // This interface is exposed by the audio service to allow trusted clients
22 // (like the browser process) to create streams. Note that while the factory
23 // interface itself is only for trusted clients, the created streams and data
24 // pipes may be forwarded to untrusted clients.
25 //
26 // The client must keep the connection to the factory while streams are
27 // running.
28 interface AudioStreamFactory {
29   // Creates an AudioInputStream and returns the AudioDataPipe it writes data to
30   // and a bool indicating whether the stream is initially muted. |data_pipe| is
31   // null, |initially_muted| is false and |stream_id| is empty in case stream
32   // creation failed.
33   // |device_id| is either the |unique_id| field from an AudioDeviceDescription
34   // obtained from the audio.mojom.SystemInfo interface, or "default".
35   // |shared_memory_count| indicates how many buffer segments can the input
36   // stream client read at once, to avoid data overwriting. |enable_agc| is used
37   // for enabling automatic gain control. |key_press_count_buffer| is an
38   // optional readonly shared memory handle for reading the current key press
39   // count, updated by browser process in media::UserInputMonitor
40   // implementation. When |processing_config| is passed, audio processing is
41   // requested (described by |processing_config|), and the audio service will
42   // apply it, on supported platforms (Win, Mac so far).
43   CreateInputStream(
44     pending_receiver<media.mojom.AudioInputStream> stream,
45     pending_remote<media.mojom.AudioInputStreamClient> client,
46     pending_remote<media.mojom.AudioInputStreamObserver>? observer,
47     pending_remote<media.mojom.AudioLog>? log,
48     string device_id, media.mojom.AudioParameters params,
49     uint32 shared_memory_count, bool enable_agc,
50     mojo_base.mojom.ReadOnlySharedMemoryRegion? key_press_count_buffer,
51     media.mojom.AudioProcessingConfig? processing_config)
52       => (media.mojom.ReadOnlyAudioDataPipe? data_pipe, bool initially_muted,
53           mojo_base.mojom.UnguessableToken? stream_id);
54
55   // Associates an output device with an input stream, so that the input knows
56   // which output device to cancel echo from. |input_stream_id| is the id
57   // returned when the stream was created. |output_device_id| is a raw device
58   // id. In case either of the parameters are invalid, the operation will
59   // silently fail.
60   AssociateInputAndOutputForAec(
61       mojo_base.mojom.UnguessableToken input_stream_id,
62       string output_device_id);
63
64   // Creates an AudioOutputStream and returns the AudioDataPipe it reads data
65   // from. |data_pipe| is null in case stream creation failed. |device_id| is
66   // either the |unique_id| field from an AudioDeviceDescription obtained from
67   // the audio.mojom.SystemInfo interface, or "default". The stream |group_id|
68   // is used for muting streams or capturing them for loopback.
69   CreateOutputStream(
70     pending_receiver<media.mojom.AudioOutputStream> stream,
71     pending_associated_remote<media.mojom.AudioOutputStreamObserver>? observer,
72     pending_remote<media.mojom.AudioLog>? log,
73     string device_id, media.mojom.AudioParameters params,
74     mojo_base.mojom.UnguessableToken group_id)
75     => (media.mojom.ReadWriteAudioDataPipe? data_pipe);
76
77   // Binds the request to the LocalMuter associated with the given |group_id|.
78   // While one or more bindings to a group's LocalMuter exists, all local audio
79   // playout for the streams in that group is muted.
80   //
81   // It is the responsibility of the client to bind to a muter before creating
82   // any output streams that should be started muted. Likewise, if existing
83   // output streams must remain muted until they are shut down, the binding to
84   // the muter must not be closed until after all other streams' binding. (This
85   // is the reason for the associated request argument.)
86   BindMuter(pending_associated_receiver<LocalMuter> receiver,
87             mojo_base.mojom.UnguessableToken group_id);
88
89   // Creates an AudioInputStream that provides the result of looping-back and
90   // mixing-together all current and future AudioOutputStreams tagged with the
91   // given |group_id|. The loopback re-mixes audio, if necessary, so that the
92   // resulting data stream format matches the specified |params|. All other args
93   // and the result are as described in CreateInputStream() above, except for
94   // |stream_id|. Loopback streams have no ID, since they cannot be used in
95   // echo cancellation.
96   CreateLoopbackStream(
97       pending_receiver<media.mojom.AudioInputStream> receiver,
98       pending_remote<media.mojom.AudioInputStreamClient> client,
99       pending_remote<media.mojom.AudioInputStreamObserver> observer,
100       media.mojom.AudioParameters params,
101       uint32 shared_memory_count,
102       mojo_base.mojom.UnguessableToken group_id)
103     => (media.mojom.ReadOnlyAudioDataPipe? data_pipe);
104 };