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.
5 #ifndef MEDIA_MIDI_USB_MIDI_DEVICE_H_
6 #define MEDIA_MIDI_USB_MIDI_DEVICE_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_vector.h"
13 #include "media/base/media_export.h"
19 // Delegate class for UsbMidiDevice.
20 // Each method is called when an corresponding event arrives at the device.
21 class MEDIA_EXPORT UsbMidiDeviceDelegate {
23 virtual ~UsbMidiDeviceDelegate() {}
25 // Called when USB-MIDI data arrives at |device|.
26 virtual void ReceiveUsbMidiData(UsbMidiDevice* device,
30 double timestamp) = 0;
33 // UsbMidiDevice represents a USB-MIDI device.
34 // This is an interface class and each platform-dependent implementation class
35 // will be a derived class.
36 class MEDIA_EXPORT UsbMidiDevice {
38 typedef ScopedVector<UsbMidiDevice> Devices;
40 // Factory class for USB-MIDI devices.
41 // Each concrete implementation will find and create devices
42 // in platform-dependent way.
45 typedef base::Callback<void(bool result, Devices* devices)> Callback;
47 // Enumerates devices.
48 // Devices that have no USB-MIDI interfaces can be omitted.
49 // When the operation succeeds, |callback| will be called with |true| and
51 // Otherwise |callback| will be called with |false| and empty devices.
52 // When this factory is destroyed during the operation, the operation
53 // will be canceled silently (i.e. |callback| will not be called).
54 // This function can be called at most once per instance.
55 virtual void EnumerateDevices(UsbMidiDeviceDelegate* delegate,
56 Callback callback) = 0;
59 virtual ~UsbMidiDevice() {}
61 // Returns the descriptor of this device.
62 virtual std::vector<uint8> GetDescriptor() = 0;
64 // Sends |data| to the given USB endpoint of this device.
65 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0;
70 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_