# This template is based on # http://www.usb.org/developers/docs/devclass_docs/audio10.pdf # Chapter 4.3 audio_control_interface_descriptor = Template( name='audio_control_interface_descriptor', fields=[ SubDescriptor( name='Standard AC interface descriptor', descriptor_type=_DescriptorTypes.INTERFACE, fields=[ UInt8(name='bInterfaceNumber', value=0x00), UInt8(name='bAlternateSetting', value=0x00), ElementCount(name='bNumEndpoints', depends_on='endpoints', length=8), UInt8(name='bInterfaceClass', value=0x01, fuzzable=False), # audio UInt8(name='bInterfaceSubClass', value=0x01, fuzzable=False), # audio control UInt8(name='bInterfaceProtocol', value=0x00), UInt8(name='iInterface', value=0x01), ]), List( name='Class-Specific AC interfaces', fields=[ SubDescriptor( name='header', descriptor_type=_DescriptorTypes.CS_INTERFACE, fields=[
BE32(name="duration", value=0x00000183), BE32(name="reserved2", value=0x00000000), BE32(name="reserved3", value=0x00000000), BE16(name="layer", value=0x0000), BE16(name="alternate_group", value=0x0001), BE16(name="volume", value=0x0100), BE16(name="reserved4", value=0x0000), Static(name="matrix", value=""" 000100000000000000000000000000000001000000000000000000000000 000040000000""".replace("\n", "").decode("hex")), BE32(name="width", value=0x00000000), BE32(name="height", value=0x00000000), ], fuzzable=False), Mp4Box("edts", fields=[ Mp4FullBox("elst", fields=[ ElementCount(name="entry_count", depends_on="dataentries", length=32), Container(name="dataentries", fields=[ EditListEntry(0x00000154, 0x00000400, 0x0001, 0x0000), ]) ]) ]), Mp4Box("mdia", fields=[ Mp4FullBox("mdhd", fields=[ BE32(name="creation_time", value=0x00000000), BE32(name="modification_time", value=0x00000000), BE32(name="timescale", value=0x00005622), BE32(name="duration", value=0x00002140), BE16(name="language", value=0x55c4), BE16(name="pre_defined", value=0x0000), ], fuzzable=False), HdlrBox("soun", "SoundHandler"),
value_field, flags=0, fuzzable=fuzzable) apev2container = Container( name="apev2container", fields=[ Static("APETAGEX"), LE32(name="version", value=struct.unpack("<I", "2000")[0]), SizeInBytes(name="size", sized_field="items and footer", length=32, encoder=ENC_INT_LE), ElementCount(depends_on="items", length=32, name="item count", encoder=ENC_INT_LE), LE32(name="flags", value=0xa0000000), RandomBytes(name="reserved", value="\x00" * 8, min_length=8, max_length=8), Container( name="items and footer", fields=[ OneOf( name="items", fields=[ apev2textitem("Title", "Music Piece Title"), apev2textitem( "Subtitle",
UInt8(name='bNumConfigurations', value=0), UInt8(name='bReserved', value=0) ]) # Configuration descriptor # Section 9.6.3, page 265 configuration_descriptor = Template( name='configuration_descriptor', fields=[ UInt8(name='bLength', value=9), UInt8(name='bDescriptorType', value=DescriptorType.configuration), SizeInBytes(name='wTotalLength', sized_field='/', length=16, encoder=ENC_INT_LE), ElementCount(name='bNumInterfaces', depends_on='interfaces', length=8), UInt8(name='bConfigurationValue', value=1), UInt8(name='iConfiguration', value=0), BitField(name='bmAttributes', value=0, length=8), UInt8(name='bMaxPower', value=1), List(name='interfaces', fields=[ Container( name='iface and eps', fields=[ SubDescriptor( name='interface_descriptor', descriptor_type=DescriptorType.interface, fields=[ UInt8(name='bInterfaceNumber', value=0), UInt8(name='bAlternateSetting', value=0),