1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72

media / midi / midi_service.mojom [blame]

// Copyright 2016 The Chromium Authors
// 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(pending_receiver<MidiSession> receiver,
               pending_remote<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);
};