示例#1
0
        /// <summary>
        /// Create a new <i>Service Description Table</i> instance.
        /// </summary>
        /// <param name="section">The section which is currently parsed.</param>
        public SDT(Section section) : base(section)
        {
            // Get the size of the service entry region
            int offset = 8, length = section.Length - 3 - offset - 4;

            // Minimum size
            if (length < 0)
            {
                return;
            }

            // Construct
            TransportStreamIdentifier = Tools.MergeBytesToWord(section[1], section[0]);
            OriginalNetworkIdentifier = Tools.MergeBytesToWord(section[6], section[5]);

            // Create helper
            ArrayList services = new ArrayList();

            // Process
            for (ServiceEntry entry; null != (entry = ServiceEntry.Create(this, offset, length));)
            {
                if (entry.IsValid)
                {
                    // Remember
                    services.Add(entry);

                    // Correct
                    offset += entry.Length;
                    length -= entry.Length;
                }
            }

            // Usefull
            m_IsValid = (0 == length);

            // Convert
            if (m_IsValid)
            {
                Services = (ServiceEntry[])services.ToArray(typeof(ServiceEntry));
            }
        }