StartPreviewToCustomSinkAsync() private method

private StartPreviewToCustomSinkAsync ( [ encodingProfile, [ customMediaSink ) : IAsyncAction
encodingProfile [
customMediaSink [
return IAsyncAction
        public async void StartPreview()
        {
            var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

            var deviceInfo = devices[0]; //grab first result
            DeviceInformation rearCamera = null;

            foreach (var device in devices)
            {
                if (device.Name.ToLowerInvariant().Contains("front"))
                {
                    DeviceInformation frontCamera;
                    deviceInfo = frontCamera = device;
                    var hasFrontCamera = true;
                }
                if (device.Name.ToLowerInvariant().Contains("back"))
                {
                    rearCamera = device;
                }
            }

            var mediaSettings = new MediaCaptureInitializationSettings
            {
                MediaCategory        = MediaCategory.Communications,
                StreamingCaptureMode = StreamingCaptureMode.AudioAndVideo,
                VideoDeviceId        = rearCamera.Id
            };

            var mediaCaptureManager = new Windows.Media.Capture.MediaCapture();
            await mediaCaptureManager.InitializeAsync(mediaSettings);

            var previewSink = new Windows.Phone.Media.Capture.MediaCapturePreviewSink();

            // List of supported video preview formats to be used by the default preview format selector.
            var supportedVideoFormats = new List <string> {
                "nv12", "rgb32"
            };

            // Find the supported preview format
            var availableMediaStreamProperties =
                mediaCaptureManager.VideoDeviceController.GetAvailableMediaStreamProperties(
                    Windows.Media.Capture.MediaStreamType.VideoPreview)
                .OfType <Windows.Media.MediaProperties.VideoEncodingProperties>()
                .Where(p => p != null &&
                       !String.IsNullOrEmpty(p.Subtype) &&
                       supportedVideoFormats.Contains(p.Subtype.ToLower()))
                .ToList();
            var previewFormat = availableMediaStreamProperties.FirstOrDefault();

            foreach (var property in availableMediaStreamProperties)
            {
                if (previewFormat.Width < property.Width)
                {
                    previewFormat = property;
                }
            }
            //previewFormat.Width = 480;
            //previewFormat.Height = 480;
            // Start Preview stream
            await mediaCaptureManager.VideoDeviceController.SetMediaStreamPropertiesAsync(Windows.Media.Capture.MediaStreamType.VideoPreview, previewFormat);

            await mediaCaptureManager.StartPreviewToCustomSinkAsync(new Windows.Media.MediaProperties.MediaEncodingProfile {
                Video = previewFormat
            }, previewSink);

            var viewfinderBrush = new VideoBrush {
                Stretch = Stretch.Uniform
            };

            // Set the source of the VideoBrush used for your preview
            Microsoft.Devices.CameraVideoBrushExtensions.SetSource(viewfinderBrush, previewSink);
            CameraPreview.Background = viewfinderBrush;


            mediaCaptureManager.SetPreviewRotation(VideoRotation.Clockwise90Degrees);
        }