OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MIDI_MESSAGE_QUEUE_H_ | 5 #ifndef MEDIA_MIDI_MIDI_MESSAGE_QUEUE_H_ |
6 #define MEDIA_MIDI_MIDI_MESSAGE_QUEUE_H_ | 6 #define MEDIA_MIDI_MIDI_MESSAGE_QUEUE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "media/midi/midi_export.h" | 12 #include "media/midi/midi_export.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
| 15 namespace midi { |
15 | 16 |
16 // A simple message splitter for possibly unsafe/corrupted MIDI data stream. | 17 // A simple message splitter for possibly unsafe/corrupted MIDI data stream. |
17 // This class allows you to: | 18 // This class allows you to: |
18 // - maintain fragmented MIDI message. | 19 // - maintain fragmented MIDI message. |
19 // - skip any invalid data sequence. | 20 // - skip any invalid data sequence. |
20 // - reorder MIDI messages so that "System Real Time Message", which can be | 21 // - reorder MIDI messages so that "System Real Time Message", which can be |
21 // inserted at any point of the byte stream, is placed at the boundary of | 22 // inserted at any point of the byte stream, is placed at the boundary of |
22 // complete MIDI messages. | 23 // complete MIDI messages. |
23 // - (Optional) reconstruct complete MIDI messages from data stream where | 24 // - (Optional) reconstruct complete MIDI messages from data stream where |
24 // MIDI status byte is abbreviated (a.k.a. "running status"). | 25 // MIDI status byte is abbreviated (a.k.a. "running status"). |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // |message| is empty if there is no complete MIDI message any more. | 61 // |message| is empty if there is no complete MIDI message any more. |
61 void Get(std::vector<uint8>* message); | 62 void Get(std::vector<uint8>* message); |
62 | 63 |
63 private: | 64 private: |
64 std::deque<uint8> queue_; | 65 std::deque<uint8> queue_; |
65 std::vector<uint8> next_message_; | 66 std::vector<uint8> next_message_; |
66 const bool allow_running_status_; | 67 const bool allow_running_status_; |
67 DISALLOW_COPY_AND_ASSIGN(MidiMessageQueue); | 68 DISALLOW_COPY_AND_ASSIGN(MidiMessageQueue); |
68 }; | 69 }; |
69 | 70 |
| 71 } // namespace midi |
70 } // namespace media | 72 } // namespace media |
71 | 73 |
72 #endif // MEDIA_MIDI_MIDI_MESSAGE_QUEUE_H_ | 74 #endif // MEDIA_MIDI_MIDI_MESSAGE_QUEUE_H_ |
OLD | NEW |