public static extern int SendMessageW([In] IntPtr hWnd, int Msg, uint wParam, ref CAPTUREPARMS waveFormat);
/// <summary> /// We can configure some settings related to capturing images from /// the camera. Primarily we want to control how many buffers are /// used in the capture process. /// /// If we are doing continuous capture, we can configure /// the interval between subsequent frames. /// </summary> public override void ConfigureCapture() { fCaptureParams = new CAPTUREPARMS(); capCaptureGetSetup(ref fCaptureParams); // These are the core parameters that must be // set when we're capturing video fCaptureParams.dwRequestMicroSecPerFrame = (uint)CaptureInterval; // Start with 15 frames per second fCaptureParams.wPercentDropForError = 10; // Percentage of frames that can drop before error is signaled fCaptureParams.fYield = true; // If set to true, a thread will be spawned fCaptureParams.wNumVideoRequested = 2; // Maximum number of video buffers to allocate // Related to capturing audio fCaptureParams.fCaptureAudio = false; fCaptureParams.wNumAudioRequested = 0; fCaptureParams.dwAudioBufferSize = 0; fCaptureParams.fLimitEnabled = false; fCaptureParams.wTimeLimit = 0; fCaptureParams.fDisableWriteCache=false; fCaptureParams.AVStreamMaster=0; // Used when capturing to a file fCaptureParams.dwIndexSize = 0; // Determines the limit of audio/video buffers that can be captured fCaptureParams.wChunkGranularity = 0; // Related to MCI fCaptureParams.fMCIControl = false; fCaptureParams.fStepMCIDevice = false; fCaptureParams.dwMCIStartTime = 0; fCaptureParams.dwMCIStopTime = 0; fCaptureParams.fStepCaptureAt2x = false; fCaptureParams.wStepCaptureAverageFrames = 5; // These are related to mouse and keyboard control of capturing // Since we want total control of the capture process // we don't want these used at all. fCaptureParams.vKeyAbort = 0; fCaptureParams.fAbortLeftMouse = false; fCaptureParams.fAbortRightMouse = false; fCaptureParams.fMakeUserHitOKToCapture = false; fCaptureParams.fUsingDOSMemory = false; // Configure the actual capture settings capCaptureSetSetup(ref fCaptureParams); }
protected bool capCaptureSetSetup(ref CAPTUREPARMS s) { uint wSize = (uint)Marshal.SizeOf(s); return 1 == SendMessageW(fWindowHandle, Vfw.WM_CAP_SET_SEQUENCE_SETUP, wSize, ref s); }