private string GetInfoHtml(Streams.IGeneralStream generalStream, List <Streams.IStreamBase> allStreams) { var sb = new StringBuilder(); var odd = false; var dict = generalStream.Properties; sb.AppendLine("<table width='100%'>"); sb.AppendLine("<thead><tr>"); sb.AppendLine("<th colspan=2> General</th>"); sb.AppendLine("</tr></thead>"); sb.AppendLine("<tbody>"); foreach (var key in dict.Keys) { odd = !odd; sb.Append(odd ? "<tr class='odd'>" : "<tr>"); sb.AppendLine(string.Format("<td nowrap>{0}</td><td>{1}</td>", key, dict[key])); sb.Append("</tr>"); } sb.AppendLine("</tbody>"); sb.AppendLine("</table>"); sb.AppendLine(); foreach (var stream in allStreams) { if (stream.Properties.Count == 0) { continue; } dict = stream.Properties; sb.AppendLine("<table width='100%'>"); sb.AppendLine("<thead><tr>"); sb.AppendLine(string.Format("<th colspan=2> {0} #{1}</th>", stream.StreamType, stream.StreamTypeIndex)); sb.AppendLine("</tr></thead>"); sb.AppendLine("<tbody>"); foreach (var key in dict.Keys) { odd = !odd; sb.Append(odd ? "<tr class='odd'>" : "<tr>"); sb.AppendLine(string.Format("<td nowrap>{0}</td><td>{1}</td>", key, dict[key])); sb.Append("</tr>"); } sb.AppendLine("</tbody>"); sb.AppendLine("</table>"); sb.AppendLine(); } return(sb.ToString()); }
private void AddProperties(Streams.IGeneralStream generalStream, List <Streams.IStreamBase> allStreams, bool isMediaInfo = false) { Dictionary <string, string> dict; var index = 0; if (this.GeneralStream == null) { this.GeneralStream = generalStream; } else { dict = generalStream.Properties; foreach (var key in dict.Keys) { if (!this.GeneralStream.Properties.ContainsKey(key)) { this.GeneralStream.Properties.Add(key, dict[key]); } } } index = -1; //simply add streams one by one if (this.AllStreams.Count == 0) { foreach (var stream in allStreams) { index++; this.AllStreams.Add(stream); switch (stream.StreamType.ToString()) { case "Data": this.DataStreams.Add(stream as Streams.DataStream); stream.StreamTypeIndex = this.DataStreams.IndexOf(stream as Streams.DataStream); break; case "Audio": this.AudioStreams.Add(stream as Streams.AudioStream); stream.StreamTypeIndex = this.AudioStreams.IndexOf(stream as Streams.AudioStream); break; case "Video": this.VideoStreams.Add(stream as Streams.VideoStream); stream.StreamTypeIndex = this.VideoStreams.IndexOf(stream as Streams.VideoStream); break; case "Text": this.TextStreams.Add(stream as Streams.TextStream); stream.StreamTypeIndex = this.TextStreams.IndexOf(stream as Streams.TextStream); break; case "Image": this.ImageStreams.Add(stream as Streams.ImageStream); stream.StreamTypeIndex = this.ImageStreams.IndexOf(stream as Streams.ImageStream); break; case "Menu": this.MenuStreams.Add(stream as Streams.MenuStream); stream.StreamTypeIndex = this.MenuStreams.IndexOf(stream as Streams.MenuStream); break; case "Chapters": this.ChaptersStreams.Add(stream as Streams.ChaptersStream); stream.StreamTypeIndex = this.ChaptersStreams.IndexOf(stream as Streams.ChaptersStream); break; } } } else { //match the streams and append additional properties for each stream foreach (var s1 in allStreams) { foreach (var s2 in this.AllStreams) { if (s2.StreamType.Equals(s1.StreamType) & (s2.StreamTypeIndex == s1.StreamTypeIndex) & ((s2.FormatId == s1.FormatId) | string.IsNullOrEmpty(s2.FormatId))) { dict = s1.Properties; if (isMediaInfo) { //overwrite ffmpeg's CodecID and Format values with MediaInfo's values if (s2.Properties.ContainsKey("Codec ID") & s1.Properties.ContainsKey("Codec ID")) { s2.Properties["Codec ID"] = s1.Properties["Codec ID"]; } if (s2.Properties.ContainsKey("Format") & s1.Properties.ContainsKey("Format")) { s2.Properties["Format"] = s1.Properties["Format"]; } } foreach (var key in dict.Keys) { if (!s2.Properties.ContainsKey(key)) { s2.Properties.Add(key, dict[key]); } } } } } } }