none
How to identify a video device correctly? RRS feed

  • Question

  • Hello,

    I know that the "DevicePath" or "DisplayName" of a Moniker is a robust way to find the appropriate device on the system. However, if I'm not mistaken, these values are only constant for a device, if the system remains always the same. If I plug the device in another USB port or try to connect to the camera via the stored value on another computer or system, then the DevicePath is already different, right?

    Therefore my question is: Is there a value, which is always constant for a certain video device, regardless on which USB port or computer it is plugged in?

    best regards,

    Vitali

    Thursday, May 10, 2012 10:15 AM

Answers

  • vanselm wrote:
    >
    >I know that the "DevicePath" or "DisplayName" of a Moniker is a robust way
    >to find the appropriate device on the system. However, if I'm not mistaken,
    >these values are only constant for a device, if the system remains always
    >the same.
     
    The "FriendlyName" comes from the INF and is associated with the device. It
    is the same no matter what port you're in, but if you have two of th same
    camera, they'll have the same friendly name.
     
    >If I plug the device in another USB port or try to connect to the camera
    >via the stored value on another computer or system, then the DevicePath
    >is already different, right?
     
    Yes.
     
    >Therefore my question is: Is there a value, which is always constant for
    >a certain video device, regardless on which USB port or computer it is
    >plugged in?
     
    No.  If your device has a serial number, it's DevicePath should be the same
    no matter what port you're plugged in to.  That's not guaranteed to port to
    other systems, however.  Further, you must not hard code the device path --
    you need to use CLSID_SystemDeviceEnum to find your device.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    • Marked as answer by vanselm Wednesday, May 16, 2012 2:24 PM
    Saturday, May 12, 2012 7:16 AM

