상속: TrackInfo
예제 #1
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]);
            }
        }
예제 #2
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]);
       }
 }