ADBaseLibrary.AdobeHDS.BoxReader.ReadBootStrap C# (CSharp) Method

ReadBootStrap() public method

public ReadBootStrap ( BootStrap info ) : bool
info BootStrap
return bool
        public bool ReadBootStrap(BootStrap info)
        {
            info.Version = ReadByte();
            info.Flags = EReadInt24();
            info.BootStrapVersion = EReadInt32();
            byte flags = ReadByte();
            info.ProfileType = (flags & 0xc0) >> 6;
            if ((flags & 0x20) == 0x20)
            {
                info.Live = true;
                info.HasMetadata = false;
            }
            info.IsUpdate = ((flags & 0x10) == 0x10);
            if (!info.IsUpdate)
            {
                info.SegmentTables = new Dictionary<int, Segment>();
                info.FragmentTables = new Dictionary<int, Fragment>();
            }
            info.Timescale = EReadInt32();
            info.CurrentMediaTime = EReadInt64();
            info.SmpteTimeCodeOffset = EReadInt64();
            info.MovieIdentifier = EReadString();
            int cnt = ReadByte();
            info.ServerEntryTable = new List<string>();
            for (int x = 0; x < cnt; x++)
                info.ServerEntryTable.Add(EReadString());
            cnt = ReadByte();
            info.QualityEntryTable = new List<string>();
            for (int x = 0; x < cnt; x++)
                info.QualityEntryTable.Add(EReadString());
            info.DrmData = ReadString();
            info.MetaData = ReadString();
            cnt = ReadByte();
            for (int x = 0; x < cnt; x++)
            {
                string name;
                long left = ReadHeader(out name);
                if (name == "asrt")
                    ReadSegment().ToList().ForEach(a => info.SegmentTables[a.Key] = a.Value);
                else
                    BaseStream.Seek(left, SeekOrigin.Current);
            }
            cnt = ReadByte();
            for (int x = 0; x < cnt; x++)
            {
                string name;
                long left = ReadHeader(out name);
                if (name == "afrt")
                    ReadFragment().ToList().ForEach(a => info.FragmentTables[a.Key] = a.Value);
                else
                    BaseStream.Seek(left, SeekOrigin.Current);
            }
            info.SegmentTables = info.SegmentTables.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value);
            info.FragmentTables = info.FragmentTables.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value);
            info.InitFragments();
            return true;
        }

Usage Example

Beispiel #1
0
        private async Task ProcessFragment(Stream s, int fragment)
        {
            BoxReader reader = new BoxReader(s);
            string    name;

            while (reader.BaseStream.Position != reader.BaseStream.Length)
            {
                long size = reader.ReadHeader(out name);
                if (name == "abst")
                {
                    reader.ReadBootStrap(bootstrap);
                }
                else if (name == "mdat")
                {
                    long       max  = reader.BaseStream.Position + size;
                    List <Tag> tags = new List <Tag>();
                    while (reader.BaseStream.Position != max)
                    {
                        tags.Add(await GetNextTag(reader.BaseStream));
                    }
                    await QueueTags(tags, fragment);
                }
                else
                {
                    reader.BaseStream.Seek(size, SeekOrigin.Current);
                }
            }
            reader.Dispose();
        }
All Usage Examples Of ADBaseLibrary.AdobeHDS.BoxReader::ReadBootStrap