Windows操作系统USB主机如何管理UVC视频的USB带宽?
2021-11-04
570
0
Windows操作系统的视频宽带管理是由视频类驱动usbvideo.sys来管理的。对于USB带宽的调整,是通过同步传输的备用接口来实现的。当一个设备从一个非0备用接口切换至另一个非0备用接口时,USB主机需要对UVC视频流带宽进行重新配置,在这过程中需要停止原来的同步传输,重新开启新的同步传输实现对UVC视频带宽的动态调整。
对UVC视频流的带宽调整是原子操作的,当然调整的前提可以满足新的带宽。在进行带宽调整的过程中新的带宽不满足需求,则调整失败,并且并不保留老的带宽,所以需要重新设置老的备用接口实现带宽的恢复。
备用接口的选择是通过端口驱动程序(usbport.sys)序列化实现的。
如本群中有一同学,同时打开2个UVCB摄像头,但是由于第一个UVC摄像头已经使用了部分USB带宽,导致打开第二个摄像头的时候,设备请求的带宽而USB总线无法满足,导致打开摄像头失败。使用bushound抓包如下:
Device Phase Data Description
------ ----- ------------------------ -------------
23.0 CTL 21 01 00 05 00 02 01 00 SET CUR
23.0 OUT 01 .
23.0 CTL a1 81 00 01 01 00 1a 00 GET CUR
23.0 IN 00 00 01 01 80 1a 06 00 ........
00 00 00 00 00 00 1e 00 ........
00 00 00 00 00 00 00 00 ........
00 00 ..
23.0 CTL a1 83 00 01 01 00 1a 00 GET MAX
23.0 IN 00 00 01 01 80 1a 06 00 ........
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
00 00 ..
23.0 CTL a1 82 00 01 01 00 1a 00 GET MIN
23.0 IN 00 00 01 01 80 1a 06 00 ........
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
00 00 ..
23.0 CTL 21 01 00 01 01 00 1a 00 SET CUR
23.0 OUT 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 1e 00 ........
00 00 00 00 00 00 00 00 ........
00 00 ..
23.0 CTL a1 81 00 01 01 00 1a 00 GET CUR
23.0 IN 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 1e 00 ........
00 00 00 60 09 00 00 0c ...`....
00 00 ..
23.0 CTL a1 83 00 01 01 00 1a 00 GET MAX
23.0 IN 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 00 00 ........
00 00 00 60 09 00 00 0c ...`....
00 00 ..
23.0 CTL a1 82 00 01 01 00 1a 00 GET MIN
23.0 IN 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 00 00 ........
00 00 00 60 09 00 00 0c ...`....
00 00 ..
23.0 CTL 21 01 00 01 01 00 1a 00 SET CUR
23.0 OUT 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 1e 00 ........
00 00 00 60 09 00 00 00 ...`....
00 00 ..
23.0 CTL a1 81 00 01 01 00 1a 00 GET CUR
23.0 IN 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 1e 00 ........
00 00 00 60 09 00 00 0c ...`....
00 00 ..
23.0 CTL 21 01 00 02 01 00 1a 00 SET CUR
23.0 OUT 00 00 01 0a 15 16 05 00 ........
00 00 00 00 00 00 1e 00 ........
00 00 00 60 09 00 00 0c ...`....
00 00 ..
23.0 CTL 01 0b 06 00 01 00 00 00 SET INTERFACE
23.0 USTS 80000700 no bandwidth
23.0 CTL 01 0b 00 00 01 00 00 00 SET INTERFACE
可以看到,选择接口时,USB状态返回80000700,即带宽不足,这时USBvideo会关闭摄像头即自动选择备用接口为0的接口。
带宽不足的解决方案
- 降低码率,如分辨率,帧率,使用压缩格式的数据格式如MJPG,H264等
- 在PC机中增加一条USB总线,可以采用PCIE转USB控制器,用新的USB总线来挂接另一条设备
- 更换支持超高速的设备和主机如USB3.2GEN1/GEN2等支持大带宽的设备和主机
HID人机交互QQ群:564808376
UAC音频QQ群:218581009
UVC相机QQ群:331552032
BOT&UASP大容量存储QQ群:258159197
STC-USB单片机QQ群:315457461
USB技术交流QQ群2:580684376
USB技术交流QQ群:952873936