Example #1
0
        public async Task RefreshVideoCaptureFormatsAsync(VideoCaptureDeviceInfo item)
        {
            var formats = new CollectionViewModel <VideoCaptureFormatViewModel>();

            if (item != null)
            {
                IReadOnlyList <VideoCaptureFormat> formatsList;
                string profileId = VideoProfiles.SelectedItem?.uniqueId;
                if (string.IsNullOrEmpty(profileId))
                {
                    // Device doesn't support video profiles; fall back on flat list of capture formats.
                    formatsList = await DeviceVideoTrackSource.GetCaptureFormatsAsync(item.Id);
                }
                else
                {
                    // Enumerate formats for the specified profile only
                    formatsList = await DeviceVideoTrackSource.GetCaptureFormatsAsync(item.Id, profileId);
                }
                foreach (var format in formatsList)
                {
                    formats.Add(new VideoCaptureFormatViewModel
                    {
                        Format = format,
                        FormatEncodingDisplayName = FourCCToString(format.fourcc)
                    });
                }
            }
            VideoCaptureFormats = formats;

            // Select first item for convenience
            VideoCaptureFormats.SelectFirstItemIfAny();
        }
        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();
        }