Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: media/midi/usb_midi_device.h

Issue 107163008: [WebMIDI] Introduce MidiManagerUsb (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-midi-stream
Patch Set: rebase Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "media/base/media_export.h" 13 #include "media/base/media_export.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 class UsbMidiDevice;
18
17 class MEDIA_EXPORT UsbMidiDeviceDelegate { 19 class MEDIA_EXPORT UsbMidiDeviceDelegate {
18 public: 20 public:
19 virtual ~UsbMidiDeviceDelegate() {} 21 virtual ~UsbMidiDeviceDelegate() {}
20 virtual void ReceiveUsbMidiData(int endpoint_number, 22 virtual void ReceiveUsbMidiData(UsbMidiDevice* device,
23 int endpoint_number,
21 const uint8* data, 24 const uint8* data,
22 size_t size, 25 size_t size,
23 double timestamp) = 0; 26 double timestamp) = 0;
24 }; 27 };
25 28
26 class MEDIA_EXPORT UsbMidiDevice { 29 class MEDIA_EXPORT UsbMidiDevice {
27 public: 30 public:
28 typedef ScopedVector<UsbMidiDevice> Devices; 31 typedef ScopedVector<UsbMidiDevice> Devices;
29 class Factory { 32 class Factory {
30 public: 33 public:
31 typedef base::Callback<void(bool result, Devices* devices)> Callback; 34 typedef base::Callback<void(bool result, Devices* devices)> Callback;
32 virtual ~Factory() {} 35 virtual ~Factory() {}
33 // Enumerates devices. 36 // Enumerates devices.
34 // Devices that have no USB-MIDI interfaces can be omitted. 37 // Devices that have no USB-MIDI interfaces can be omitted.
35 // When the operation succeeds, |callback| will be called with |true| and 38 // When the operation succeeds, |callback| will be called with |true| and
36 // devices. 39 // devices.
37 // Otherwise |callback| will be called with |false| and empty devices. 40 // Otherwise |callback| will be called with |false| and empty devices.
38 // When this factory is destroyed during the operation, the operation 41 // When this factory is destroyed during the operation, the operation
39 // will be canceled silently (i.e. |callback| will not be called). 42 // will be canceled silently (i.e. |callback| will not be called).
40 virtual void EnumerateDevices(Callback callback) = 0; 43 virtual void EnumerateDevices(UsbMidiDeviceDelegate* delegate,
44 Callback callback) = 0;
41 }; 45 };
42 46
43 virtual ~UsbMidiDevice() {} 47 virtual ~UsbMidiDevice() {}
44 48
45 // Returns the descriptor of this device. 49 // Returns the descriptor of this device.
46 virtual std::vector<uint8> GetDescriptor() = 0; 50 virtual std::vector<uint8> GetDescriptor() = 0;
47 51
48 // Sends |data| to the given USB endpoint of this device. 52 // Sends |data| to the given USB endpoint of this device.
49 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0; 53 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0;
50 }; 54 };
51 55
52 } // namespace media 56 } // namespace media
53 57
54 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_ 58 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_
OLDNEW
« media/midi/midi_manager_usb_unittest.cc ('K') | « media/midi/midi_manager_usb_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698