Esempio n. 1
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Turn off device notifications
            if (m_rdn != null)
            {
                m_rdn.Dispose();
                m_rdn = null;
            }

            // End any active captures
            if (m_pCapture != null)
            {
                m_pCapture.EndCaptureSession();
                m_pCapture = null;
            }

            // Shut down MF
            MFExtern.MFShutdown();
        }
Esempio n. 2
0
        private void StopCapture()
        {
            HResult hr = 0;

            if (m_pCapture != null)
            {
                hr = m_pCapture.EndCaptureSession();
            }

            m_pCapture = null;

            UpdateDeviceList();

            UpdateUI();

            if (hr < 0)
            {
                NotifyError("Error stopping capture. File might be corrupt.", hr);
            }
        }
Esempio n. 3
0
        private void StartCapture()
        {
            CCapture.EncodingParameters eparams;

            if (rbWMV.Checked)
            {
                eparams.subtype = MFMediaType.WMV3;
            }
            else
            {
                eparams.subtype = MFMediaType.H264;
            }

            eparams.bitrate = TARGET_BIT_RATE;

            HResult hr = 0;

            IMFActivate pActivate = null;

            // Create the media source for the capture device.

            hr = GetSelectedDevice(out pActivate);

            // Start capturing.

            if (hr >= 0)
            {
                m_pCapture = new CCapture(this.Handle, WM_APP_PREVIEW_ERROR);
                hr         = m_pCapture.StartCapture(pActivate, tbOutputFile.Text, eparams);
            }

            if (hr >= 0)
            {
                UpdateUI();
            }

            if (hr < 0)
            {
                NotifyError("Error starting capture.", hr);
            }
        }
Esempio n. 4
0
        private void StopCapture()
        {
            int hr = 0;

            if (m_pCapture != null)
            {
                hr = m_pCapture.EndCaptureSession();
            }

            m_pCapture = null;

            UpdateDeviceList();

            UpdateUI();

            if (hr < 0)
            {
                NotifyError("Error stopping capture. File might be corrupt.", hr);
            }
        }
Esempio n. 5
0
        private void StartCapture()
        {
            CCapture.EncodingParameters eparams;

            if (rbWMV.Checked)
            {
                eparams.subtype = MFMediaType.WMV3;
            }
            else
            {
                eparams.subtype = MFMediaType.H264;
            }

            eparams.bitrate = TARGET_BIT_RATE;

            int hr = 0;

            IMFActivate pActivate = null;

            // Create the media source for the capture device.

            hr = GetSelectedDevice(out pActivate);

            // Start capturing.

            if (hr >= 0)
            {
                m_pCapture = new CCapture(this.Handle, WM_APP_PREVIEW_ERROR);
                hr = m_pCapture.StartCapture(pActivate, tbOutputFile.Text, eparams);
            }

            if (hr >= 0)
            {
                UpdateUI();
            }

            if (hr < 0)
            {
                NotifyError("Error starting capture.", hr);
            }
        }
Esempio n. 6
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Turn off device notifications
            if (m_rdn != null)
            {
                m_rdn.Dispose();
                m_rdn = null;
            }

            // End any active captures
            if (m_pCapture != null)
            {
                m_pCapture.EndCaptureSession();
                m_pCapture = null;
            }

            // Shut down MF
            MFExtern.MFShutdown();
        }