Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / media / midi / usb_midi_device.h
blob6af92b6ef6be702dcfd21798018dfbfaabfedc4f
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_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_vector.h"
13 #include "base/time/time.h"
14 #include "media/base/media_export.h"
16 namespace media {
18 class UsbMidiDevice;
20 // Delegate class for UsbMidiDevice.
21 // Each method is called when an corresponding event arrives at the device.
22 class MEDIA_EXPORT UsbMidiDeviceDelegate {
23 public:
24 virtual ~UsbMidiDeviceDelegate() {}
26 // Called when USB-MIDI data arrives at |device|.
27 virtual void ReceiveUsbMidiData(UsbMidiDevice* device,
28 int endpoint_number,
29 const uint8* data,
30 size_t size,
31 base::TimeTicks time) = 0;
34 // UsbMidiDevice represents a USB-MIDI device.
35 // This is an interface class and each platform-dependent implementation class
36 // will be a derived class.
37 class MEDIA_EXPORT UsbMidiDevice {
38 public:
39 typedef ScopedVector<UsbMidiDevice> Devices;
41 // Factory class for USB-MIDI devices.
42 // Each concrete implementation will find and create devices
43 // in platform-dependent way.
44 class Factory {
45 public:
46 typedef base::Callback<void(bool result, Devices* devices)> Callback;
47 virtual ~Factory() {}
48 // Enumerates devices.
49 // Devices that have no USB-MIDI interfaces can be omitted.
50 // When the operation succeeds, |callback| will be called with |true| and
51 // devices.
52 // Otherwise |callback| will be called with |false| and empty devices.
53 // When this factory is destroyed during the operation, the operation
54 // will be canceled silently (i.e. |callback| will not be called).
55 // This function can be called at most once per instance.
56 virtual void EnumerateDevices(UsbMidiDeviceDelegate* delegate,
57 Callback callback) = 0;
60 virtual ~UsbMidiDevice() {}
62 // Returns the descriptor of this device.
63 virtual std::vector<uint8> GetDescriptor() = 0;
65 // Sends |data| to the given USB endpoint of this device.
66 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0;
69 } // namespace media
71 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_