2 using System.Collections.Generic;
\r
4 using System.Text.RegularExpressions;
\r
6 namespace Handbrake.Parsing
\r
9 /// An object represending an AudioTrack associated with a Title, in a DVD
\r
11 public class AudioTrack
\r
13 private int m_trackNumber;
\r
15 /// The track number of this Audio Track
\r
17 public int TrackNumber
\r
21 return this.m_trackNumber;
\r
25 private string m_language;
\r
27 /// The language (if detected) of this Audio Track
\r
29 public string Language
\r
33 return this.m_language;
\r
37 private string m_format;
\r
39 /// The primary format of this Audio Track
\r
41 public string Format
\r
45 return this.m_format;
\r
49 private string m_subFormat;
\r
51 /// Additional format info for this Audio Track
\r
53 public string SubFormat
\r
57 return this.m_subFormat;
\r
61 private int m_frequency;
\r
63 /// The frequency (in MHz) of this Audio Track
\r
65 public int Frequency
\r
69 return this.m_frequency;
\r
73 private int m_bitrate;
\r
75 /// The bitrate (in kbps) of this Audio Track
\r
81 return this.m_bitrate;
\r
86 /// Override of the ToString method to make this object easier to use in the UI
\r
88 /// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
\r
89 public override string ToString()
\r
91 return string.Format("{0} {1} ({2}) ({3})", this.m_trackNumber, this.m_language, this.m_format, this.m_subFormat);
\r
94 public static AudioTrack Parse(StringReader output)
\r
96 Match m = Regex.Match(output.ReadLine(), @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\), ([0-9]*)Hz, ([0-9]*)bps");
\r
99 AudioTrack thisTrack = new AudioTrack();
\r
100 thisTrack.m_trackNumber = int.Parse(m.Groups[1].Value.Trim().ToString());
\r
101 thisTrack.m_language = m.Groups[2].Value;
\r
102 thisTrack.m_format = m.Groups[3].Value;
\r
103 thisTrack.m_subFormat = m.Groups[4].Value;
\r
104 thisTrack.m_frequency = int.Parse(m.Groups[5].Value.Trim().ToString());
\r
105 thisTrack.m_bitrate = int.Parse(m.Groups[6].Value.Trim().ToString());
\r
114 public static AudioTrack[] ParseList(StringReader output)
\r
116 List<AudioTrack> tracks = new List<AudioTrack>();
\r
119 AudioTrack thisTrack = AudioTrack.Parse(output);
\r
120 if (thisTrack != null)
\r
122 tracks.Add(thisTrack);
\r
129 return tracks.ToArray();
\r