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

Side by Side 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 unified diff | Download patch
OLDNEW
(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_DESCRIPTOR_PARSER_H_
6 #define MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/containers/hash_tables.h"
12 #include "media/base/media_export.h"
13 #include "media/midi/usb_midi_jack.h"
14
15 namespace media {
16
17 class UsbMidiDevice;
18
19 // UsbMidiDescriptorParser parses USB descriptors and
20 // generates input / output lists of MIDIPortInfo.
21 class MEDIA_EXPORT UsbMidiDescriptorParser {
22 public:
23 UsbMidiDescriptorParser();
24 ~UsbMidiDescriptorParser();
25
26 // Returns true if the operation succeeds.
27 // When an incorrect input is given, this method may return true but
28 // 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.
29 bool Parse(UsbMidiDevice* device, const uint8* data, size_t size);
30
31 const std::vector<UsbMidiJack>& jacks() const { return jacks_; }
32
33 private:
34 bool ParseInternal(UsbMidiDevice* device, const uint8* data, size_t size);
35 bool ParseInterface(UsbMidiDevice* device, const uint8* data, size_t size);
36 bool ParseCSInterface(UsbMidiDevice* device, const uint8* data, size_t size);
37 bool ParseEndpoint(UsbMidiDevice* device, const uint8* data, size_t size);
38 bool ParseCSEndpoint(UsbMidiDevice* device, const uint8* data, size_t size);
39 void Clear();
40 void ClearExceptJacks();
41
42 bool is_parsing_usb_midi_interface_;
43 uint8 current_endpoint_address_;
44 uint8 current_cable_number_;
45
46 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.
47 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.
48 };
49
50
51 } // namespace media
52
53 #endif // MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698