UAC设备实例分析
+ -

华为UAC耳机 音频流接口

2021-02-08 1153 0

音频流接口分为麦克风和耳机(headphone)。

由于音频流传输只能是同步/等时传输方式进行,故在音频流接口描述符中,接口bAlternateSetting=0时为默认的无音频输出接口即无端点描述符,从bAlternateSetting=1开始有数据传输,即应该有等时传输端点描述符

麦克风

在麦克风下只有一个音频转换接口,音频接口的采样率为48000HZ,格式为PCM.包的最大数据长度为192字节,即1ms,数据支持的是2通道(左右),每个通道16字节。

在UAC中,固定采用时间间隔是1ms.

所以48000/1000ms=48*2(通道)*2(字节) = 192字节/ms

麦克风

        ---------------- Interface Descriptor -----------------          麦克风关闭   1
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01
bAlternateSetting        : 0x00
bNumEndpoints            : 0x00 (Default Control Pipe only)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x00
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 01 00 00 01 02 00 00                        .........

        ---------------- Interface Descriptor -----------------       打开
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x01
bAlternateSetting        : 0x01
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x00
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 01 01 01 01 02 00 00                        .........

        -------- Audio Streaming Interface Descriptor ---------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x01
bTerminalLink            : 0x05
bDelay                   : 0x00
wFormatTag               : 0x0001 (PCM)
Data (HexDump)           : 07 24 01 05 00 01 00                              .$.....

        ------- Audio Streaming Format Type Descriptor --------      麦克风
