OLD | NEW |
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_OUTPUT_STREAM_H_ | 5 #ifndef MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |
6 #define MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ | 6 #define MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <vector> | 10 #include <vector> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "media/midi/usb_midi_export.h" | 13 #include "media/midi/usb_midi_export.h" |
12 #include "media/midi/usb_midi_jack.h" | 14 #include "media/midi/usb_midi_jack.h" |
13 | 15 |
14 namespace media { | 16 namespace media { |
15 namespace midi { | 17 namespace midi { |
16 | 18 |
17 // UsbMidiOutputStream converts MIDI data to USB-MIDI data. | 19 // UsbMidiOutputStream converts MIDI data to USB-MIDI data. |
18 // See "USB Device Class Definition for MIDI Devices" Release 1.0, | 20 // See "USB Device Class Definition for MIDI Devices" Release 1.0, |
19 // Section 4 "USB-MIDI Event Packets" for details. | 21 // Section 4 "USB-MIDI Event Packets" for details. |
20 class USB_MIDI_EXPORT UsbMidiOutputStream { | 22 class USB_MIDI_EXPORT UsbMidiOutputStream { |
21 public: | 23 public: |
22 explicit UsbMidiOutputStream(const UsbMidiJack& jack); | 24 explicit UsbMidiOutputStream(const UsbMidiJack& jack); |
23 | 25 |
24 // Converts |data| to USB-MIDI data and send it to the jack. | 26 // Converts |data| to USB-MIDI data and send it to the jack. |
25 void Send(const std::vector<uint8>& data); | 27 void Send(const std::vector<uint8_t>& data); |
26 | 28 |
27 const UsbMidiJack& jack() const { return jack_; } | 29 const UsbMidiJack& jack() const { return jack_; } |
28 | 30 |
29 private: | 31 private: |
30 size_t GetSize(const std::vector<uint8>& data) const; | 32 size_t GetSize(const std::vector<uint8_t>& data) const; |
31 uint8_t Get(const std::vector<uint8>& data, size_t index) const; | 33 uint8_t Get(const std::vector<uint8_t>& data, size_t index) const; |
32 | 34 |
33 bool PushSysExMessage(const std::vector<uint8>& data, | 35 bool PushSysExMessage(const std::vector<uint8_t>& data, |
34 size_t* current, | 36 size_t* current, |
35 std::vector<uint8>* data_to_send); | 37 std::vector<uint8_t>* data_to_send); |
36 bool PushSysCommonMessage(const std::vector<uint8>& data, | 38 bool PushSysCommonMessage(const std::vector<uint8_t>& data, |
37 size_t* current, | 39 size_t* current, |
38 std::vector<uint8>* data_to_send); | 40 std::vector<uint8_t>* data_to_send); |
39 void PushSysRTMessage(const std::vector<uint8>& data, | 41 void PushSysRTMessage(const std::vector<uint8_t>& data, |
40 size_t* current, | 42 size_t* current, |
41 std::vector<uint8>* data_to_send); | 43 std::vector<uint8_t>* data_to_send); |
42 bool PushChannelMessage(const std::vector<uint8>& data, | 44 bool PushChannelMessage(const std::vector<uint8_t>& data, |
43 size_t* current, | 45 size_t* current, |
44 std::vector<uint8>* data_to_send); | 46 std::vector<uint8_t>* data_to_send); |
45 | 47 |
46 static const size_t kPacketContentSize = 3; | 48 static const size_t kPacketContentSize = 3; |
47 | 49 |
48 UsbMidiJack jack_; | 50 UsbMidiJack jack_; |
49 size_t pending_size_; | 51 size_t pending_size_; |
50 uint8 pending_data_[kPacketContentSize]; | 52 uint8_t pending_data_[kPacketContentSize]; |
51 bool is_sending_sysex_; | 53 bool is_sending_sysex_; |
52 | 54 |
53 DISALLOW_COPY_AND_ASSIGN(UsbMidiOutputStream); | 55 DISALLOW_COPY_AND_ASSIGN(UsbMidiOutputStream); |
54 }; | 56 }; |
55 | 57 |
56 } // namespace midi | 58 } // namespace midi |
57 } // namespace media | 59 } // namespace media |
58 | 60 |
59 #endif // MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ | 61 #endif // MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |
OLD | NEW |