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

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

Issue 1098913003: [WebMIDI] [Android] Set appropriate port properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 8 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/midi_manager_usb_unittest.cc ('k') | media/midi/usb_midi_descriptor_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_ 5 #ifndef MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
6 #define MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_ 6 #define MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
7 7
8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/basictypes.h" 11 #include "base/basictypes.h"
11 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
12 #include "media/midi/usb_midi_jack.h" 13 #include "media/midi/usb_midi_jack.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 class UsbMidiDevice; 17 class UsbMidiDevice;
17 18
18 // UsbMidiDescriptorParser parses USB descriptors and 19 // UsbMidiDescriptorParser parses USB descriptors and
19 // generates input / output lists of MIDIPortInfo. 20 // generates input / output lists of MIDIPortInfo.
20 // This is not a generic USB descriptor parser: this parser is designed 21 // This is not a generic USB descriptor parser: this parser is designed
21 // for collecting USB-MIDI jacks information from the descriptor. 22 // for collecting USB-MIDI jacks information from the descriptor.
22 class MEDIA_EXPORT UsbMidiDescriptorParser { 23 class MEDIA_EXPORT UsbMidiDescriptorParser {
23 public: 24 public:
25 struct DeviceInfo {
26 DeviceInfo()
27 : vendor_id(0),
28 product_id(0),
29 bcd_device_version(0),
30 manufacturer_index(0),
31 product_index(0) {}
32 uint16 vendor_id;
33 uint16 product_id;
34 // The higher one byte represents the "major" number and the lower one byte
35 // represents the "minor" number.
36 uint16 bcd_device_version;
37 uint8 manufacturer_index;
38 uint8 product_index;
39
40 static std::string BcdVersionToString(uint16);
41 };
42
24 UsbMidiDescriptorParser(); 43 UsbMidiDescriptorParser();
25 ~UsbMidiDescriptorParser(); 44 ~UsbMidiDescriptorParser();
26 45
27 // Returns true if the operation succeeds. 46 // Returns true if the operation succeeds.
28 // When an incorrect input is given, this method may return true but 47 // When an incorrect input is given, this method may return true but
29 // never crashes. 48 // never crashes.
30 bool Parse(UsbMidiDevice* device, 49 bool Parse(UsbMidiDevice* device,
31 const uint8* data, 50 const uint8* data,
32 size_t size, 51 size_t size,
33 std::vector<UsbMidiJack>* jacks); 52 std::vector<UsbMidiJack>* jacks);
34 53
54 bool ParseDeviceInfo(const uint8* data, size_t size, DeviceInfo* info);
55
35 private: 56 private:
36 bool ParseInternal(UsbMidiDevice* device, 57 bool ParseInternal(UsbMidiDevice* device,
37 const uint8* data, 58 const uint8* data,
38 size_t size, 59 size_t size,
39 std::vector<UsbMidiJack>* jacks); 60 std::vector<UsbMidiJack>* jacks);
61 bool ParseDevice(const uint8* data, size_t size, DeviceInfo* info);
40 bool ParseInterface(const uint8* data, size_t size); 62 bool ParseInterface(const uint8* data, size_t size);
41 bool ParseCSInterface(UsbMidiDevice* device, const uint8* data, size_t size); 63 bool ParseCSInterface(UsbMidiDevice* device, const uint8* data, size_t size);
42 bool ParseEndpoint(const uint8* data, size_t size); 64 bool ParseEndpoint(const uint8* data, size_t size);
43 bool ParseCSEndpoint(const uint8* data, 65 bool ParseCSEndpoint(const uint8* data,
44 size_t size, 66 size_t size,
45 std::vector<UsbMidiJack>* jacks); 67 std::vector<UsbMidiJack>* jacks);
46 void Clear(); 68 void Clear();
47 69
48 bool is_parsing_usb_midi_interface_; 70 bool is_parsing_usb_midi_interface_;
49 uint8 current_endpoint_address_; 71 uint8 current_endpoint_address_;
50 uint8 current_cable_number_; 72 uint8 current_cable_number_;
51 73
52 std::vector<UsbMidiJack> incomplete_jacks_; 74 std::vector<UsbMidiJack> incomplete_jacks_;
53 75
54 DISALLOW_COPY_AND_ASSIGN(UsbMidiDescriptorParser); 76 DISALLOW_COPY_AND_ASSIGN(UsbMidiDescriptorParser);
55 }; 77 };
56 78
57 79
58 } // namespace media 80 } // namespace media
59 81
60 #endif // MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_ 82 #endif // MEDIA_MIDI_USB_MIDI_DESCRIPTOR_PARSER_H_
OLDNEW
« no previous file with comments | « media/midi/midi_manager_usb_unittest.cc ('k') | media/midi/usb_midi_descriptor_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698