public ChunkInfo(XmlNode element, uint index, ulong starttime) { if (element.Name != "c") { throw new Exception("Source element is not a(n) c element!"); } this.Attributes = Parse.Attributes(element); this.Index = index; if (this.Attributes.ContainsKey("n")) { this.Index = Parse.UInt32Attribute(this.Attributes, "n"); } if (this.Index != index) { throw new Exception("Missing chunk index: " + index); } this.StartTime = starttime; if (this.Attributes.ContainsKey("t")) { this.StartTime = Parse.UInt64Attribute(this.Attributes, "t"); } if (this.Attributes.ContainsKey("d")) { this.Duration = Parse.UInt64Attribute(this.Attributes, "d"); } }
public TrackInfo(XmlNode element, uint index, StreamInfo stream) { if (element.Name != "QualityLevel") { throw new Exception("Source element is not a(n) QualityLevel element!"); } this.Attributes = Parse.Attributes(element); this.CustomAttributes = Parse.CustomAttributes(element); this.Index = index; if (this.Attributes.ContainsKey("Index")) { this.Index = Parse.UInt32Attribute(this.Attributes, "Index"); } if (this.Index != index) { throw new Exception("Missing quality level index: " + index); } this.Bitrate = Parse.UInt32Attribute(this.Attributes, "Bitrate"); this.Stream = stream; }
private ManifestInfo(XmlNode element, Uri uri) { this.Uri = uri; if (element.Name != "SmoothStreamingMedia") { throw new Exception("Source element is not a(n) SmoothStreamingMedia element!"); } this.Attributes = Parse.Attributes(element); this.MajorVersion = Parse.UInt32Attribute(this.Attributes, "MajorVersion"); this.MinorVersion = Parse.UInt32Attribute(this.Attributes, "MinorVersion"); this.Duration = Parse.UInt64Attribute(this.Attributes, "Duration"); this.IsLive = false; if (this.Attributes.ContainsKey("IsLive")) { this.IsLive = Parse.BoolAttribute(this.Attributes, "IsLive"); } this.TimeScale = 10000000uL; if (this.Attributes.ContainsKey("TimeScale")) { this.TimeScale = Parse.UInt64Attribute(this.Attributes, "TimeScale"); } this.AvailableStreams = new List <StreamInfo>(); foreach (XmlNode element2 in element.SelectNodes("StreamIndex")) // Automatic cast to XmlNode. { this.AvailableStreams.Add(new StreamInfo(element2, this.Uri)); } this.SelectedStreams = new List <StreamInfo>(); for (int i = 0; i < this.AvailableStreams.Count; i++) { if (this.AvailableStreams[i].Type != MediaStreamType.Script) { this.SelectedStreams.Add(this.AvailableStreams[i]); } } this.TotalTicks = this.IsLive ? 0 : (ulong)(this.Duration / this.TimeScale * 10000000.0); }
public StreamInfo(XmlNode element, Uri manifestUri) { if (element.Name != "StreamIndex") { throw new Exception("Source element is not a(n) StreamIndex element!"); } this.Attributes = Parse.Attributes(element); this.CustomAttributes = Parse.CustomAttributes(element); this.Type = Parse.MediaStreamTypeAttribute(this.Attributes, "Type"); this.Subtype = this.Attributes.ContainsKey("Subtype") ? Parse.StringAttribute(this.Attributes, "Subtype") : ""; if (this.Attributes.ContainsKey("Url")) { this.CheckUrlAttribute(); } this.AvailableTracks = new List <TrackInfo>(); XmlNodeList xmlNodeList = element.SelectNodes("QualityLevel"); int i; for (i = 0; i < xmlNodeList.Count; ++i) { TrackInfo trackInfo; if (this.Type == MediaStreamType.Audio) { trackInfo = new AudioTrackInfo(xmlNodeList[i], this.Attributes, (uint)i, this); } else if (this.Type == MediaStreamType.Video) { trackInfo = new VideoTrackInfo(xmlNodeList[i], this.Attributes, (uint)i, this); } else { continue; } int num = 0; while (num < this.AvailableTracks.Count && this.AvailableTracks[num].Bitrate > trackInfo.Bitrate) { num++; } this.AvailableTracks.Insert(num, trackInfo); } this.ChunkList = new List <ChunkInfo>(); XmlNodeList xmlNodeList2 = element.SelectNodes("c"); ulong num2 = 0uL; for (i = 0; i < xmlNodeList2.Count; i++) { ChunkInfo chunkInfo = new ChunkInfo(xmlNodeList2[i], (uint)i, num2); this.ChunkList.Add(chunkInfo); num2 += chunkInfo.Duration; } if (this.Attributes.ContainsKey("Chunks")) { uint chunkCount = Parse.UInt32Attribute(this.Attributes, "Chunks"); if (this.ChunkList.Count > 0 && this.ChunkList.Count != chunkCount) { throw new Exception("Chunk count mismatch: c=" + this.ChunkList.Count + " chunks=" + chunkCount); } this.ChunkCount = (int)chunkCount; } else { this.ChunkCount = this.ChunkList.Count; // Can be 0 if no `<c' tags. } this.pureUrl = manifestUri.AbsoluteUri; this.pureUrl = this.pureUrl.Substring(0, this.pureUrl.LastIndexOf('/')); this.SelectedTracks = new List <TrackInfo>(); if (this.AvailableTracks.Count > 0) { this.SelectedTracks.Add(this.AvailableTracks[0]); } }