public void EnumVideoFormats()
        {
            PeerConnection.GetVideoCaptureDevicesAsync().ContinueWith((enumDeviceTask) =>
            {
                Assert.IsNull(enumDeviceTask.Exception);
                List <VideoCaptureDevice> devices = enumDeviceTask.Result;
                if (devices.Count == 0)
                {
                    Assert.Inconclusive("Host device has no available video capture device.");
                }

                foreach (var device in devices)
                {
                    PeerConnection.GetVideoCaptureFormatsAsync(device.id).ContinueWith((enumFormatTask) =>
                    {
                        Assert.IsNull(enumFormatTask.Exception);
                        List <VideoCaptureFormat> formats = enumFormatTask.Result;
                        foreach (var format in formats)
                        {
                            Assert.That(format.width, Is.GreaterThan(0));
                            Assert.That(format.height, Is.GreaterThan(0));
                            Assert.That(format.framerate, Is.GreaterThan(0.0));
                        }
                    });
                }
            });
        }
        public async Task RefreshVideoCaptureFormatsAsync(VideoCaptureDeviceInfo item)
        {
            var formats = new CollectionViewModel <VideoCaptureFormatViewModel>();

            if (item != null)
            {
                if (MediaCapture.IsVideoProfileSupported(item.Id))
                {
                    foreach (var desc in VideoProfiles.SelectedItem?.SupportedRecordMediaDescription)
                    {
                        var formatVM = new VideoCaptureFormatViewModel();
                        formatVM.Format.width     = desc.Width;
                        formatVM.Format.height    = desc.Height;
                        formatVM.Format.framerate = desc.FrameRate;
                        //formatVM.Format.fourcc = desc.Subtype; // TODO: string => FOURCC
                        formatVM.FormatEncodingDisplayName = desc.Subtype;
                        formats.Add(formatVM);
                    }
                }
                else
                {
                    // Device doesn't support video profiles; fall back on flat list of capture formats.
                    List <VideoCaptureFormat> formatsList = await PeerConnection.GetVideoCaptureFormatsAsync(item.Id);

                    foreach (var format in formatsList)
                    {
                        formats.Add(new VideoCaptureFormatViewModel
                        {
                            Format = format,
                            FormatEncodingDisplayName = FourCCToString(format.fourcc)
                        });
                    }
                }
            }
            VideoCaptureFormats = formats;

            // Select first item for convenience
            VideoCaptureFormats.SelectFirstItemIfAny();
        }