Guest User

Untitled

a guest
Jul 22nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. //Create invisible window to hold the capture window.
  2. hwnd = CreateWindowEx(0, _T("webcampcapwindow"), _T(""), 0, 0, 0, 1, 1, HWND_DESKTOP, NULL, GetModuleHandle(NULL), NULL);
  3. if( !hwnd )
  4. throw FatalException( _T("main Capture window create failed"), _T(__FILE__), __LINE__ );
  5.  
  6. //Create capture window.
  7. capHwnd = capCreateCaptureWindow(_T("webcampcapwindowchild"), WS_CHILD, 0, 0, 1, 1, hwnd, 1);
  8. if( !capHwnd )
  9. throw FatalException( _T("secondary Capture window create failed"), _T(__FILE__), __LINE__ );
  10.  
  11. CAPDRIVERCAPS caps;
  12. if(capDriverConnect(capHwnd, 0)) {
  13. connectedtoWc = true;
  14. break;
  15. }
  16.  
  17. if ( !connectedtoWc )
  18. throw FatalException( _T("Could not connect to capture driver."), _T(__FILE__), __LINE__ );
  19.  
  20. //Attach our callback to the capture window.
  21. if( !capSetCallbackOnVideoStream(capHwnd, videoCallback))
  22. throw FatalException( _T("Unable to Attach our callback to the capture window."), _T(__FILE__), __LINE__ );
  23.  
  24. //Make sure we can access this object from the callback.
  25. if(!capSetUserData(capHwnd, this))
  26. throw FatalException( _T("Could not associate user data with capture."), _T(__FILE__), __LINE__ );
  27.  
  28. //Check everything's initialised.
  29. caps.fCaptureInitialized = false;
  30. if( !capDriverGetCaps(capHwnd, &caps, sizeof(CAPDRIVERCAPS)))
  31. throw FatalException( _T("Unable to get driver caps"), _T(__FILE__), __LINE__ );
  32.  
  33. if(!caps.fCaptureInitialized)
  34. throw FatalException( _T("Unable to initialize capture driver"), _T(__FILE__), __LINE__ );
  35.  
  36. if (caps.fHasDlgVideoSource)
  37. capDlgVideoSource(capHwnd);
Add Comment
Please, Sign In to add comment