예제 #1
0
파일: AviCap.cs 프로젝트: ricksam/Framework
        public VideoSource[] GetVideoSource()
        {
            List <VideoSource> lst = new List <VideoSource>();

            int  index    = 0;
            bool IsDevice = true;

            do
            {
                string vName    = "".PadLeft(80, ' ');
                string vVersion = "".PadLeft(80, ' ');
                IsDevice = AVICAP32.capGetDriverDescriptionA(index, ref vName, 80, ref vVersion, 80);

                if (IsDevice)
                {
                    lst.Add(new VideoSource(vName, vVersion));
                }

                index++;
            }while (IsDevice);

            return(lst.ToArray());
        }
예제 #2
0
파일: AviCap.cs 프로젝트: ricksam/Framework
        /// <summary>
        /// Status de conexão da câmera
        /// </summary>
        //public bool Connected { get; set; }
        #endregion

        #region Start
        /// <summary>
        /// Starts the video capture
        /// </summary>
        /// <param name="FrameNumber">the frame number to start at.
        /// Set to 0 to let the control allocate the frame number</param>
        public override void Start()
        {
            #region for safety, call stop, just in case we are already running
            this.Stop();
            #endregion

            #region setup a capture window
            int Flags = 0;
            if (!this.UseClipboard)
            {
                Flags = IMAGECAPTURE.WS_VISIBLE | IMAGECAPTURE.WS_CHILD;
            }


            mCapHwnd = AVICAP32.capCreateCaptureWindowA("WebCap",
                                                        Flags, 0, 0,
                                                        this.Width,
                                                        this.Height,
                                                        this.Control.Handle,
                                                        0
                                                        );
            #endregion

            #region connect to the capture device
            Application.DoEvents();

            USER32.SendMessage(mCapHwnd, IMAGECAPTURE.WM_CAP_DRIVER_CONNECT, DriverIndex, 0);
            USER32.SendMessage(mCapHwnd, IMAGECAPTURE.WM_CAP_SET_PREVIEWRATE, 66, 0); //66
            USER32.SendMessage(mCapHwnd, IMAGECAPTURE.WM_CAP_SET_PREVIEW, 1, 0);

            //USER32.SendMessage(mCapHwnd, IMAGECAPTURE.WM_CAP_DLG_VIDEOSOURCE, 0, 0);
            //GetMCIDevice mci = new GetMCIDevice();
            //int i =USER32.SendMessage(mCapHwnd, IMAGECAPTURE.WM_CAP_GET_MCI_DEVICE, Marshal.SizeOf(mci), mci);

            BITMAPINFO bInfo = new BITMAPINFO();
            bInfo.bmiHeader            = new BITMAPINFOHEADER();
            bInfo.bmiHeader.biSize     = (uint)Marshal.SizeOf(bInfo.bmiHeader);
            bInfo.bmiHeader.biWidth    = Width;
            bInfo.bmiHeader.biHeight   = Height;
            bInfo.bmiHeader.biPlanes   = 1;
            bInfo.bmiHeader.biBitCount = 24; // bits per frame, 24 - RGB
            USER32.SendBitmapMessage(mCapHwnd, IMAGECAPTURE.WM_CAP_SET_VIDEOFORMAT, Marshal.SizeOf(bInfo), ref bInfo);


            CAPTUREPARMS CaptureParams = new CAPTUREPARMS();
            CaptureParams.fYield                    = 1;
            CaptureParams.fAbortLeftMouse           = 0;
            CaptureParams.fAbortRightMouse          = 0;
            CaptureParams.dwRequestMicroSecPerFrame = 66667;
            CaptureParams.fMakeUserHitOKToCapture   = 0;
            CaptureParams.wPercentDropForError      = 10;//10
            CaptureParams.wChunkGranularity         = 0;
            CaptureParams.dwIndexSize               = 324000;
            CaptureParams.wNumVideoRequested        = 10;
            CaptureParams.wNumAudioRequested        = 10;
            CaptureParams.fCaptureAudio             = 1;
            CaptureParams.fMCIControl               = 0; //0
            CaptureParams.fStepMCIDevice            = 0; //0
            CaptureParams.dwMCIStartTime            = 0;
            CaptureParams.dwMCIStopTime             = 0;
            CaptureParams.fStepCaptureAt2x          = 0;//0
            CaptureParams.wStepCaptureAverageFrames = 5;
            CaptureParams.dwAudioBufferSize         = 10;
            USER32.SendMessageA(mCapHwnd, IMAGECAPTURE.WM_CAP_SET_SEQUENCE_SETUP, new IntPtr(Marshal.SizeOf(CaptureParams)), CaptureParams);
            //ConfigFormat();
            #endregion

            #region set the timer information
            this.Tmr.Interval = TimeToCapture;
            if (this.UseClipboard)
            {
                this.Tmr.Start();
            }
            #endregion

            base.Start();
        }