midi_service.mojom 2.2 KB

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