blob: 420f44aa4afc8210bbc15b896bd2f346ee4c5aa2 [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,
// New code should be inserted here so that existing members keep the same
// assigned value. //tools/metrics/histograms/histograms.xml contains a enum
// entry that should be consistent with enum Result.
// |MAX| is used in content/common/media/midi_messages.h with
// IPC_ENUM_TRAITS_MAX_VALUE macro. Keep the value up to date. Otherwise
// a new value can not be passed to the renderer.
// TODO(toyoshim): Remove |MAX| once IPC is replaced with Mojo.
// http://crbug.com/582327
MAX = INITIALIZATION_ERROR,
};
enum PortState {
DISCONNECTED,
CONNECTED,
OPENED,
// TODO(toyosim): Remove |LAST| once IPC is replaced with Mojo.
// http://crbug.com/582327
LAST = 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);
};