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

Side by Side Diff: media/midi/midi_manager_usb.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/media.gyp ('k') | media/midi/midi_manager_usb.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_MIDI_MIDI_MANAGER_USB_H_
6 #define MEDIA_MIDI_MIDI_MANAGER_USB_H_
7
8 #include <utility>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/bind.h"
13 #include "base/callback.h"
14 #include "base/containers/hash_tables.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "media/base/media_export.h"
17 #include "media/midi/midi_manager.h"
18 #include "media/midi/usb_midi_device.h"
19 #include "media/midi/usb_midi_input_stream.h"
20 #include "media/midi/usb_midi_jack.h"
21 #include "media/midi/usb_midi_output_stream.h"
22
23 namespace media {
24
25 // MIDIManager for USB-MIDI.
26 class MEDIA_EXPORT MidiManagerUsb : public MIDIManager,
27 public UsbMidiDeviceDelegate,
28 public UsbMidiInputStream::Delegate {
29 public:
30 explicit MidiManagerUsb(scoped_ptr<UsbMidiDevice::Factory> device_factory);
31 virtual ~MidiManagerUsb();
32
33 // MIDIManager implementation.
34 virtual bool Initialize() OVERRIDE;
35 virtual void DispatchSendMIDIData(MIDIManagerClient* client,
36 uint32 port_index,
37 const std::vector<uint8>& data,
38 double timestamp) OVERRIDE;
39
40 // UsbMidiDeviceDelegate implementation.
41 virtual void ReceiveUsbMidiData(UsbMidiDevice* device,
42 int endpoint_number,
43 const uint8* data,
44 size_t size,
45 double timestamp) OVERRIDE;
46
47 // UsbMidiInputStream::Delegate implementation.
48 virtual void OnReceivedData(size_t jack_index,
49 const uint8* data,
50 size_t size,
51 double timestamp) OVERRIDE;
52
53 const ScopedVector<UsbMidiOutputStream>& output_streams() const {
54 return output_streams_;
55 }
56 const UsbMidiInputStream* input_stream() const { return input_stream_.get(); }
57
58 // Initializes this object.
59 // When the initialization finishes, |callback| will be called with the
60 // result.
61 // When this factory is destroyed during the operation, the operation
62 // will be canceled silently (i.e. |callback| will not be called).
63 void Initialize(base::Callback<void(bool result)> callback);
64
65 private:
66 void OnEnumerateDevicesDone(bool result, UsbMidiDevice::Devices* devices);
67
68 scoped_ptr<UsbMidiDevice::Factory> device_factory_;
69 ScopedVector<UsbMidiDevice> devices_;
70 ScopedVector<UsbMidiOutputStream> output_streams_;
71 scoped_ptr<UsbMidiInputStream> input_stream_;
72
73 base::Callback<void(bool result)> initialize_callback_;
74
75 // A map from <endpoint_number, cable_number> to the index of input jacks.
76 base::hash_map<std::pair<int, int>, size_t> input_jack_dictionary_;
77
78 DISALLOW_COPY_AND_ASSIGN(MidiManagerUsb);
79 };
80
81 } // namespace media
82
83 #endif // MEDIA_MIDI_MIDI_MANAGER_USB_H_
OLDNEW
« no previous file with comments | « media/media.gyp ('k') | media/midi/midi_manager_usb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698