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

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

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

Powered by Google App Engine
This is Rietveld 408576698