Esempio n. 1
0
        public async Task InitialiseAsync(
            Func <IEnumerable <MediaFrameSourceInfo>, MediaFrameSourceInfo> sourceInfoSelector,
            FilterSet filterChain = null)
        {
            // Get all the media frame source groups.
            var mediaFrameSourceGroups = await MediaFrameSourceGroup.FindAllAsync();

            // Flatten all this data out so that we have access to the groups, the source infos and the
            // video profiles.
            var mediaSourceInfos = mediaFrameSourceGroups
                                   .SelectMany(
                group => group.SourceInfos
                )
                                   .SelectMany(
                sourceInfo => sourceInfo.VideoProfileMediaDescription,
                (sourceInfo, videoProfileDescriptions) =>
                new
            {
                MediaFrameSourceInfo    = sourceInfo,
                VideoProfileDescription = videoProfileDescriptions
            }
                );

            // Find the ones which match our device & which satisfy all of the media frame source info
            // filters && all of the video device profile filters.
            var filteredSourceInfos = mediaSourceInfos
                                      .Where(
                entry => (
                    (entry.MediaFrameSourceInfo.DeviceInformation.Id == this.deviceFinder.Device.Id) &&
                    (filterChain == null || filterChain.All(entry.MediaFrameSourceInfo)) &&
                    (filterChain == null || filterChain.All(entry.VideoProfileDescription))));

            this.mediaFrameSourceInfo =
                sourceInfoSelector(filteredSourceInfos.Select(si => si.MediaFrameSourceInfo));
        }