toyoshim | 2f3a48f | 2016-10-17 01:54:13 -0700 | [diff] [blame] | 1 | // Copyright 2016 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 | module midi.mojom; |
| 6 | |
Adithya Srinivasan | 052cbb4 | 2018-11-28 17:17:34 +0000 | [diff] [blame] | 7 | import "mojo/public/mojom/base/time.mojom"; |
| 8 | |
toyoshim | 2f3a48f | 2016-10-17 01:54:13 -0700 | [diff] [blame] | 9 | enum Result { |
| 10 | NOT_INITIALIZED, |
| 11 | OK, |
| 12 | NOT_SUPPORTED, |
| 13 | INITIALIZATION_ERROR, |
toyoshim | 2f3a48f | 2016-10-17 01:54:13 -0700 | [diff] [blame] | 14 | }; |
| 15 | |
toyoshim | ec2570a | 2016-10-21 02:15:27 -0700 | [diff] [blame] | 16 | enum PortState { |
| 17 | DISCONNECTED, |
| 18 | CONNECTED, |
| 19 | OPENED, |
toyoshim | ec2570a | 2016-10-21 02:15:27 -0700 | [diff] [blame] | 20 | }; |
| 21 | |
Adithya Srinivasan | 3325273 | 2018-10-17 15:59:40 +0000 | [diff] [blame] | 22 | struct PortInfo { |
| 23 | string id; |
| 24 | string manufacturer; |
| 25 | string name; |
| 26 | string version; |
| 27 | PortState state; |
| 28 | }; |
| 29 | |
Adithya Srinivasan | 052cbb4 | 2018-11-28 17:17:34 +0000 | [diff] [blame] | 30 | // Interface for MIDI related browser to renderer messages. |
| 31 | interface MidiSessionClient { |
| 32 | // These functions are called in 2 cases: |
| 33 | // (1) Just before calling |SessionStarted|, to notify the recipient about |
| 34 | // existing ports. |
| 35 | // (2) To notify the recipient that a new device was connected and that new |
| 36 | // ports have been created. |
| 37 | AddInputPort(PortInfo info); |
| 38 | AddOutputPort(PortInfo info); |
| 39 | |
| 40 | // Used to notify clients when a device is disconnected or reconnected. The |
| 41 | // ports correspond to ports already sent to the client using AddInputPort/ |
| 42 | // AddOutputPort. |
| 43 | SetInputPortState(uint32 port, PortState state); |
| 44 | SetOutputPortState(uint32 port, PortState state); |
| 45 | |
| 46 | // Called in response to StartSession and indicates if a connection with |
| 47 | // MIDI hardware was successfully made. |
| 48 | SessionStarted(Result result); |
| 49 | |
| 50 | // Used to inform the client incrementally of how many bytes have been |
| 51 | // successfully sent. This is only called after the client calls SendData(). |
| 52 | AcknowledgeSentData(uint32 bytes); |
| 53 | |
| 54 | // Called to send MIDI data to the client. |
| 55 | DataReceived(uint32 port, |
| 56 | array<uint8> data, |
| 57 | mojo_base.mojom.TimeTicks timestamp); |
| 58 | }; |
| 59 | |
| 60 | // Interface used by the renderer to start a MIDI session in the browser. |
| 61 | interface MidiSessionProvider { |
| 62 | // Start session to access MIDI hardware. |
Gyuyoung Kim | 5559bb7 | 2019-08-27 00:47:10 +0000 | [diff] [blame] | 63 | StartSession(pending_receiver<MidiSession> receiver, |
| 64 | pending_remote<MidiSessionClient> client); |
Adithya Srinivasan | 052cbb4 | 2018-11-28 17:17:34 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | // Represents an active MIDI session. |
| 68 | interface MidiSession { |
| 69 | // Send data to a MIDI output port. The output port should be a port already |
| 70 | // sent to the client (via AddOutputPort). |
| 71 | SendData(uint32 port, array<uint8> data, mojo_base.mojom.TimeTicks timestamp); |
| 72 | }; |