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

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: Created 6 years, 10 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
« no previous file with comments | « media/midi/usb_midi_descriptor_parser_unittest.cc ('k') | media/midi/usb_midi_input_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_vector.h"
11 #include "media/base/media_export.h" 13 #include "media/base/media_export.h"
12 14
13 namespace media { 15 namespace media {
14 16
17 class UsbMidiDevice;
18
19 // Delegate class for UsbMidiDevice.
20 // Each method is called when an corresponding event arrives at the device.
21 class MEDIA_EXPORT UsbMidiDeviceDelegate {
22 public:
23 virtual ~UsbMidiDeviceDelegate() {}
24
25 // Called when USB-MIDI data arrives at |device|.
26 virtual void ReceiveUsbMidiData(UsbMidiDevice* device,
27 int endpoint_number,
28 const uint8* data,
29 size_t size,
30 double timestamp) = 0;
31 };
32
15 // UsbMidiDevice represents a USB-MIDI device. 33 // UsbMidiDevice represents a USB-MIDI device.
16 // This is an interface class and each platform-dependent implementation class 34 // This is an interface class and each platform-dependent implementation class
17 // will be a derived class. 35 // will be a derived class.
18 class MEDIA_EXPORT UsbMidiDevice { 36 class MEDIA_EXPORT UsbMidiDevice {
19 public: 37 public:
38 typedef ScopedVector<UsbMidiDevice> Devices;
39
40 // Factory class for USB-MIDI devices.
41 // Each concrete implementation will find and create devices
42 // in platform-dependent way.
43 class Factory {
44 public:
45 typedef base::Callback<void(bool result, Devices* devices)> Callback;
46 virtual ~Factory() {}
47 // Enumerates devices.
48 // Devices that have no USB-MIDI interfaces can be omitted.
49 // When the operation succeeds, |callback| will be called with |true| and
50 // devices.
51 // Otherwise |callback| will be called with |false| and empty devices.
52 // When this factory is destroyed during the operation, the operation
53 // will be canceled silently (i.e. |callback| will not be called).
54 virtual void EnumerateDevices(UsbMidiDeviceDelegate* delegate,
55 Callback callback) = 0;
56 };
57
20 virtual ~UsbMidiDevice() {} 58 virtual ~UsbMidiDevice() {}
21 59
22 // Returns the descriptor of this device. 60 // Returns the descriptor of this device.
23 virtual std::vector<uint8> GetDescriptor() = 0; 61 virtual std::vector<uint8> GetDescriptor() = 0;
24 62
25 // Sends |data| to the given USB endpoint of this device. 63 // Sends |data| to the given USB endpoint of this device.
26 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0; 64 virtual void Send(int endpoint_number, const std::vector<uint8>& data) = 0;
27 }; 65 };
28 66
29 } // namespace media 67 } // namespace media
30 68
31 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_ 69 #endif // MEDIA_MIDI_USB_MIDI_DEVICE_H_
OLDNEW
« no previous file with comments | « media/midi/usb_midi_descriptor_parser_unittest.cc ('k') | media/midi/usb_midi_input_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698