Chromium Code Reviews| Index: media/midi/usb_midi_output_stream.h |
| diff --git a/media/midi/usb_midi_output_stream.h b/media/midi/usb_midi_output_stream.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dac87479c7f122fbc942b5f8564aff4116d74d21 |
| --- /dev/null |
| +++ b/media/midi/usb_midi_output_stream.h |
| @@ -0,0 +1,56 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |
| +#define MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |
| + |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "media/base/media_export.h" |
| +#include "media/midi/usb_midi_jack.h" |
| + |
| +namespace media { |
| + |
| +// UsbMidiOutputStream converts MIDI data to USB-MIDI data. |
| +// See "USB Device Class Definition for MIDI Devices" Release 1.0, |
| +// Section 4 "USB-MIDI Event Packets" for details. |
| +class MEDIA_EXPORT UsbMidiOutputStream { |
| + public: |
| + explicit UsbMidiOutputStream(const UsbMidiJack& jack) |
| + : jack_(jack), pending_size_(0), is_sending_sysex_(false) {} |
|
scherkus (not reviewing)
2014/01/16 21:55:52
nit: I woudln't bother inlining the constructor
yhirano
2014/01/20 09:12:19
Done.
|
| + |
| + const UsbMidiJack& jack() const { return jack_; } |
|
scherkus (not reviewing)
2014/01/16 21:55:52
I don't see this called anywhere -- remove?
yhirano
2014/01/20 09:12:19
Done.
|
| + void Send(const std::vector<uint8>& data); |
|
scherkus (not reviewing)
2014/01/16 21:55:52
needs docs
yhirano
2014/01/20 09:12:19
Done.
|
| + |
| + private: |
| + size_t GetSize(const std::vector<uint8>& data) const; |
| + uint8_t Get(const std::vector<uint8>& data, size_t index) const; |
| + |
| + bool PushSysExMessage(const std::vector<uint8>& data, |
| + size_t* current, |
| + std::vector<uint8>* data_to_send); |
| + bool PushSysCommonMessage(const std::vector<uint8>& data, |
| + size_t* current, |
| + std::vector<uint8>* data_to_send); |
| + void PushSysRTMessage(const std::vector<uint8>& data, |
| + size_t* current, |
| + std::vector<uint8>* data_to_send); |
| + bool PushChannelMessage(const std::vector<uint8>& data, |
| + size_t* current, |
| + std::vector<uint8>* data_to_send); |
| + |
| + static const size_t kPacketContentSize = 3; |
| + |
| + UsbMidiJack jack_; |
| + size_t pending_size_; |
| + uint8 pending_data_[kPacketContentSize]; |
| + bool is_sending_sysex_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UsbMidiOutputStream); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_MIDI_USB_MIDI_OUTPUT_STREAM_H_ |