Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Side by Side Diff: media/midi/message_util.h

Issue 2431393002: Web MIDI: move MIDI message validating logic into message_util.{cc|h} (Closed)
Patch Set: build fix Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/midi/BUILD.gn ('k') | media/midi/message_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_MIDI_MESSAGE_UTIL_H_
6 #define MEDIA_MIDI_MESSAGE_UTIL_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <deque>
12 #include <vector>
13
14 #include "media/midi/midi_export.h"
15
16 namespace midi {
17
18 // Returns the length of a MIDI message in bytes. Never returns 4 or greater.
19 // Returns 0 if |status_byte| is:
20 // - not a valid status byte, namely data byte.
21 // - MIDI System Exclusive message.
22 // - End of System Exclusive message.
23 // - Reserved System Common Message (0xf4, 0xf5)
24 MIDI_EXPORT size_t GetMessageLength(uint8_t status_byte);
25
26 // Checks if the specified byte is a valid data byte.
27 MIDI_EXPORT bool IsDataByte(uint8_t data);
28
29 // Checks if the specified byte is a valid system real time message.
30 MIDI_EXPORT bool IsSystemRealTimeMessage(uint8_t data);
31
32 // Checks if the specified byte is a valid system message.
33 MIDI_EXPORT bool IsSystemMessage(uint8_t data);
34
35 // Checks if |data| fulfills the requirements of MidiOutput.send API that is
36 // defined in the Web MIDI spec.
37 // - |data| must be any number of complete MIDI messages (data abbreviation
38 // called "running status" is disallowed).
39 // - 1-byte MIDI realtime messages can be placed at any position of |data|.
40 MIDI_EXPORT bool IsValidWebMIDIData(const std::vector<uint8_t>& data);
41
42 const uint8_t kSysExByte = 0xf0;
43 const uint8_t kEndOfSysExByte = 0xf7;
44
45 const uint8_t kSysMessageBitMask = 0xf0;
46 const uint8_t kSysMessageBitPattern = 0xf0;
47 const uint8_t kSysRTMessageBitMask = 0xf8;
48 const uint8_t kSysRTMessageBitPattern = 0xf8;
49
50 } // namespace midi
51
52 #endif // MEDIA_MIDI_MESSAGE_UTIL_H_
OLDNEW
« no previous file with comments | « media/midi/BUILD.gn ('k') | media/midi/message_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698