#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/midi/usb_midi_descriptor_parser.h"
#include "base/logging.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
namespace midi {
namespace {
enum DescriptorType { … };
enum DescriptorSubType { … };
enum JackType { … };
const uint8_t kAudioInterfaceClass = …;
const uint8_t kAudioMidiInterfaceSubclass = …;
bool DecodeBcd(uint8_t byte, int* decoded) { … }
}
std::string UsbMidiDescriptorParser::DeviceInfo::BcdVersionToString(
uint16_t version) { … }
UsbMidiDescriptorParser::UsbMidiDescriptorParser()
: … { … }
UsbMidiDescriptorParser::~UsbMidiDescriptorParser() = default;
bool UsbMidiDescriptorParser::Parse(UsbMidiDevice* device,
const uint8_t* data,
size_t size,
std::vector<UsbMidiJack>* jacks) { … }
bool UsbMidiDescriptorParser::ParseDeviceInfo(const uint8_t* data,
size_t size,
DeviceInfo* info) { … }
bool UsbMidiDescriptorParser::ParseInternal(UsbMidiDevice* device,
const uint8_t* data,
size_t size,
std::vector<UsbMidiJack>* jacks) { … }
bool UsbMidiDescriptorParser::ParseDevice(const uint8_t* data,
size_t size,
DeviceInfo* info) { … }
bool UsbMidiDescriptorParser::ParseInterface(const uint8_t* data, size_t size) { … }
bool UsbMidiDescriptorParser::ParseCSInterface(UsbMidiDevice* device,
const uint8_t* data,
size_t size) { … }
bool UsbMidiDescriptorParser::ParseEndpoint(const uint8_t* data, size_t size) { … }
bool UsbMidiDescriptorParser::ParseCSEndpoint(const uint8_t* data,
size_t size,
std::vector<UsbMidiJack>* jacks) { … }
void UsbMidiDescriptorParser::Clear() { … }
}