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

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, 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
(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/midi/midi_manager.h"
17 #include "media/midi/usb_midi_device.h"
18 #include "media/midi/usb_midi_input_stream.h"
19 #include "media/midi/usb_midi_jack.h"
20 #include "media/midi/usb_midi_output_stream.h"
21
22 namespace media {
23
24 // MIDIManager for USB-MIDI.
25 class MIDIManagerUsb : public MIDIManager,
scherkus (not reviewing) 2014/01/27 19:23:49 nit: I'd like to see you folks agree on a naming c
yhirano 2014/01/28 04:31:05 Discussed with toyoshim@. We are going to change M
26 public UsbMidiDeviceDelegate,
27 public UsbMidiInputStream::Delegate {
28 public:
29 explicit MIDIManagerUsb(scoped_ptr<UsbMidiDevice::Factory> device_factory);
30 virtual ~MIDIManagerUsb();
31
32 // MIDIManager implementation.
33 virtual bool Initialize() OVERRIDE;
34 virtual void DispatchSendMIDIData(MIDIManagerClient* client,
35 uint32 port_index,
36 const std::vector<uint8>& data,
37 double timestamp) OVERRIDE;
38
39 // UsbMidiDeviceDelegate implementation.
40 virtual void ReceiveUsbMidiData(UsbMidiDevice* device,
41 int endpoint_number,
42 const uint8* data,
43 size_t size,
44 double timestamp) OVERRIDE;
45
46 // UsbMidiInputStream::Delegate implementation.
47 virtual void OnReceivedData(size_t jack_index,
48 const uint8* data,
49 size_t size,
50 double timestamp) OVERRIDE;
51
52 const ScopedVector<UsbMidiOutputStream>& output_streams() const {
53 return output_streams_;
54 }
55 const UsbMidiInputStream* input_stream() const { return input_stream_.get(); }
56
57 // Initializes this object.
58 // When the initialization finishes, |callback| will be called with the
59 // result.
60 // When this factory is destroyed during the operation, the operation
61 // will be canceled silently (i.e. |callback| will not be called).
62 void Initialize(base::Callback<void(bool result)> callback);
63
64 private:
65 static void OnRequestPermissionDone(bool result);
scherkus (not reviewing) 2014/01/27 19:23:49 I can't find this function -- remove?
yhirano 2014/01/28 04:31:05 Done.
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') | media/midi/midi_manager_usb.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698