pkg/driver/camera/camera_windows.cpp
// selectCamera stores pointer to the selected device IMoniker* according to the configs in camera*.
selectCamera stores pointer to the selected device IMoniker* according to the configs in camera*.
selectCamera stores pointer to the selected device IMoniker * according to the configs in camera * .
int selectCamera(camera* cam, IMoniker** monikerSelected, const char** errstr)
{
  ICreateDevEnum* sysDevEnum = nullptr;
  IEnumMoniker* enumMon = nullptr;
  if (FAILED(CoCreateInstance(
          CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC,
          IID_ICreateDevEnum, (void**)&sysDevEnum)))
  {
    *errstr = errEnumDevice;
    goto fail;
  }
  if (FAILED(sysDevEnum->CreateClassEnumerator(
          CLSID_VideoInputDeviceCategory, &enumMon, 0)))
  {
    *errstr = errEnumDevice;
    goto fail;
  }
  safeRelease(&sysDevEnum);
  {
    IMoniker* moniker;
    while (enumMon->Next(1, &moniker, nullptr) == S_OK)
    {
      char* name = getCameraName(moniker);
      if (strcmp(cam->name, name) != 0)
      {
        free(name);
        safeRelease(&moniker);
        continue;
      }
      free(name);
      *monikerSelected = moniker;
      safeRelease(&enumMon);
      return 1;
    }
  }
  safeRelease(&enumMon);
  return 0;
fail:
  safeRelease(&sysDevEnum);
  safeRelease(&enumMon);
  return 1;
}
int selectCamera ( camera * cam , IMoniker * * monikerSelected , const char * * errstr ) { ICreateDevEnum * sysDevEnum = nullptr ; IEnumMoniker * enumMon = nullptr ; if ( FAILED ( CoCreateInstance ( CLSID_SystemDeviceEnum , nullptr , CLSCTX_INPROC , IID_ICreateDevEnum , ( void * * ) & sysDevEnum ) ) ) { * errstr = errEnumDevice ; goto fail ; } if ( FAILED ( sysDevEnum -> CreateClassEnumerator ( CLSID_VideoInputDeviceCategory , & enumMon , 0 ) ) ) { * errstr = errEnumDevice ; goto fail ; } safeRelease ( & sysDevEnum ) ; { IMoniker * moniker ; while ( enumMon -> Next ( 1 , & moniker , nullptr ) == S_OK ) { char * name = getCameraName ( moniker ) ; if ( strcmp ( cam -> name , name ) != 0 ) { free ( name ) ; safeRelease ( & moniker ) ; continue ; } free ( name ) ; * monikerSelected = moniker ; safeRelease ( & enumMon ) ; return 1 ; } } safeRelease ( & enumMon ) ; return 0 ; fail : safeRelease ( & sysDevEnum ) ; safeRelease ( & enumMon ) ; return 1 ; }
selectCamera stores pointer to the selected device IMoniker* according to the configs in camera*.
selectCamera stores pointer to the selected device IMoniker * according to the configs in camera * .