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_
10 #include "base/basictypes.h"
11 #include "media/base/media_export.h"
12 #include "media/midi/usb_midi_jack.h"
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
{
24 UsbMidiDescriptorParser();
25 ~UsbMidiDescriptorParser();
27 // Returns true if the operation succeeds.
28 // When an incorrect input is given, this method may return true but
30 bool Parse(UsbMidiDevice
* device
,
33 std::vector
<UsbMidiJack
>* jacks
);
36 bool ParseInternal(UsbMidiDevice
* device
,
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
,
45 std::vector
<UsbMidiJack
>* jacks
);
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
);
60 #endif // MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_