示例#1
0
        // Implementation of a video capture callback
        public static int CommonCaptureCallback
        (
            IntPtr hwnd,
            ref VIDEOHDR videoHdr
        )
        {
            // Attempt to find an instance of STVideoCapture with the specified hwnd.
            // If found, call it's delegate.
            foreach (STVideoCapture videoCapture in STVideoCapture.mListOfActiveInstances)
            {
                if (videoCapture.mHWNDCapture == hwnd)
                {
                    return(videoCapture.InstanceCaptureCallback(hwnd, ref videoHdr));
                }
            }

            return(0);
        }
示例#2
0
        /// <summary>
        /// 捕获视频事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="hdr"></param>
        private void vc_VideoCaptured(object sender, VIDEOHDR hdr)
        {
            try
            {
                byte[] data = new byte[hdr.dwBytesUsed];
                Marshal.Copy(hdr.lpData, data, 0, hdr.dwBytesUsed);

                this.drawDib.Draw(data, this.controlVideo);

                if (this.VideoDataCapturered != null)
                {
                    this.VideoDataCapturered(this, new VideoCapturedEventArgs(this.bitmapInfo, data));
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message + ":" + ex.StackTrace);
            }
        }
示例#3
0
        /// <summary>
        /// 捕获视频事件 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="hdr"></param>
        private void vc_VideoCaptured(object sender,VIDEOHDR hdr)
        {
            try
            {
                byte[] data = new byte[hdr.dwBytesUsed];
                Marshal.Copy(hdr.lpData, data, 0, hdr.dwBytesUsed);

                this.drawDib.Draw(data, this.controlVideo);

                if (this.VideoDataCapturered != null)
                    this.VideoDataCapturered(this, new VideoCapturedEventArgs(this.bitmapInfo, data));

            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message + ":" + ex.StackTrace);
            }
        }
示例#4
0
        public int InstanceCaptureCallback
        (
            IntPtr hwnd,
            ref VIDEOHDR videoHdr
        )
        {
            if (null == mClientCaptureCallback)
            {
                return(0);
            }


            // Copy image data to local buffer before calling client
            int captureWidth  = 0;
            int captureHeight = 0;

            captureWidth  = this.GetCaptureWidth( );
            captureHeight = this.GetCaptureHeight( );


            int sourceStrideBytes              = 0;
            int sourceCopyStartByteOffset      = 0;
            int destinationStrideBytes         = 0;
            int destinationCopyStartByteOffset = 0;
            int bytesToCopyPerLine             = 0;

            sourceCopyStartByteOffset      = 0;
            sourceStrideBytes              = (captureWidth * 3);
            destinationCopyStartByteOffset = 0;
            destinationStrideBytes         = (captureWidth * 3);
            bytesToCopyPerLine             = (captureWidth * 3);



            int lineIndex = 0;

            for (lineIndex = 0; lineIndex < captureHeight; lineIndex++)
            {
                IntPtr sourceLineStartPtr =
                    new IntPtr(videoHdr.lpData.ToInt32( ) + sourceCopyStartByteOffset);

                System.Runtime.InteropServices.Marshal.Copy
                (
                    sourceLineStartPtr,
                    this.mBGRData,
                    destinationCopyStartByteOffset,
                    bytesToCopyPerLine
                );

                sourceCopyStartByteOffset      += sourceStrideBytes;
                destinationCopyStartByteOffset += destinationStrideBytes;
            }


            // Call the client
            mClientCaptureCallback
            (
                this.mBGRData,
                this.GetCaptureWidth(),
                this.GetCaptureHeight()
            );

            return(0);
        }
示例#5
0
 private int CallbackVideoStream(IntPtr hwnd, VIDEOHDR lpVHdr)
 {
     iFrame++;
     Marshal.Copy(lpVHdr.lpData, PictureData, 0, lpVHdr.dwBytesUsed);
     return(0);
 }