modules/video_capture/windows/device_info_ds.cc
void DeviceInfoDS::GetProductId(const char* devicePath,
                                      char* productUniqueIdUTF8,
                                      uint32_t productUniqueIdUTF8Length)
{
    *productUniqueIdUTF8 = '\0';
    char* startPos = strstr((char*) devicePath, "\\\\?\\");
    if (!startPos)
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);
        WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                     "Failed to get the product Id");
        return;
    }
    startPos += 4;

    char* pos = strchr(startPos, '&');
    if (!pos || pos >= (char*) devicePath + strlen((char*) devicePath))
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);
        WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                     "Failed to get the product Id");
        return;
    }
    // Find the second occurrence.
    pos = strchr(pos + 1, '&');
    uint32_t bytesToCopy = (uint32_t)(pos - startPos);
    if (pos && (bytesToCopy <= productUniqueIdUTF8Length) && bytesToCopy
        <= kVideoCaptureProductIdLength)
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length,
                  (char*) startPos, bytesToCopy);
    }
    else
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);
        WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                     "Failed to get the product Id");
    }
}
/* Constructs a product ID from the Windows DevicePath. on a USB device the devicePath contains product id and vendor id.
 This seems to work for firewire as well
 /* Example of device path
 "\\?\usb#vid_0408&pid_2010&mi_00#7&258e7aaf&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
 "\\?\avc#sony&dv-vcr&camcorder&dv#65b2d50301460008#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
 */
Constructs a product ID from the Windows DevicePath. on a USB device the devicePath contains product id and vendor id.
Constructs a product ID from the Windows DevicePath . on a USB device the devicePath contains product id and vendor id .
void DeviceInfoDS::GetProductId(const char* devicePath,
                                      char* productUniqueIdUTF8,
                                      uint32_t productUniqueIdUTF8Length)
{
    *productUniqueIdUTF8 = '\0';
    char* startPos = strstr((char*) devicePath, "\\\\?\\");
    if (!startPos)
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);
        WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                     "Failed to get the product Id");
        return;
    }
    startPos += 4;
    char* pos = strchr(startPos, '&');
    if (!pos || pos >= (char*) devicePath + strlen((char*) devicePath))
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);
        WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                     "Failed to get the product Id");
        return;
    }
    pos = strchr(pos + 1, '&');
    uint32_t bytesToCopy = (uint32_t)(pos - startPos);
    if (pos && (bytesToCopy <= productUniqueIdUTF8Length) && bytesToCopy
        <= kVideoCaptureProductIdLength)
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length,
                  (char*) startPos, bytesToCopy);
    }
    else
    {
        strncpy_s((char*) productUniqueIdUTF8, productUniqueIdUTF8Length, "", 1);
        WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideoCapture, -1,
                     "Failed to get the product Id");
    }
}
void DeviceInfoDS :: GetProductId ( const char * devicePath , char * productUniqueIdUTF8 , uint32_t productUniqueIdUTF8Length ) { * productUniqueIdUTF8 = ' \0 ' ; char * startPos = strstr ( ( char * ) devicePath , " \\ \\ \\ " ) ; if ( ! startPos ) { strncpy_s ( ( char * ) productUniqueIdUTF8 , productUniqueIdUTF8Length , " " , 1 ) ; WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceVideoCapture , -1 , " " ) ; return ; } startPos += 4 ; char * pos = strchr ( startPos , ' ' ) ; if ( ! pos || pos >= ( char * ) devicePath + strlen ( ( char * ) devicePath ) ) { strncpy_s ( ( char * ) productUniqueIdUTF8 , productUniqueIdUTF8Length , " " , 1 ) ; WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceVideoCapture , -1 , " " ) ; return ; } pos = strchr ( pos + 1 , ' ' ) ; uint32_t bytesToCopy = ( uint32_t ) ( pos - startPos ) ; if ( pos && ( bytesToCopy <= productUniqueIdUTF8Length ) && bytesToCopy <= kVideoCaptureProductIdLength ) { strncpy_s ( ( char * ) productUniqueIdUTF8 , productUniqueIdUTF8Length , ( char * ) startPos , bytesToCopy ) ; } else { strncpy_s ( ( char * ) productUniqueIdUTF8 , productUniqueIdUTF8Length , " " , 1 ) ; WEBRTC_TRACE ( webrtc :: kTraceError , webrtc :: kTraceVideoCapture , -1 , " " ) ; } }
Constructs a product ID from the Windows DevicePath.
Constructs a product ID from the Windows DevicePath .
// Find the second occurrence.