blob: ab49b735a0a5a532dbe9b26dafd506c77fc88ff7 [file] [log] [blame]
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module midi.mojom;
import "mojo/public/mojom/base/time.mojom";
enum Result {
NOT_INITIALIZED,
OK,
NOT_SUPPORTED,
INITIALIZATION_ERROR,
};
enum PortState {
DISCONNECTED,
CONNECTED,
OPENED,
};
struct PortInfo {
string id;
string manufacturer;
string name;
string version;
PortState state;
};
// Interface for MIDI related browser to renderer messages.
interface MidiSessionClient {
// These functions are called in 2 cases:
// (1) Just before calling |SessionStarted|, to notify the recipient about
// existing ports.
// (2) To notify the recipient that a new device was connected and that new
// ports have been created.
AddInputPort(PortInfo info);
AddOutputPort(PortInfo info);
// Used to notify clients when a device is disconnected or reconnected. The
// ports correspond to ports already sent to the client using AddInputPort/
// AddOutputPort.
SetInputPortState(uint32 port, PortState state);
SetOutputPortState(uint32 port, PortState state);
// Called in response to StartSession and indicates if a connection with
// MIDI hardware was successfully made.
SessionStarted(Result result);
// Used to inform the client incrementally of how many bytes have been
// successfully sent. This is only called after the client calls SendData().
AcknowledgeSentData(uint32 bytes);
// Called to send MIDI data to the client.
DataReceived(uint32 port,
array<uint8> data,
mojo_base.mojom.TimeTicks timestamp);
};
// Interface used by the renderer to start a MIDI session in the browser.
interface MidiSessionProvider {
// Start session to access MIDI hardware.
StartSession(MidiSession& request, MidiSessionClient client);
};
// Represents an active MIDI session.
interface MidiSession {
// Send data to a MIDI output port. The output port should be a port already
// sent to the client (via AddOutputPort).
SendData(uint32 port, array<uint8> data, mojo_base.mojom.TimeTicks timestamp);
};