usb_midi_jack.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2014 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. #ifndef MEDIA_MIDI_USB_MIDI_JACK_H_
  5. #define MEDIA_MIDI_USB_MIDI_JACK_H_
  6. #include <stdint.h>
  7. #include "media/midi/usb_midi_export.h"
  8. namespace midi {
  9. class UsbMidiDevice;
  10. // UsbMidiJack represents an EMBEDDED MIDI jack.
  11. struct USB_MIDI_EXPORT UsbMidiJack {
  12. // The direction of the endpoint associated with an EMBEDDED MIDI jack.
  13. // Note that an IN MIDI jack associated with an OUT endpoint has
  14. // ***DIRECTION_OUT*** direction.
  15. enum Direction {
  16. DIRECTION_IN,
  17. DIRECTION_OUT,
  18. };
  19. UsbMidiJack(UsbMidiDevice* device,
  20. uint8_t jack_id,
  21. uint8_t cable_number,
  22. uint8_t endpoint_address)
  23. : device(device),
  24. jack_id(jack_id),
  25. cable_number(cable_number),
  26. endpoint_address(endpoint_address) {}
  27. // Not owned
  28. UsbMidiDevice* device;
  29. // The id of this jack unique in the interface.
  30. uint8_t jack_id;
  31. // The cable number of this jack in the associated endpoint.
  32. uint8_t cable_number;
  33. // The address of the endpoint that this jack is associated with.
  34. uint8_t endpoint_address;
  35. Direction direction() const {
  36. return (endpoint_address & 0x80) ? DIRECTION_IN : DIRECTION_OUT;
  37. }
  38. uint8_t endpoint_number() const { return (endpoint_address & 0xf); }
  39. };
  40. } // namespace midi
  41. #endif // MEDIA_MIDI_USB_MIDI_JACK_H_