Beispiel #1
0
 private void InitializeCaptureSource()
 {
     if (mCaptureSource == null)
     {
         // Setup the capture source (for recording audio)
         mCaptureSource = new CaptureSource {
             VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()
         };
         if (mCaptureSource.VideoCaptureDevice != null)
         {
             MediaDeviceConfig.SelectBestVideoFormat(mCaptureSource.VideoCaptureDevice);
             if (mCaptureSource.AudioCaptureDevice.DesiredFormat != null)
             {
                 mCaptureSource.AudioCaptureDevice.AudioFrameSize = AudioConstants.MillisecondsPerFrame;                         // 20 milliseconds
                 mVideoSink = new VideoSinkAdapter(mCaptureSource, mRecorder, mVideoQualityController);
                 ClientLogger.Debug("CaptureSource initialized.");
             }
             else
             {
                 ClientLogger.Debug("No suitable audio format was found.");
             }
             panelWebcam.DataContext = mCaptureSource;
         }
         else
         {
             // Do something more here eventually, once we figure out what the user experience should be.
             ClientLogger.Debug("No audio capture device was found.");
         }
     }
 }
Beispiel #2
0
        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            btnSaveRaw.IsEnabled = false;
            btnPlayRaw.IsEnabled = false;

            videoCapture.Height           = VideoConstants.Height;
            videoCapture.Width            = VideoConstants.Width;
            mRawMediaElement.Height       = VideoConstants.Height;
            mRawMediaElement.Width        = VideoConstants.Width;
            mProcessedMediaElement.Height = VideoConstants.Height;
            mProcessedMediaElement.Width  = VideoConstants.Width;

            // Initialize and capture the webcam.
            InitializeCaptureSource();
            CaptureSelectedInputDevices();
            var videoBrush = new VideoBrush();

            videoBrush.SetSource(mCaptureSource);
            videoCapture.Fill = videoBrush;

            // Setup the recorder
            mVideoQualityController = new TestVideoQualityController();
            mRecorder  = new Recorder();
            mVideoSink = new VideoSinkAdapter(mCaptureSource, mRecorder, mVideoQualityController);
            lblFramesRecorded.DataContext = mRecorder;
        }