Beispiel #1
0
        /// <summary>
        /// Ergänz Teildaten zu diesem Modul.
        /// </summary>
        /// <param name="table">Die SI Tabelle mit den Teildaten.</param>
        public void AddPartialModule(Tables.OpenTV table)
        {
            // Check for expected offset
            if (table.SectionOffset != m_NextOffset)
            {
                // See if we are synchronizing
                if (0 != m_NextOffset)
                {
                    // Lost a part.
                    ++WrongOffset;

                    // Restart
                    m_NextOffset = 0;
                    m_Collector  = null;
                }

                // Continue synchronizing.
                if (table.SectionOffset != 0)
                {
                    return;
                }
            }

            // Check for the head of the module
            if (0 == m_NextOffset)
            {
                try
                {
                    // Allocate memory
                    m_Collector = new byte[table.ModuleLength];
                }
                catch
                {
                    // Not enough free space
                    ++MemoryError;

                    // Done
                    return;
                }
            }

            // Check consistency
            if (m_Collector.Length != table.ModuleLength)
            {
                // SI table data mismatch
                ++WrongLength;

                // Reset
                m_NextOffset = 0;
                m_Collector  = null;

                // Next
                return;
            }

            // See if data fits
            if ((m_NextOffset + table.DataLength) > m_Collector.Length)
            {
                // Too much data
                ++OverRunError;

                // Reset
                m_NextOffset = 0;
                m_Collector  = null;

                // Next
                return;
            }

            // Store data into raw buffer
            table.CopyTo(m_Collector, (int)m_NextOffset);

            // Advance offset
            m_NextOffset += table.DataLength;

            // See if module is complete
            if (m_NextOffset == table.ModuleLength)
            {
                // Try decompression
                if (Decompress())
                {
                    // Get the callback
                    CompleteHandler callback = OnModuleComplete;

                    // Report finished packet to client
                    if (null != callback)
                    {
                        callback(table, this);
                    }
                }

                // Reset
                m_NextOffset = 0;
                m_Collector  = null;
            }
        }