/// <summary>
        /// Versucht, aus der aktuellen <i>Program Access Table</i> das Programm des
        /// eingehenden Transport Streams zu ermitteln.
        /// </summary>
        /// <remarks>
        /// Nur das erste Programm wird berücksichtigt.
        /// </remarks>
        /// <param name="pat">Eine SI Tabelle.</param>
        private void ProcessPAT( Section pat )
        {
            // Not active
            if (!IsRunning)
                return;

            // Validate
            if (!pat.IsValid)
                return;

            // Attach to table
            PAT table = pat.Table as PAT;

            // Validate
            if (null == table)
                return;
            if (!table.IsValid)
                return;
            if (null == table.ProgramIdentifier)
                return;

            // Get the first
            IEnumerator<KeyValuePair<ushort, ushort>> programEnum = table.ProgramIdentifier.GetEnumerator();
            if (!programEnum.MoveNext())
                return;

            // Compare current PMT
            if (m_CurrentPMT == programEnum.Current.Value)
                return;

            // Remove the audio names
            m_AudioNames = new string[0];

            // Stop current PMT
            if (0 != m_CurrentPMT)
                m_TSParser.RemoveFilter( m_CurrentPMT );

            // Re-create parser
            m_PMTParser = new Parser();

            // Connect to handler
            m_PMTParser.SectionFound += ProcessPMT;

            // Change
            m_CurrentPMT = programEnum.Current.Value;
            m_CurrentService = null;
            CurrentEntry = null;
            NextEntry = null;

            // Create PMT
            m_TSParser.SetFilter( m_CurrentPMT, true, m_PMTParser.OnData );
        }
Exemplo n.º 2
0
        private void AddEntry( ushort service, EventEntry entry )
        {
            // Create a key
            string simpleKey = string.Format( "{0}-{1}", service, entry.EventIdentifier );

            // Already collected
            if (m_Entries.ContainsKey( simpleKey )) return;

            // Lock out
            m_Entries[simpleKey] = true;

            // Load all
            string name, description;
            LoadEventData( out name, out description, entry.Descriptors );

            // Remember
            m_ListItems.Add( new EPGEntry( service, name, description, entry.StartTime.ToLocalTime(), entry.Duration, entry.EventIdentifier ) );
        }
        /// <summary>
        /// Prüft, ob in der Programmzeitschrift Daten zur aktuellen Aufzeichnung vorliegen.
        /// </summary>
        /// <param name="section">Eintrag aus der Programmzeitschrift.</param>
        private void ProcessEPG( Section section )
        {
            // Not valid
            if (null == section)
                return;
            if (!section.IsValid)
                return;

            // Get the table
            EIT eit = section.Table as EIT;

            // Not valid
            if (null == eit)
                return;
            if (!eit.IsValid)
                return;

            // See if filter is active
            int? service = m_CurrentService;

            // Only current events are of interest
            if (!service.HasValue)
                return;
            if (service.Value != eit.ServiceIdentifier)
                return;

            // Set flags
            bool gotCurrent = false, gotNext = false;

            // Find all
            foreach (EventEntry entry in eit.Entries)
            {
                // Check for current
                if (!gotCurrent)
                    if (EventStatus.Running == entry.Status)
                    {
                        // Remember
                        CurrentEntry = entry;
                        gotCurrent = true;

                        // Done
                        if (gotNext)
                            break;
                        else
                            continue;
                    }

                // Check for next
                if (!gotNext)
                    if (EventStatus.NotRunning == entry.Status)
                    {
                        // Remember
                        NextEntry = entry;
                        gotNext = true;

                        // Done
                        if (gotCurrent)
                            break;
                    }
            }
        }