private void UIColorModeControlButton_Click(object sender, RoutedEventArgs e) { var modes = Enum.GetValues(typeof(ColorModeKind)); m_colorMode = (m_colorMode + 1) % modes.Length; CameraKsPropertyInquiry.SetCustomControlFlags(CustomControlKind.ColorMode, m_mediaCapture.VideoDeviceController, (uint)((int)modes.GetValue(m_colorMode))); }
/// <summary> /// Initialize the view of the virtual camera and configure available interactions /// </summary> /// <returns></returns> public async Task InitializeAsync() { m_mediaCapture = new MediaCapture(); m_mediaPlayer = new MediaPlayer(); // We initialize the MediaCapture instance with the virtual camera in sharing mode // to preview its stream without blocking other app from using it var initSettings = new MediaCaptureInitializationSettings() { SharingMode = MediaCaptureSharingMode.SharedReadOnly, VideoDeviceId = VirtualCameraProxyInst.SymbolicLink, StreamingCaptureMode = StreamingCaptureMode.Video }; await m_mediaCapture.InitializeAsync(initSettings); // Retrieve the source associated with the video preview stream. // On 1-pin camera, this may be the VideoRecord MediaStreamType as opposed to VideoPreview on multi-pin camera var frameSource = m_mediaCapture.FrameSources.FirstOrDefault(source => source.Value.Info.MediaStreamType == MediaStreamType.VideoPreview && source.Value.Info.SourceKind == MediaFrameSourceKind.Color).Value; if (frameSource == null) { frameSource = m_mediaCapture.FrameSources.FirstOrDefault(source => source.Value.Info.MediaStreamType == MediaStreamType.VideoRecord && source.Value.Info.SourceKind == MediaFrameSourceKind.Color).Value; } // if no preview stream is available, bail if (frameSource == null) { return; } // Setup MediaPlayer with the preview source m_mediaPlayer.RealTimePlayback = true; m_mediaPlayer.AutoPlay = true; m_mediaPlayer.Source = MediaSource.CreateFromMediaFrameSource(frameSource); UIMediaPlayerElement.SetMediaPlayer(m_mediaPlayer); // Query support of custom and standard KSProperty and update UI toggle buttons accordingly bool isColorModeSupported = (null != CameraKsPropertyInquiry.GetCustomControl(CustomControlKind.ColorMode, m_mediaCapture.VideoDeviceController)); bool isEyeGazeCorrectionSupported = (null != CameraKsPropertyInquiry.GetExtendedControl(ExtendedControlKind.EyeGazeCorrection, m_mediaCapture.VideoDeviceController)); UIColorModeControlButton.IsEnabled = isColorModeSupported; UIEyeGazeControlButton.IsEnabled = isEyeGazeCorrectionSupported; }
private void UIEyeGazeControlButton_Click(object sender, RoutedEventArgs e) { m_eyeGazeMode = !m_eyeGazeMode; CameraKsPropertyInquiry.SetExtendedControlFlags(ExtendedControlKind.EyeGazeCorrection, m_mediaCapture.VideoDeviceController, (uint)(m_eyeGazeMode == true ? 1 : 0)); }