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 class MEDIA_EXPORT UsbMidiOutputStream { |
| 18 public: |
| 19 explicit UsbMidiOutputStream(const UsbMidiJack& jack) |
| 20 : jack_(jack), pending_size_(0), is_sending_sysex_(false) {} |
| 21 |
| 22 const UsbMidiJack& jack() const { return jack_; } |
| 23 void Send(const std::vector<uint8>& data); |
| 24 |
| 25 private: |
| 26 size_t GetSize(const std::vector<uint8>& data) const; |
| 27 uint8_t Get(const std::vector<uint8>& data, size_t index) const; |
| 28 |
| 29 bool PushSysExMessage(const std::vector<uint8>& data, |
| 30 size_t* current, |
| 31 std::vector<uint8>* data_to_send); |
| 32 bool PushSysCommonMessage(const std::vector<uint8>& data, |
| 33 size_t* current, |
| 34 std::vector<uint8>* data_to_send); |
| 35 bool PushSysRTMessage(const std::vector<uint8>& data, |
| 36 size_t* current, |
| 37 std::vector<uint8>* data_to_send); |
| 38 bool PushChannelMessage(const std::vector<uint8>& data, |
| 39 size_t* current, |
| 40 std::vector<uint8>* data_to_send); |
| 41 |
| 42 static const size_t kPacketContentSize = 3; |
| 43 |
| 44 UsbMidiJack jack_; |
| 45 size_t pending_size_; |
| 46 uint8 pending_data_[kPacketContentSize]; |
| 47 bool is_sending_sysex_; |
| 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(UsbMidiOutputStream); |
| 50 }; |
| 51 |
| 52 } // namespace media |
| 53 |
| 54 #endif // MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |
OLD | NEW |