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

Unified Diff: media/midi/usb_midi_descriptor_parser.h

Issue 105043008: Introduce USB MIDI descriptor parser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: media/midi/usb_midi_descriptor_parser.h
diff --git a/media/midi/usb_midi_descriptor_parser.h b/media/midi/usb_midi_descriptor_parser.h
new file mode 100644
index 0000000000000000000000000000000000000000..e45887a5b47fbf6a654a7c59f0ddae68aa7b05fc
--- /dev/null
+++ b/media/midi/usb_midi_descriptor_parser.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 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_DESCRIPTOR_PARSER_H_
+#define MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/containers/hash_tables.h"
+#include "media/base/media_export.h"
+#include "media/midi/usb_midi_jack.h"
+
+namespace media {
+
+class UsbMidiDevice;
+
+// UsbMidiDescriptorParser parses USB descriptors and
+// generates input / output lists of MIDIPortInfo.
+class MEDIA_EXPORT UsbMidiDescriptorParser {
+ public:
+ UsbMidiDescriptorParser();
+ ~UsbMidiDescriptorParser();
+
+ // Returns true if the operation succeeds.
+ // When an incorrect input is given, this method may return true but
+ // never crashes.
Takashi Toyoshima 2013/12/19 05:54:23 So, when does it return false? Or why it may retur
yhirano 2013/12/19 07:15:05 It may return false when the input is not correct.
+ bool Parse(UsbMidiDevice* device, const uint8* data, size_t size);
+
+ const std::vector<UsbMidiJack>& jacks() const { return jacks_; }
+
+ private:
+ bool ParseInternal(UsbMidiDevice* device, const uint8* data, size_t size);
+ bool ParseInterface(UsbMidiDevice* device, const uint8* data, size_t size);
+ bool ParseCSInterface(UsbMidiDevice* device, const uint8* data, size_t size);
+ bool ParseEndpoint(UsbMidiDevice* device, const uint8* data, size_t size);
+ bool ParseCSEndpoint(UsbMidiDevice* device, const uint8* data, size_t size);
+ void Clear();
+ void ClearExceptJacks();
+
+ bool is_parsing_usb_midi_interface_;
+ uint8 current_endpoint_address_;
+ uint8 current_cable_number_;
+
+ std::vector<UsbMidiJack> jacks_;
Takashi Toyoshima 2013/12/19 05:54:23 Some comments? They are not trivial, and comments
yhirano 2013/12/19 07:15:05 Done.
+ base::hash_map<uint8, UsbMidiJack> incomplete_jacks_;
Takashi Toyoshima 2013/12/19 05:54:23 DISALLOW_COPY_AND_ASSIGN()
yhirano 2013/12/19 07:15:05 Done.
+};
+
+
+} // namespace media
+
+#endif // MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_

Powered by Google App Engine
This is Rietveld 408576698