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