代码之家  ›  专栏  ›  技术社区  ›  Fabiano Taioli

getUserMedia和WEBUSB在同一设备窗口上

  •  1
  • Fabiano Taioli  · 技术社区  · 7 年前

    我们正在开发一个基于Chrome(旧的USB API现在迁移到WEBUSB)和网络摄像头的项目。USB网络摄像头有一个用于拍照的按钮。在MAC和Linux中,我可以使用getUserMedia()显示网络摄像头的实时视频,同时我可以使用Web USB API与设备通信以检测按键。

    N、 B。

    Linux lsusb转储:

    Bus 001 Device 008: ID a168:0872 AnMo Electronics Corporation 
    Device Descriptor:
      bLength                18
      bDescriptorType         1
      bcdUSB               2.00
      bDeviceClass          239 Miscellaneous Device
      bDeviceSubClass         2 
      bDeviceProtocol         1 Interface Association
      bMaxPacketSize0        64
      idVendor           0xa168 AnMo Electronics Corporation
      idProduct          0x0872 
      bcdDevice           20.01
      iManufacturer           1 ANMO Electronics Corporation
      iProduct                2 Dino-Lite Premier
      iSerial                 3                         
      bNumConfigurations      1
      Configuration Descriptor:
        bLength                 9
        bDescriptorType         2
        wTotalLength          509
        bNumInterfaces          2
        bConfigurationValue     1
        iConfiguration          0 
        bmAttributes         0x80
          (Bus Powered)
        MaxPower              500mA
        Interface Association:
          bLength                 8
          bDescriptorType        11
          bFirstInterface         0
          bInterfaceCount         2
          bFunctionClass         14 Video
          bFunctionSubClass       3 Video Interface Collection
          bFunctionProtocol       0 
          iFunction               2 Dino-Lite Premier
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        0
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass        14 Video
          bInterfaceSubClass      1 Video Control
          bInterfaceProtocol      0 
          iInterface              2 Dino-Lite Premier
          VideoControl Interface Descriptor:
            bLength                13
            bDescriptorType        36
            bDescriptorSubtype      1 (HEADER)
            bcdUVC               1.00
            wTotalLength           80
            dwClockFrequency        6.000000MHz
            bInCollection           1
            baInterfaceNr( 0)       1
          VideoControl Interface Descriptor:
            bLength                18
            bDescriptorType        36
            bDescriptorSubtype      2 (INPUT_TERMINAL)
            bTerminalID             1
            wTerminalType      0x0201 Camera Sensor
            bAssocTerminal          0
            iTerminal               0 
            wObjectiveFocalLengthMin      0
            wObjectiveFocalLengthMax      0
            wOcularFocalLength            0
            bControlSize                  3
            bmControls           0x000200a2
              Auto-Exposure Mode
              Focus (Absolute)
              Iris (Absolute)
              Focus, Auto
          VideoControl Interface Descriptor:
            bLength                11
            bDescriptorType        36
            bDescriptorSubtype      5 (PROCESSING_UNIT)
          Warning: Descriptor too short
            bUnitID                 3
            bSourceID               1
            wMaxMultiplier          0
            bControlSize            2
            bmControls     0x0000147f
              Brightness
              Contrast
              Hue
              Saturation
              Sharpness
              Gamma
              White Balance Temperature
              Power Line Frequency
              White Balance Temperature, Auto
            iProcessing             0 
            bmVideoStandards     0x1d
              None
              PAL - 625/50
              SECAM - 625/50
              NTSC - 625/50
          VideoControl Interface Descriptor:
            bLength                29
            bDescriptorType        36
            bDescriptorSubtype      6 (EXTENSION_UNIT)
            bUnitID                 4
            guidExtensionCode         {2652215a-8932-5641-894a-5c557cdf9664}
            bNumControl            16
            bNrPins                 1
            baSourceID( 0)          3
            bControlSize            4
            bmControls( 0)       0xff
            bmControls( 1)       0xff
            bmControls( 2)       0xff
            bmControls( 3)       0xff
            iExtension              0 
          VideoControl Interface Descriptor:
            bLength                 9
            bDescriptorType        36
            bDescriptorSubtype      3 (OUTPUT_TERMINAL)
            bTerminalID             2
            wTerminalType      0x0101 USB Streaming
            bAssocTerminal          0
            bSourceID               4
            iTerminal               0 
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x81  EP 1 IN
            bmAttributes            3
              Transfer Type            Interrupt
              Synch Type               None
              Usage Type               Data
            wMaxPacketSize     0x0008  1x 8 bytes
            bInterval               9
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        1
          bAlternateSetting       0
          bNumEndpoints           1
          bInterfaceClass        14 Video
          bInterfaceSubClass      2 Video Streaming
          bInterfaceProtocol      0 
          iInterface              0 
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x82  EP 2 IN
            bmAttributes            5
              Transfer Type            Isochronous
              Synch Type               Asynchronous
              Usage Type               Data
            wMaxPacketSize     0x0000  1x 0 bytes
            bInterval               1
            INTERFACE CLASS:  0f 24 01 02 67 01 82 00 02 01 01 00 01 00 00
            INTERFACE CLASS:  0b 24 06 01 05 00 01 00 00 00 00
            INTERFACE CLASS:  1e 24 07 01 00 80 02 e0 01 00 00 08 ca 00 00 08 ca 00 60 09 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1e 24 07 02 00 40 01 f0 00 80 00 02 32 80 00 02 32 00 58 02 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1e 24 07 03 00 a0 00 78 00 a0 00 00 8c a0 00 00 8c 00 96 00 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1e 24 07 04 00 00 05 00 04 00 00 19 00 00 00 19 00 00 00 28 00 20 a1 07 00 01 20 a1 07 00
            INTERFACE CLASS:  1e 24 07 01 00 80 02 e0 01 00 00 08 ca 00 00 08 ca 00 60 09 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1b 24 04 02 05 59 55 59 32 00 00 10 00 80 00 00 aa 00 38 9b 71 10 01 00 00 00 00
            INTERFACE CLASS:  1e 24 05 01 00 80 02 e0 01 00 00 08 ca 00 00 08 ca 00 60 09 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1e 24 05 02 00 40 01 f0 00 80 00 02 32 80 00 02 32 00 58 02 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1e 24 05 03 00 a0 00 78 00 a0 00 00 8c a0 00 00 8c 00 96 00 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  1e 24 05 04 00 00 05 00 04 00 00 19 00 00 00 19 00 00 00 28 00 20 a1 07 00 01 20 a1 07 00
            INTERFACE CLASS:  1e 24 05 01 00 80 02 e0 01 00 00 08 ca 00 00 08 ca 00 60 09 00 15 16 05 00 01 15 16 05 00
            INTERFACE CLASS:  06 24 0d 00 00 00
        Interface Descriptor:
          bLength                 9
          bDescriptorType         4
          bInterfaceNumber        1
          bAlternateSetting       1
          bNumEndpoints           1
          bInterfaceClass        14 Video
          bInterfaceSubClass      2 Video Streaming
          bInterfaceProtocol      0 
          iInterface              0 
          Endpoint Descriptor:
            bLength                 7
            bDescriptorType         5
            bEndpointAddress     0x82  EP 2 IN
            bmAttributes            5
              Transfer Type            Isochronous
              Synch Type               Asynchronous
              Usage Type               Data
            wMaxPacketSize     0x13fc  3x 1020 bytes
            bInterval               1
    Device Qualifier (for other device speed):
      bLength                10
      bDescriptorType         6
      bcdUSB               2.00
      bDeviceClass          239 Miscellaneous Device
      bDeviceSubClass         2 
      bDeviceProtocol         1 Interface Association
      bMaxPacketSize0        64
      bNumConfigurations      1
    can't get debug descriptor: Resource temporarily unavailable
    Device Status:     0x0000
      (Bus Powered)
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Reilly Grant    7 年前

    基于 lsusb -v 上面我可以看到,这个设备有一个由两个USB接口组成的单一功能。接口关联描述符(IAD)向主机操作系统发出信号,表明这两个接口是相关的,并且为了驱动程序绑定的目的,操作系统(如Windows)将它们视为单个接口。

    推荐文章