Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_USB_MIDI_INPUT_STREAM_H_ | |
| 6 #define MEDIA_MIDI_USB_MIDI_INPUT_STREAM_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/containers/hash_tables.h" | |
| 13 #include "media/base/media_export.h" | |
| 14 #include "media/midi/usb_midi_jack.h" | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 class UsbMidiDevice; | |
| 19 | |
| 20 // UsbMidiInputStream converts USB-MIDI data to MIDI data. | |
| 21 // See "USB Device Class Definition for MIDI Devices" Release 1.0, | |
| 22 // Section 4 "USB-MIDI Event Packets" for details. | |
| 23 class MEDIA_EXPORT UsbMidiInputStream { | |
| 24 public: | |
| 25 class Delegate { | |
| 26 public: | |
| 27 virtual ~Delegate() {} | |
| 28 // This function is called when some data arrives to a USB-MIDI jack. | |
| 29 // An input USB-MIDI jack corresponds to an input MIDIPortInfo. | |
| 30 virtual void OnReceivedData(size_t jack_index, | |
| 31 const uint8* data, | |
| 32 size_t size, | |
| 33 double timestamp) = 0; | |
| 34 }; | |
| 35 | |
| 36 UsbMidiInputStream(const std::vector<UsbMidiJack>& jacks, | |
| 37 Delegate* delegate); | |
| 38 ~UsbMidiInputStream(); | |
| 39 void OnReceivedData(UsbMidiDevice* device, | |
|
scherkus (not reviewing)
2014/01/16 21:55:52
nit: add blank line to separate functions and need
yhirano
2014/01/20 09:12:19
Done.
| |
| 40 int endpoint_number, | |
| 41 const uint8* data, | |
| 42 size_t size, | |
| 43 double timestamp); | |
| 44 const std::vector<UsbMidiJack>& jacks() const { return jacks_; } | |
|
scherkus (not reviewing)
2014/01/16 21:55:52
don't see this being called anywhere -- remove?
yhirano
2014/01/20 09:12:19
Done.
| |
| 45 | |
| 46 private: | |
| 47 static const size_t kPacketSize = 4; | |
| 48 struct JackUniqueKey { | |
| 49 JackUniqueKey(UsbMidiDevice* device, int endpoint_number, int cable_number); | |
| 50 bool operator==(const JackUniqueKey& that) const; | |
| 51 bool operator<(const JackUniqueKey& that) const; | |
| 52 | |
| 53 UsbMidiDevice* device; | |
| 54 int endpoint_number; | |
| 55 int cable_number; | |
| 56 }; | |
| 57 | |
| 58 // |size| must be a multiple of |kPacketSize|. | |
| 59 void OnReceivedData(size_t jack_index, | |
|
scherkus (not reviewing)
2014/01/16 21:55:52
I'm not seeing this function in the .cc -- remove?
yhirano
2014/01/20 09:12:19
Done.
| |
| 60 const uint8* data, | |
| 61 size_t size, | |
| 62 double timestamp); | |
| 63 | |
| 64 // Processes a USB-MIDI Event Packet. | |
| 65 // The first |kPacketSize| bytes of |packet| must be accessible. | |
| 66 void ProcessOnePacket(UsbMidiDevice* device, | |
| 67 int endpoint_number, | |
| 68 const uint8* packet, | |
| 69 double timestamp); | |
| 70 | |
| 71 const std::vector<UsbMidiJack> jacks_; | |
| 72 // A map from UsbMidiJack to its index in |jacks_|. | |
| 73 std::map<JackUniqueKey, size_t> jack_dictionary_; | |
| 74 | |
| 75 // Not owned | |
| 76 Delegate* delegate_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(UsbMidiInputStream); | |
| 79 }; | |
| 80 | |
| 81 } // namespace media | |
| 82 | |
| 83 #endif // MEDIA_MIDI_USB_MIDI_INPUT_STREAM_H_ | |
| OLD | NEW |