bLength                  : 0x0B (11 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x02 (Format Type)
bFormatType              : 0x01 (FORMAT_TYPE_I)
bNrChannels              : 0x02 (2 channels)
bSubframeSize            : 0x02 (2 bytes per subframe)
bBitResolution           : 0x10 (16 bits per sample)
bSamFreqType             : 0x01 (supports 1 sample frequence)
tSamFreq[1]              : 0x0BB80 (48000 Hz)
Data (HexDump)           : 0B 24 02 01 02 02 10 01 80 BB 00                  .$.........

        ----------------- Endpoint Descriptor -----------------         麦克风 输入数据
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x83 (Direction=IN EndpointID=3)
bmAttributes             : 0x0D (TransferType=Isochronous  SyncType=Synchronous  EndpointType=Data)
wMaxPacketSize           : 0x00C0 (192 bytes)   //192/48=4
bInterval                : 0x01 (1 ms)
bRefresh                 : 0x00
bSynchAddress            : 0x00
Data (HexDump)           : 09 05 83 0D C0 00 01 00 00                        .........

        ----------- Audio Data Endpoint Descriptor ------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x25 (Audio Endpoint Descriptor)
bDescriptorSubtype       : 0x01 (General)
bmAttributes             : 0x01
 D0   : Sampling Freq    : 0x01 (supported)
 D1   : Pitch            : 0x00 (not supported)
 D6..2: Reserved         : 0x00
 D7   : MaxPacketsOnly   : 0x00 (no)
bLockDelayUnits          : 0x00 (Undefined)
wLockDelay               : 0x0000
Data (HexDump)           : 07 25 01 01 00 00 00                              .%.....

耳机

耳机支持2个转换接口,按每通道的字节数分为2字节和3字节,分别对应的是转换接口2和3。
耳机

        ---------------- Interface Descriptor -----------------            耳机关闭 2
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x02
bAlternateSetting        : 0x00
bNumEndpoints            : 0x00 (Default Control Pipe only)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x00
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 02 00 00 01 02 00 00                        .........

        ---------------- Interface Descriptor -----------------           耳机打开  2
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x02
bAlternateSetting        : 0x01
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x00
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 02 01 01 01 02 00 00                        .........

        -------- Audio Streaming Interface Descriptor ---------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x01
bTerminalLink            : 0x01
bDelay                   : 0x00
wFormatTag               : 0x0001 (PCM)
Data (HexDump)           : 07 24 01 01 00 01 00                              .$.....

        ------- Audio Streaming Format Type Descriptor --------
bLength                  : 0x11 (17 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x02 (Format Type)
bFormatType              : 0x01 (FORMAT_TYPE_I)
bNrChannels              : 0x02 (2 channels)
bSubframeSize            : 0x02 (2 bytes per subframe)
bBitResolution           : 0x10 (16 bits per sample)
bSamFreqType             : 0x03 (supports 3 sample frequencies)
tSamFreq[1]              : 0x0AC44 (44100 Hz)
tSamFreq[2]              : 0x0BB80 (48000 Hz)
tSamFreq[3]              : 0x17700 (96000 Hz)
Data (HexDump)           : 11 24 02 01 02 02 10 03 44 AC 00 80 BB 00 00 77   .$......D......w
                           01                                                .

        ----------------- Endpoint Descriptor -----------------             耳机输出数据=====1
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x03 (Direction=OUT EndpointID=3)
bmAttributes             : 0x0D (TransferType=Isochronous  SyncType=Synchronous  EndpointType=Data)
wMaxPacketSize           : 0x0180 (384 bytes)        384/96=4  
bInterval                : 0x01 (1 ms)
bRefresh                 : 0x00
bSynchAddress            : 0x00
Data (HexDump)           : 09 05 03 0D 80 01 01 00 00                        .........

        ----------- Audio Data Endpoint Descriptor ------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x25 (Audio Endpoint Descriptor)
bDescriptorSubtype       : 0x01 (General)
bmAttributes             : 0x01
 D0   : Sampling Freq    : 0x01 (supported)
 D1   : Pitch            : 0x00 (not supported)
 D6..2: Reserved         : 0x00
 D7   : MaxPacketsOnly   : 0x00 (no)
bLockDelayUnits          : 0x00 (Undefined)
wLockDelay               : 0x0000
Data (HexDump)           : 07 25 01 01 00 00 00                              .%.....

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x02
bAlternateSetting        : 0x02
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x02 (Audio Streaming)
bInterfaceProtocol       : 0x00
iInterface               : 0x00 (No String Descriptor)
Data (HexDump)           : 09 04 02 02 01 01 02 00 00                        .........

        -------- Audio Streaming Interface Descriptor ---------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x01
bTerminalLink            : 0x01
bDelay                   : 0x00
wFormatTag               : 0x0001 (PCM)
Data (HexDump)           : 07 24 01 01 00 01 00                              .$.....

        ------- Audio Streaming Format Type Descriptor --------
bLength                  : 0x11 (17 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x02 (Format Type)
bFormatType              : 0x01 (FORMAT_TYPE_I)
bNrChannels              : 0x02 (2 channels)
bSubframeSize            : 0x03 (3 bytes per subframe)
bBitResolution           : 0x18 (24 bits per sample)
bSamFreqType             : 0x03 (supports 3 sample frequencies)
tSamFreq[1]              : 0x0AC44 (44100 Hz)
tSamFreq[2]              : 0x0BB80 (48000 Hz)
tSamFreq[3]              : 0x17700 (96000 Hz)
Data (HexDump)           : 11 24 02 01 02 03 18 03 44 AC 00 80 BB 00 00 77   .$......D......w
                           01                                                .

        ----------------- Endpoint Descriptor -----------------            =====2
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x03 (Direction=OUT EndpointID=3)
bmAttributes             : 0x0D (TransferType=Isochronous  SyncType=Synchronous  EndpointType=Data)
wMaxPacketSize           : 0x0240 (576 bytes)                            576/96=6
bInterval                : 0x01 (1 ms)
bRefresh                 : 0x00
bSynchAddress            : 0x00
Data (HexDump)           : 09 05 03 0D 40 02 01 00 00                        ....@....

        ----------- Audio Data Endpoint Descriptor ------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x25 (Audio Endpoint Descriptor)
bDescriptorSubtype       : 0x01 (General)
bmAttributes             : 0x01
 D0   : Sampling Freq    : 0x01 (supported)
 D1   : Pitch            : 0x00 (not supported)
 D6..2: Reserved         : 0x00
 D7   : MaxPacketsOnly   : 0x00 (no)
bLockDelayUnits          : 0x00 (Undefined)
wLockDelay               : 0x0000
Data (HexDump)           : 07 25 01 01 00 00 00                              .%.....
HID人机交互QQ群:564808376    UAC音频QQ群:218581009    UVC相机QQ群:331552032    BOT&UASP大容量存储QQ群:258159197    STC-USB单片机QQ群:315457461    USB技术交流QQ群2:580684376    USB技术交流QQ群:952873936   

0 篇笔记 写笔记

华为UAC耳机 音频控制接口
音频控制接口占用接口ID=0,音频控制接口的描述符结构布局如下:USB标准接口描述符UAC音频控制接口头描述符IDSId描述    音频控制输入终端描述符1USB Streaming   ......
华为UAC耳机的工作过程数据分析
华为UAC耳机工作时,首先需要打开设备,然后读取数据,播放过程后,需要关闭设备。这里我们使用BusHound抓包(省略掉重复的数据包:由于这些特定类请求是发给UAC音频控制终端/实体或接口的,所以我们先回顾一下UAC音频控制单元的一些ID,然后对照其选择子进行分析。UAC音频控制接口头描述符ID描述......
华为UAC耳机 配置描述符
配置描述符的大小其实不光包括配置描述符自身,也包括后续的所有描述符。这里我们只先介绍一下配置描述符,后续的接口描述符和其它UAC相关描述符在后续一节介绍。配置描述符的内容如下: ------------------ Configuration Descriptor --------------......
华为UAC麦克风的工作过程数据分析
看完了耳机的数据分析,再来分析麦克风,就相对来说很简单了,这是因为:第一:麦克风没有音频控制特效单元描述符,所以少了很多特定类请求。第二:麦克风只有一个音频流转换接口,且只支持采样率为48000HZ 16位。具体的过程见下:Length Phase Data-------- --......
UAC 标准音频流接口描述符
UAC音频流接口描述符包含与音频数据流相关的描述符信息。标准音频流接口描述符,Standard AS Interface Descriptor是音频流接口描述符的第一个描述符。该描述符是标准的接口描述符,故数据结构定义如下:typedef struct _USB_INTERFACE_DESCRIPT......
华为UAC耳机 设备描述符
从UAC的设备描述符可知,音频是属于接口级别的,在UAC1.0版本,是需要将相关的配置参数bDeviceClass,bDeviceSubClass,bDeviceProtocoll置为0。对于别的参数,可参考USB设备描述符进行相关配置。本设备只有一个配置描述符,且端点0的bMaxPacketSiz......
华为UAC耳机 概述
本人手中有一个华为的TYPE-C耳机,其实是一个复合设备(usbccgp.sys)。这个复合设备总共有三个分设备,分别为HeadPhone(耳机),Microphone(麦克风)和一个自定义的HID设备。在设备管理器中设备树关系如下:设备的硬件ID如下:USBVID_12D1&PID_3A......
华为UAC耳机 字符串描述符
字符串描述符 -------------------- String Descriptors ------------------- ------ String Descriptor 0 ------bLength : 0x04 (......
USB-UAC麦克风 音频流接口
音频流接口有2个转换接口。UAC麦克风 零带宽转换接口转换接口0是零带宽设置,用于在麦克风未使用。这是通电后的默认设置。实现了零带宽通过指定接口的此备用设置没有与之关联的端点(bNumEndpoints=0)。偏移地址字段长度值描述0bLength10x091bDescriptorType10x04......
华为UAC耳机 HID接口
---------------- Interface Descriptor ----------------- HIDbLength : 0x09 (9 bytes)bDescriptorType : 0x04 (Interf......
UAC 类特定音频流接口描述符
类特定音频流接口描述符:Class-Specific AS Interface Descriptor.UAC类特定音频流接口描述符 - UVC1.0结构体定义如下:typedef struct _USB_ASI_DESCRIPTOR{ UINT8 bLength; UINT8......
UAC 传输速度
传统3.5mm模拟耳机逐步被USB数字耳机代替。采用USB协议进行音频播放使用USB Audio Class协议(简称UAC).UAC2.0由于支持USB High Speed,从而天生带有高带宽、低延时的优势。这些优势转化为对于Hi-Resolution Auido的支持。UAC1.0最高只支持到......
华为UAC耳机 音频流接口
音频流接口分为麦克风和耳机(headphone)。由于音频流传输只能是同步/等时传输方式进行,故在音频流接口描述符中,接口bAlternateSetting=0时为默认的无音频输出接口即无端点描述符,从bAlternateSetting=1开始有数据传输,即应该有等时传输端点描述符。麦克风在麦克风下......
UAC麦克风音频流接口描述符
UAC麦克风音频流接口描述符使用普通用USB接口描述符结构,该描述符是音频流描述符集合的开始。UAC音频流描述符的组织结构如下图:UAC麦克风音频流接口描述符的数据配置如下:接口描述符的各字段的解释详见:USB接口描述符 http://www.usbzh.com/article/detail......
UAC麦克风类特定音频流接口描述符
UAC麦克风类特定音频流接口描述符数据组织如下图:该描述符包含了音频数据流的相关信息。关于该描述符的字段解释详见:http://www.usbzh.com/article/detail-158.html/* 4.5.2 Class-Specific AS Interface Descript......
关注公众号
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!