//フレームキャプチャ完了時に呼び出されるコールバック関数
        int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLength)
        {
            // コールバックの処理中なら終了
            if (mProcessing)
            {
                return(0);
            }

            mProcessing = true;

            // 1. キャプチャするフレームデータのサイズを設定する.
            int size = mVideoInfoHeader.BmiHeader.ImageSize;

            mFrameArray = new byte [size + 64000];

            //メモリ内のサンプリングされたデータ(pBuffer)を配列(frameArray)にコピーする.
            if ((pBuffer != IntPtr.Zero) && (BufferLength > 1000) && (BufferLength <= mFrameArray.Length))
            {
                Marshal.Copy(pBuffer, mFrameArray, 0, BufferLength);
            }

            try
            {
                //CaptureDoneデリゲードを呼び出す.
                mForm1.BeginInvoke(new CaptureDone(this.OnCaptureDone), new object[] { SampleTime });
            }
            catch (Exception e)
            {
                SMMMessageBox.Show("エラー:映像データのサンプリング完了時の処理に失敗しました。Error: Failed to process when complete sampling of video data." + e.ToString(), SMMMessageBoxIcon.Error);
            }
            return(0);
        }
示例#2
0
        //フレームキャプチャ完了時に呼び出されるコールバック関数
        int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLength)
        {
            // コールバックの処理中なら終了
            if (mProcessing)
            {
                return(0);
            }

            mProcessing = true;

            mFrameArray = new byte[mAudioInfoHeader.nAvgBytesPerSec / 100];

            // メモリ内のサンプリングされたデータ(pBuffer)を配列(frameArray)にコピーする.
            if ((pBuffer != IntPtr.Zero) && (BufferLength <= mFrameArray.Length))
            {
                Marshal.Copy(pBuffer, mFrameArray, 0, BufferLength);
            }

            //Console.WriteLine("SampleTime:" + SampleTime);
            //Console.WriteLine("BufferLength:" + BufferLength);

            try {
                // CaptureDoneデリゲードを呼び出す.
                mForm1.BeginInvoke(new CaptureDone(this.OnCaptureDone), new object[] { SampleTime, BufferLength });
            } catch (Exception e) {
                SMMMessageBox.Show("エラー:音声データのサンプリング完了時の処理に失敗しました。Error: Failed to process when complete sampling of audio data." + e.ToString(), SMMMessageBoxIcon.Error);
            }

            return(0);
        }