/// <summary>
        /// Initializes the scenario
        /// </summary>
        /// <returns></returns>
        private async Task InitializeAsync(CancellationToken cancel = default(CancellationToken))
        {
            var streamFilteringCriteria = new
            {
                //AspectRatio = 1.333333333333333,
                HorizontalResolution = (uint)480,
                SubType = "YUY2"
            };

            currentState = State.Initializing;
            device       = new CaptureDevice();

            CameraPreview.Visibility = Visibility.Collapsed;
            PreviewPoster.Visibility = Visibility.Visible;
            Preview.Content          = "Start Preview";
            LoopbackClient.IsEnabled = false;

            mode = defaultMode;
            LatencyModeToggle.IsOn      = (mode == LatencyMode.LowLatency);
            LatencyModeToggle.IsEnabled = false;

            await device.InitializeAsync();

            var setting = await device.SelectPreferredCameraStreamSettingAsync(MediaStreamType.VideoPreview, ((x) =>
            {
                var previewStreamEncodingProperty = x as Windows.Media.MediaProperties.VideoEncodingProperties;

                return(previewStreamEncodingProperty.Width >= streamFilteringCriteria.HorizontalResolution &&
                       previewStreamEncodingProperty.Subtype == streamFilteringCriteria.SubType);
            }));

            previewEncodingProperties = setting as VideoEncodingProperties;

            PreviewSetupCompleted();
        }
        private async Task InitializeAsync(CancellationToken cancel = default(CancellationToken))
        {
            rootPage.NotifyUser("Initializing...", NotifyType.StatusMessage);

            try
            {
                await device.InitializeAsync();
                await StartRecordToCustomSink();

                HostName.IsEnabled = Call.IsEnabled = true;
                EndCall.IsEnabled  = false;
                RemoteVideo.Source = null;
                RemoteVideo.Height = (RemoteVideo.Parent as Grid).ActualHeight;

                // Each client starts out as passive
                roleIsActive = false;
                Interlocked.Exchange(ref isTerminator, 0);

                rootPage.NotifyUser("Tap 'Call' button to start call", NotifyType.StatusMessage);
            }
            catch (Exception)
            {
                rootPage.NotifyUser("Initialization error. Restart the sample to try again.", NotifyType.ErrorMessage);
            }
        }
Beispiel #3
0
        private async Task readCameraProperties()
        {
            var cameraFound = await CaptureDevice.CheckForRecordingDeviceAsync();

            if (cameraFound)
            {
                device = new CaptureDevice();
                await device.InitializeAsync();

                loadAllVideoProperties();
                await device.CleanUpAsync();

                device = null;
            }
            else
            {
                NotifyUser("A machine with a camera and a microphone is required to run this sample.", NotifyType.ErrorMessage);
            }
        }
Beispiel #4
0
        private async Task <bool> createRecordingObject()
        {
            var cameraFound = await CaptureDevice.CheckForRecordingDeviceAsync();

            if (cameraFound)
            {
                device = new CaptureDevice();
                await device.InitializeAsync();

                device.IncomingConnectionArrived += device_IncomingConnectionArrived;
                device.CaptureFailed             += device_CaptureFailed;
                return(true);
            }
            else
            {
                NotifyUser("A machine with a camera and a microphone is required to run this sample.", NotifyType.ErrorMessage);
                return(false);
            }
        }
        /// <summarycancel
        /// Initializes the scenario
        /// </summary>
        /// <returns></returns>
        private async Task InitializeAsync()
        {
            var streamFilteringCriteria = new
            {
                HorizontalResolution = (uint)480,
                SubType = "YUY2"
            };
            currentState = State.Initializing;
            device = new CaptureDevice();

            PreviewVideo.Visibility = Visibility.Collapsed;
            WebcamPreviewPoster.Visibility = Visibility.Visible;
            PreviewButton.Content = "Start Preview";
            LoopbackClientButton.IsEnabled = false;

            mode = defaultMode;
            LatencyModeToggle.IsOn = (mode == LatencyMode.LowLatency);
            LatencyModeToggle.IsEnabled = false;

            await device.InitializeAsync();
            var setting = await device.SelectPreferredCameraStreamSettingAsync(MediaStreamType.VideoPreview, ((x) =>
            {
                var previewStreamEncodingProperty = x as Windows.Media.MediaProperties.VideoEncodingProperties;

                return (previewStreamEncodingProperty.Width >= streamFilteringCriteria.HorizontalResolution &&
                    previewStreamEncodingProperty.Subtype == streamFilteringCriteria.SubType);
            }));

            previewEncodingProperties = setting as VideoEncodingProperties;

            PreviewSetupCompleted();
        }