OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_MIDI_USB_MIDI_DEVICE_H_ | 5 #ifndef MEDIA_MIDI_USB_MIDI_DEVICE_H_ |
6 #define MEDIA_MIDI_USB_MIDI_DEVICE_H_ | 6 #define MEDIA_MIDI_USB_MIDI_DEVICE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/callback.h" | 10 #include "base/callback.h" |
12 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
13 #include "base/time/time.h" | 12 #include "base/time/time.h" |
14 #include "media/midi/usb_midi_export.h" | 13 #include "media/midi/usb_midi_export.h" |
15 | 14 |
16 namespace media { | 15 namespace media { |
17 namespace midi { | 16 namespace midi { |
18 | 17 |
19 class MidiManagerUsb; | 18 class MidiManagerUsb; |
20 class UsbMidiDevice; | 19 class UsbMidiDevice; |
21 | 20 |
22 // Delegate class for UsbMidiDevice. | 21 // Delegate class for UsbMidiDevice. |
23 // Each method is called when an corresponding event arrives at the device. | 22 // Each method is called when an corresponding event arrives at the device. |
24 class USB_MIDI_EXPORT UsbMidiDeviceDelegate { | 23 class USB_MIDI_EXPORT UsbMidiDeviceDelegate { |
25 public: | 24 public: |
26 virtual ~UsbMidiDeviceDelegate() {} | 25 virtual ~UsbMidiDeviceDelegate() {} |
27 | 26 |
28 // Called when USB-MIDI data arrives at |device|. | 27 // Called when USB-MIDI data arrives at |device|. |
29 virtual void ReceiveUsbMidiData(UsbMidiDevice* device, | 28 virtual void ReceiveUsbMidiData(UsbMidiDevice* device, |
30 int endpoint_number, | 29 int endpoint_number, |
31 const uint8* data, | 30 const uint8_t* data, |
32 size_t size, | 31 size_t size, |
33 base::TimeTicks time) = 0; | 32 base::TimeTicks time) = 0; |
34 | 33 |
35 // Called when a USB-MIDI device is attached. | 34 // Called when a USB-MIDI device is attached. |
36 virtual void OnDeviceAttached(scoped_ptr<UsbMidiDevice> device) = 0; | 35 virtual void OnDeviceAttached(scoped_ptr<UsbMidiDevice> device) = 0; |
37 // Called when a USB-MIDI device is detached. | 36 // Called when a USB-MIDI device is detached. |
38 virtual void OnDeviceDetached(size_t index) = 0; | 37 virtual void OnDeviceDetached(size_t index) = 0; |
39 }; | 38 }; |
40 | 39 |
41 // UsbMidiDevice represents a USB-MIDI device. | 40 // UsbMidiDevice represents a USB-MIDI device. |
(...skipping 19 matching lines...) Expand all Loading... |
61 // When this factory is destroyed during the operation, the operation | 60 // When this factory is destroyed during the operation, the operation |
62 // will be canceled silently (i.e. |callback| will not be called). | 61 // will be canceled silently (i.e. |callback| will not be called). |
63 // This function can be called at most once per instance. | 62 // This function can be called at most once per instance. |
64 virtual void EnumerateDevices(UsbMidiDeviceDelegate* delegate, | 63 virtual void EnumerateDevices(UsbMidiDeviceDelegate* delegate, |
65 Callback callback) = 0; | 64 Callback callback) = 0; |
66 }; | 65 }; |
67 | 66 |
68 virtual ~UsbMidiDevice() {} | 67 virtual ~UsbMidiDevice() {} |
69 | 68 |
70 // Returns the descriptors of this device. | 69 // Returns the descriptors of this device. |
71 virtual std::vector<uint8> GetDescriptors() = 0; | 70 virtual std::vector<uint8_t> GetDescriptors() = 0; |
72 | 71 |
73 // Return the name of the manufacturer. | 72 // Return the name of the manufacturer. |
74 virtual std::string GetManufacturer() = 0; | 73 virtual std::string GetManufacturer() = 0; |
75 | 74 |
76 // Retur the name of the device. | 75 // Retur the name of the device. |
77 virtual std::string GetProductName() = 0; | 76 virtual std::string GetProductName() = 0; |
78 | 77 |
79 // Return the device version. | 78 // Return the device version. |
80 virtual std::string GetDeviceVersion() = 0; | 79 virtual std::string GetDeviceVersion() = 0; |
81 | 80 |
82 // Sends |data| to the given USB endpoint of this device. | 81 // Sends |data| to the given USB endpoint of this device. |
83 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0; | 82 virtual void Send(int endpoint_number, const std::vector<uint8_t>& data) = 0; |
84 }; | 83 }; |
85 | 84 |
86 } // namespace midi | 85 } // namespace midi |
87 } // namespace media | 86 } // namespace media |
88 | 87 |
89 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_ | 88 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_ |
OLD | NEW |