public static string ToFormattedString()

in SharedContent/cs/Logging/Extensions/MediaPlaybackItemStringExtensions.cs [41:143]


        public static string ToFormattedString(this MediaPlaybackItem item)
        {
            if (item == null)
                return String.Empty;

            StringBuilder sb = new StringBuilder();

            // MediaPlaybackItem.Source.CustomProperties
            var source = item.Source;
            if (source != null && source.CustomProperties.Any())
            {
                sb.AppendLine();
                sb.AppendLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
                sb.AppendLine("Source.CustomProperties:");
                foreach (var prop in source.CustomProperties)
                {
                    sb.AppendLine(prop.Key + ":\t" + prop.Value);
                }
            }

            // MediaPlaybackItem.VideoTracks[].*
            foreach (var track in item.VideoTracks)
            {
                // Note that AdaptiveMediaSource only exposes a single Video track.  Details on bitrates are directly on the AdaptiveMediaSource.
                sb.AppendLine();
                sb.AppendLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
                sb.AppendLine("TrackKind:\t" + track.TrackKind);
                sb.AppendLine("Id:\t" + track.Id);
                sb.AppendLine("Label:\t" + track.Label);
                sb.AppendLine("Language:\t" + track.Language);
                sb.AppendLine("Name:\t" + track.Name);
                sb.AppendLine("DecoderStatus:\t" + track.SupportInfo.DecoderStatus);
                sb.AppendLine("MediaSourceStatus:\t" + track.SupportInfo.MediaSourceStatus);
                var encodingProps = track.GetEncodingProperties();
                if (encodingProps != null)
                {
                    sb.AppendLine("Encoding Properties:");
                    sb.AppendLine("Type:\t" + encodingProps.Type);
                    sb.AppendLine("Subtype:\t" + MediaFoundationGuidStringExtensions.ToMFAttributeName(encodingProps.Subtype));
                    sb.AppendLine("Bitrate:\t" + encodingProps.Bitrate);
                    sb.AppendLine(encodingProps.FrameRate.ToFormattedString("FrameRate"));
                    sb.AppendLine("Height:\t" + encodingProps.Height);
                    sb.AppendLine(encodingProps.PixelAspectRatio.ToFormattedString("PixelAspectRatio"));
                    sb.AppendLine("ProfileId:\t" + encodingProps.ProfileId);
                    sb.AppendLine("StereoscopicVideoPackingMode:\t" + encodingProps.StereoscopicVideoPackingMode);
                    sb.AppendLine("Width:\t" + encodingProps.Width);
                    var additionalProperties = encodingProps.Properties;
                    sb.AppendLine(additionalProperties.ToFormattedString());
                }
            }

            // MediaPlaybackItem.AudioTracks[].*
            foreach (var track in item.AudioTracks)
            {
                sb.AppendLine();
                sb.AppendLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
                sb.AppendLine("TrackKind:\t" + track.TrackKind);
                sb.AppendLine("Id:\t" + track.Id);
                sb.AppendLine("Label:\t" + track.Label);
                sb.AppendLine("Language:\t" + track.Language);
                sb.AppendLine("Name:\t" + track.Name);
                sb.AppendLine("DecoderStatus:\t" + track.SupportInfo.DecoderStatus);
                sb.AppendLine("MediaSourceStatus:\t" + track.SupportInfo.MediaSourceStatus);
                var encodingProps = track.GetEncodingProperties();
                if (encodingProps != null)
                {
                    sb.AppendLine("Encoding Properties:");
                    sb.AppendLine("Type:\t" + encodingProps.Type);
                    sb.AppendLine("Subtype:\t" + MediaFoundationGuidStringExtensions.ToMFAttributeName(encodingProps.Subtype));
                    sb.AppendLine("Bitrate:\t" + encodingProps.Bitrate);
                    sb.AppendLine("BitsPerSample:\t" + encodingProps.BitsPerSample);
                    sb.AppendLine("ChannelCount:\t" + encodingProps.ChannelCount);
                    sb.AppendLine("SampleRate:\t" + encodingProps.SampleRate);
                    var additionalProperties = encodingProps.Properties;
                    sb.AppendLine(additionalProperties.ToFormattedString());
                }
            }

            // MediaPlaybackItem.TimedMetadataTracks[].*
            // Metadata tracks can be added after the open operation,
            // using a foreach has a risk that the collection will
            // change during the itteration which will throw an exception.
            int countOfMetadataTracks = item.TimedMetadataTracks.Count;
            for (int i = 0; i < countOfMetadataTracks; i++)
            {
                var track = item.TimedMetadataTracks[i];

                sb.AppendLine();
                sb.AppendLine("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
                sb.AppendLine("TrackKind:\t" + track.TrackKind);
                sb.AppendLine("Id:\t" + track.Id);
                sb.AppendLine("Label:\t" + track.Label);
                sb.AppendLine("Language:\t" + track.Language);
                sb.AppendLine("Name:\t" + track.Name);
                if (track.ActiveCues != null)
                    sb.AppendLine("ActiveCues.Count:\t" + track.ActiveCues.Count);
                if (track.Cues != null)
                    sb.AppendLine("Cues.Count:\t" + track.Cues.Count);
                sb.AppendLine("DispatchType:\t" + track.DispatchType);
                sb.AppendLine("TimedMetadataKind:\t" + track.TimedMetadataKind);
            }
            return sb.ToString();
        }