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