| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/memory/scoped_vector.h" |
| 15 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 16 #include "media/midi/usb_midi_export.h" | 17 #include "media/midi/usb_midi_export.h" |
| 17 | 18 |
| 18 namespace midi { | 19 namespace midi { |
| 19 | 20 |
| 20 class UsbMidiDevice; | 21 class UsbMidiDevice; |
| 21 | 22 |
| 22 // Delegate class for UsbMidiDevice. | 23 // Delegate class for UsbMidiDevice. |
| 23 // Each method is called when an corresponding event arrives at the device. | 24 // Each method is called when an corresponding event arrives at the device. |
| 24 class USB_MIDI_EXPORT UsbMidiDeviceDelegate { | 25 class USB_MIDI_EXPORT UsbMidiDeviceDelegate { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 36 virtual void OnDeviceAttached(std::unique_ptr<UsbMidiDevice> device) = 0; | 37 virtual void OnDeviceAttached(std::unique_ptr<UsbMidiDevice> device) = 0; |
| 37 // Called when a USB-MIDI device is detached. | 38 // Called when a USB-MIDI device is detached. |
| 38 virtual void OnDeviceDetached(size_t index) = 0; | 39 virtual void OnDeviceDetached(size_t index) = 0; |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 // UsbMidiDevice represents a USB-MIDI device. | 42 // UsbMidiDevice represents a USB-MIDI device. |
| 42 // This is an interface class and each platform-dependent implementation class | 43 // This is an interface class and each platform-dependent implementation class |
| 43 // will be a derived class. | 44 // will be a derived class. |
| 44 class USB_MIDI_EXPORT UsbMidiDevice { | 45 class USB_MIDI_EXPORT UsbMidiDevice { |
| 45 public: | 46 public: |
| 46 typedef std::vector<std::unique_ptr<UsbMidiDevice>> Devices; | 47 typedef ScopedVector<UsbMidiDevice> Devices; |
| 47 | 48 |
| 48 // Factory class for USB-MIDI devices. | 49 // Factory class for USB-MIDI devices. |
| 49 // Each concrete implementation will find and create devices | 50 // Each concrete implementation will find and create devices |
| 50 // in platform-dependent way. | 51 // in platform-dependent way. |
| 51 class Factory { | 52 class Factory { |
| 52 public: | 53 public: |
| 53 typedef base::Callback<void(bool result, Devices* devices)> Callback; | 54 typedef base::Callback<void(bool result, Devices* devices)> Callback; |
| 54 virtual ~Factory() {} | 55 virtual ~Factory() {} |
| 55 | 56 |
| 56 // Enumerates devices. | 57 // Enumerates devices. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 79 // Return the device version. | 80 // Return the device version. |
| 80 virtual std::string GetDeviceVersion() = 0; | 81 virtual std::string GetDeviceVersion() = 0; |
| 81 | 82 |
| 82 // Sends |data| to the given USB endpoint of this device. | 83 // Sends |data| to the given USB endpoint of this device. |
| 83 virtual void Send(int endpoint_number, const std::vector<uint8_t>& data) = 0; | 84 virtual void Send(int endpoint_number, const std::vector<uint8_t>& data) = 0; |
| 84 }; | 85 }; |
| 85 | 86 |
| 86 } // namespace midi | 87 } // namespace midi |
| 87 | 88 |
| 88 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_ | 89 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_ |
| OLD | NEW |