private async Task SetPreviewRotationAsync() { if (!_externalCamera) { // Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames var rotation = _rotationHelper.GetCameraPreviewOrientation(); var props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview); Guid RotationKey = new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1"); props.Properties.Add(RotationKey, CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(rotation)); await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, null); } }
public async Task SetPreviewRotationAsync() { // Only need to update the orientation if the camera is mounted on the device if (_externalCamera || _rotationHelper == null || m_mediaCapture == null) { return; } // Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames var rotation = _rotationHelper.GetCameraPreviewOrientation(); var props = m_mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview); props.Properties.Add(new Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1"), CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(rotation)); await m_mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, null); }
/// <summary> /// Gets the current orientation of the UI in relation to the device (when AutoRotationPreferences cannot be honored) and applies a corrective rotation to the preview /// </summary> private async Task SetPreviewRotationAsync() { // Only need to update the orientation if the camera is mounted on the device if (_externalCamera) { return; } // Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames var rotation = _rotationHelper.GetCameraPreviewOrientation(); var props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview); props.Properties.Add(RotationKey, CameraRotationHelper.ConvertSimpleOrientationToClockwiseDegrees(rotation)); await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, null); }