Fixing UMA logging for GestureNav
[chromium-blink-merge.git] / media / midi / usb_midi_descriptor_parser.h
blob826a449ef6e39cb91cf14a5c8d70b90edef00a42
1 // Copyright 2014 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.
5 #ifndef MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
6 #define MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "media/base/media_export.h"
12 #include "media/midi/usb_midi_jack.h"
14 namespace media {
16 class UsbMidiDevice;
18 // UsbMidiDescriptorParser parses USB descriptors and
19 // generates input / output lists of MIDIPortInfo.
20 // This is not a generic USB descriptor parser: this parser is designed
21 // for collecting USB-MIDI jacks information from the descriptor.
22 class MEDIA_EXPORT UsbMidiDescriptorParser {
23 public:
24 UsbMidiDescriptorParser();
25 ~UsbMidiDescriptorParser();
27 // Returns true if the operation succeeds.
28 // When an incorrect input is given, this method may return true but
29 // never crashes.
30 bool Parse(UsbMidiDevice* device,
31 const uint8* data,
32 size_t size,
33 std::vector<UsbMidiJack>* jacks);
35 private:
36 bool ParseInternal(UsbMidiDevice* device,
37 const uint8* data,
38 size_t size,
39 std::vector<UsbMidiJack>* jacks);
40 bool ParseInterface(const uint8* data, size_t size);
41 bool ParseCSInterface(UsbMidiDevice* device, const uint8* data, size_t size);
42 bool ParseEndpoint(const uint8* data, size_t size);
43 bool ParseCSEndpoint(const uint8* data,
44 size_t size,
45 std::vector<UsbMidiJack>* jacks);
46 void Clear();
48 bool is_parsing_usb_midi_interface_;
49 uint8 current_endpoint_address_;
50 uint8 current_cable_number_;
52 std::vector<UsbMidiJack> incomplete_jacks_;
54 DISALLOW_COPY_AND_ASSIGN(UsbMidiDescriptorParser);
58 } // namespace media
60 #endif // MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_