Beispiel #1
0
        /// <summary>
        /// Übermittelt eine SI Tabelle zur Bearbeitung.
        /// </summary>
        /// <param name="table">Die neu empfangene SI Tabelle mit Teildaten zu einem Modul.</param>
        public void AddPartialModule(Tables.OpenTV table)
        {
            // See if module should be processed
            lock (m_Enabled)
                if (m_Enabled.Count > 0)
                {
                    if (!m_Enabled.ContainsKey(table.ModuleIdentifier))
                    {
                        return;
                    }
                }

            // The new module
            Module module;

            // Check for module manager inside collection
            lock (m_Modules)
                if (!m_Modules.TryGetValue(table.ModuleIdentifier, out module))
                {
                    // Create new
                    module = new Module();

                    // Connect
                    module.OnModuleComplete += ForwardComplete;

                    // Remember
                    m_Modules[table.ModuleIdentifier] = module;
                }

            // Forward
            module.AddPartialModule(table);
        }
Beispiel #2
0
        /// <summary>
        /// Wird aufgerufen, wenn ein Modul komplettiert wurde.
        /// </summary>
        /// <param name="lastTable">Die letzte SI Tabelle des Moduls.</param>
        /// <param name="module">Das fertiggestellte Modul.</param>
        private void ForwardComplete(Tables.OpenTV lastTable, Module module)
        {
            // Check for interested client
            Module.CompleteHandler callback = OnModuleComplete;

            // Report to client
            if (null != callback)
            {
                callback(lastTable, module);
            }
        }
Beispiel #3
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;
            }
        }