All replies

  • vanselm wrote:
    >
    >I know that the "DevicePath" or "DisplayName" of a Moniker is a robust way
    >to find the appropriate device on the system. However, if I'm not mistaken,
    >these values are only constant for a device, if the system remains always
    >the same.
     
    The "FriendlyName" comes from the INF and is associated with the device. It
    is the same no matter what port you're in, but if you have two of th same
    camera, they'll have the same friendly name.
     
    >If I plug the device in another USB port or try to connect to the camera
    >via the stored value on another computer or system, then the DevicePath
    >is already different, right?
     
    Yes.
     
    >Therefore my question is: Is there a value, which is always constant for
    >a certain video device, regardless on which USB port or computer it is
    >plugged in?
     
    No.  If your device has a serial number, it's DevicePath should be the same
    no matter what port you're plugged in to.  That's not guaranteed to port to
    other systems, however.  Further, you must not hard code the device path --
    you need to use CLSID_SystemDeviceEnum to find your device.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    • Marked as answer by vanselm Wednesday, May 16, 2012 2:24 PM
    Saturday, May 12, 2012 7:16 AM

  • No.  If your device has a serial number, it's DevicePath should be the same
    no matter what port you're plugged in to.  That's not guaranteed to port to
    other systems, however.  Further, you must not hard code the device path --
    you need to use CLSID_SystemDeviceEnum to find your device.
    How can I find out, whether my device has a serial number?
    Wednesday, May 16, 2012 2:26 PM
  •  
    No.  If your device has a serial number, it's DevicePath should be the same
    no matter what port you're plugged in to.  That's not guaranteed to port to
    other systems, however.  Further, you must not hard code the device path --
    you need to use CLSID_SystemDeviceEnum to find your device.

    I suppose DevicePath still embeds USB port number (see David Miller's comment), so replugging the camera to another port makes it a different device. And one needs to know way to query for persistent s/n using a different method.


    http://alax.info/blog/tag/directshow

    Wednesday, May 16, 2012 5:09 PM
  • Roman Ryltsov [MVP] wrote:
    >
    >I suppose DevicePath still embeds USB port number (see David Miller's
    >comment), so replugging the camera to another port makes it a
    >different device.
     
    Not if it has a serial number, it doesn't.  I guarantee it.  A USB device
    with a serial number is seen as the same device no matter what port it is
    plugged in to.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Friday, May 18, 2012 3:05 AM
  • vanselm wrote:
    >
    >>No.  If your device has a serial number, it's DevicePath should be the same
    >>no matter what port you're plugged in to. 
    >
    >How can I find out, whether my device has a serial number?
     
    One way is to plug it into two ports and see if you get a second install.
     
    You can tell by looking at the hardware ID in Device Manager, but you'd
    have to know what you are looking for.
     
    If you have usbview from the WDK, you can tell from the descriptors.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Friday, May 18, 2012 3:21 AM
  • David gives example there with serial number, and with USB path too, hence device path would change. Can you give an example of device path that does not change with replugging the device to another port?

    http://alax.info/blog/tag/directshow

    Friday, May 18, 2012 8:12 AM
  • Roman Ryltsov [MVP] wrote:
    >
    >David gives example there with serial number, and with USB path too,
    >hence device path would change. Can you give an example of device path
    >that does not change with replugging the device to another port
    >
     
    I don't see any posts there that talk about this issue.  Can you be more
    specific?
     
    I've done drivers for USB cameras both with and without serial numbers.
    When they have a serial number, plugging in to a new port does not get a
    new devnode -- there is not a new install for it.  It uses the same devnode
    it had before.  It is the same device.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Sunday, May 20, 2012 5:28 AM
  • OK this is the post there:

    usb#vid_10f5&pid_0004&mi_00#6&edc7182&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global

    usb is the bus.

    vid_10f5 is the USB vendor/ manufacturer

    pid_0004 is the manufacture's product id

    mi_00 is the USB composite device's "multiple interface" number.

    #6 is the distance (the number of DevNodes) between the root and the device.

    edc7182 is the device's serial number

    0 I forget

    0000 I forget - maybe it's also the multiple interface number

    {65e8773d-8f56-11d0-a3b9-00a0c9223196} is KSCATEGORY_CAPTURE

    Now as you can see s/n is a part of Device Path. USB stuff too. User re-plugs into different port, is this a correct understanding of mine that DevicePath is not going to change, in particular mi_00 and #6?

    http://alax.info/blog/tag/directshow

    Sunday, May 20, 2012 10:28 AM
  • OK this is the post there:

    usb#vid_10f5&pid_0004&mi_00#6&edc7182&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global

    usb is the bus.

    vid_10f5 is the USB vendor/ manufacturer

    pid_0004 is the manufacture's product id

    mi_00 is the USB composite device's "multiple interface" number.

    #6 is the distance (the number of DevNodes) between the root and the device.

    edc7182 is the device's serial number

    0 I forget

    0000 I forget - maybe it's also the multiple interface number

    {65e8773d-8f56-11d0-a3b9-00a0c9223196} is KSCATEGORY_CAPTURE
    Now as you can see s/n is a part of Device Path. USB stuff too. User re-plugs into different port, is this a correct understanding of mine that DevicePath is not going to change, in particular mi_00 and #6?

    http://alax.info/blog/tag/directshow

    The Device Path will change. The #6 will change. For example if you stick a hub before the camera it will probably change from #6 to #7.

    One of the zeros (the “I forgots”) is probably the node number on the hub immediately above the camera. Those values can change too.


    Sunday, May 20, 2012 2:38 PM
  • How can I find out, whether my device has a serial number?

    It gets complicated. You have to find the usb hub immediately above the video capture device and send it a IOCTL_USB_GET_NODE_INFORMATION (you will need to know the wbcam’s node number). That IOCTL will return (among other things) specified device’s USB_DEVICE_DESCRIPTOR structure.

    The device descriptor will give you the index of the serial number’s string descriptor. If the value is zero then there is no serial number.

    If it is non-zero then you can use it in conjunction with IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION to get the serial number string.

    IOCTL_USB_GET_NODE_INFORMATION

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff539280(v=vs.85).aspx

    USB_NODE_INFORMATION structure

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff540110(v=vs.85).aspx

    USB_DEVICE_DESCRIPTOR structure

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff539280(v=vs.85).aspx




    Sunday, May 20, 2012 2:49 PM
  • Is there a value, which is always constant for a certain video device, regardless on which USB port or computer it is plugged in?

    best regards,

    Vitali


    Why do you want to do this?

    What problem are you trying to solve?

    If the device does not expose a serial number – and if you really, really, really need to differentiate between two identical devices (same manufacturer, same model) then there might be some other evil ways to do it.

    For example if the camera has an SD Card, and if the SD Card appears as a standard storage device to the operating system, then you can probably use the SD Card’s serial number to identify them.

    But that technique will fail as soon as the user swaps both SD Cards on both of his cameras while both cameras are disconnected from the computer.



    Sunday, May 20, 2012 3:04 PM
  • Why do you want to do this?

    What problem are you trying to solve?

    Hello,

    in my program the made configurations are serialized. Thus, you should be able to start with the saved configuration next time. I would like to guarantee, that the saved camera should be found again, if it is physically attached to the computer.

    best regards,

    Vitali

    Sunday, May 20, 2012 3:34 PM
  • Why do you want to do this?

    What problem are you trying to solve?

    Hello,

    in my program the made configurations are serialized. Thus, you should be able to start with the saved configuration next time. I would like to guarantee, that the saved camera should be found again, if it is physically attached to the computer.

    best regards,

    Vitali

    Just use the friendly name or the device Id.

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff541237(v=vs.85).aspx

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff546152(v=vs.85).aspx

    http://msdn.microsoft.com/en-us/library/windows/hardware/ff541230(v=vs.85).aspx

    I think the device Id is available from the property bag – but I’m not sure (because I use the Setup Api).

    And do you really think that your users will have two or more cameras where the manufacturer and models are identical?

    Sunday, May 20, 2012 4:10 PM
  • I don't think it is on property bag. One has to use Setup API and find ways to lookup up Setup API enumerated collection with DevicePath from the bag.

    http://alax.info/blog/tag/directshow

    Sunday, May 20, 2012 4:34 PM
  • Hello,

    I have checked the DevicePaths for different USB ports and found out, that the first part of the path is constant:

    usb#vid_10f5&pid_0004&mi_00#

    I have to check yet, whether 2 equal cameras differ in this first part of the ID string. If it is the case, then it would be sufficient for my pupose to take into account only the first part.

    best regards,

    Vitali

    Monday, May 21, 2012 12:43 PM
  • Roman Ryltsov [MVP] wrote:
    >
    >OK this is the post there:
    >
    >usb#vid_10f5&pid_0004&mi_00#6&edc7182&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global
     
    If this is his example, then his analysis is wrong.  This is a device that
    does not have a serial number.
     
    >usb is the bus.
    >vid_10f5 is the USB vendor/ manufacturer
    >pid_0004 is the manufacture's product id
    >mi_00 is the USB composite device's "multiple interface" number.
    >#6 is the distance (the number of DevNodes) between the root and the device.
    >edc7182 is the device's serial number
     
    Nope.  "edc7182" is a semi-random number assigned to this particular hub.
    All devices plugged in to this hub without a serial number will have
    6&edc7182 in this spot.
     
    >0 I forget
    >0000 I forget - maybe it's also the multiple interface number
     
    Those identify the port number within this hub.
     
    >Now as you can see s/n is a part of Device Path. USB stuff too. User
    >re-plugs into different port, is this a correct understanding of mine
    >that DevicePath is not going to change, in particular mi_00 and #6?
     
    No.  The MI_xx number is the interface number within the device.  That's
    part of the descriptors and will not change.
     
    **IF** this device had had a serial number, the section "6&edc7182&0&0000"
    would be replaced by the actual serial number of the device, and would not
    change when it was plugged in to a different port.
     
    Really.  I know this.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Tuesday, May 22, 2012 3:10 AM
  • vanselm wrote:
    >
    >I have checked the DevicePaths for different USB ports and found out, that the first part of the path is constant:
    >
    >usb#vid_10f5&pid_0004&mi_00#
    >
    >I have to check yet, whether 2 equal cameras differ in this first part of
    >the ID string.
     
    Do you really have no experience at all with USB?
     
    The VID identifies the manufacturer.  The PID is assigned by the
    manufacturer to identify this type of device.  All instances of a single
    model will use the same PID.
     
    The MI identifies the USB interface number of the Video Class interface
    within this device.  It is a constant for all devices that use the same
    descriptors.
     
    >If it is the case, then it would be sufficient for my pupose to take
    >into account only the first part.
     
    Probably.  HOWEVER, you need to know that the format of that path is not
    documented.  The official recommendation is that you do not rely on
    chopping it into pieces, because the encoding scheme might change at any
    time.  The fact is that it has not changed since it was introduced, but
    Microsoft reserves the right to do so.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Tuesday, May 22, 2012 3:13 AM
  • **IF** this device had had a serial number, the section "6&edc7182&0&0000"
    would be replaced by the actual serial number of the device, and would not

    change when it was plugged in to a different port.

    Great, thanks. So lucky owners of this hardware already have everything settled, and those who have no s/n ask questions like at the top of the topic.


    http://alax.info/blog/tag/directshow

    Tuesday, May 22, 2012 5:36 AM
  • Nope.  "edc7182" is a semi-random number assigned to this particular hub.
    All devices plugged in to this hub without a serial number will have
    6&edc7182 in this spot.
    **IF** this device had had a serial number, the section "6&edc7182&0&0000"
    would be replaced by the actual serial number of the device, and would not
    change when it was plugged in to a different port.

    There we go.

     

    I stand corrected.
    Tuesday, May 22, 2012 1:44 PM
  • Really.  I know this.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.

    The problem is that you appear to be human like the rest of us, and as such you are not always correct. For example in the thread below you claim there is no API (except to use WMI) to get the motherboard’s serial number, when in fact that is what GetSystemFirmwareTable() is all about.

     

    http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/0bb0840e-85f4-4cdb-9710-7581f7348f2f

     

    Tuesday, May 22, 2012 1:56 PM
  • David Miller already exists wrote:
    >
    >The problem is that you appear to be human like the rest of us, and as
    >such you are not always correct. For example in the thread below you
    >claim there is no API (except to use WMI) to get the motherboard’s
    >serial number, when in fact that is what GetSystemFirmwareTable() is
    >all about.
     
    Well, that API wasn't introduced until after XP, which was the last time I
    memorized all of MSDN.  
     
        ;)
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Thursday, May 24, 2012 5:40 AM