Beispiel #1
0
        public EPGThread(MulticastEPGSource epg_datasource, Hashtable EPGEvents)
        {
            done = false;
            EPG_Events = EPGEvents;
            EPGParser = new Parser();

            EPGParser.SectionFound += new JMS.DVB.EPG.Parser.SectionFoundHandler(SectionFound);

            EPGDataSource = epg_datasource;
        }
Beispiel #2
0
        /// <summary>
        /// Create a new instance and start EPG parsing on PID <i>0x12</i>.
        /// </summary>
        /// <param name="device">Related hardware device.</param>
        /// <param name="portal">The currently show station.</param>
        public ServiceParser(IDeviceProvider device, Station portal)
        {
            // Remember
            DVBDevice = device;
            Portal = portal;

            // Create EPG parser
            EPGParser = new Parser(DVBDevice);

            // Attach handler
            EPGParser.SectionFound += new Parser.SectionFoundHandler(EPGSectionFound);
        }
        /// <summary>
        /// Initialisiert eine Instanz.
        /// </summary>
        protected TransportStreamAccessor()
        {
            // Analyseeinheit erzeugen
            m_TTXConsumer = new TTXStreamConsumer( this );

            // Videotext PES Analysator erzeugen
            m_TTXStream = new TS.TTXStream( m_TTXConsumer, 0, false );

            // Install parser
            m_PATParser = new Parser();

            // Register receiver
            m_PATParser.SectionFound += ProcessPAT;

            // Connect to parser
            m_TSParser.SetFilter( 0, true, m_PATParser.OnData );

            // Install EPG parser
            m_EPGParser = new Parser();

            // Register receiver
            m_EPGParser.SectionFound += ProcessEPG;

            // Connect to parser
            m_TSParser.SetFilter( 0x12, true, m_EPGParser.OnData );
        }
        /// <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 );
        }
Beispiel #5
0
        /// <summary>
        /// Create a new section from a raw data buffer.
        /// <seealso cref="Section"/>
        /// </summary>
        /// <param name="buffer">The full buffer.</param>
        /// <param name="offset">The first byte of the data for the section.</param>
        /// <param name="length">The number of bytes available for the section.</param>
        /// <param name="parser">The related parser used for error countings.</param>
        /// <returns><i>null</i> if there are not enough bytes available in
        /// the raw data for the section. If a <see cref="Section"/> is reported
        /// it may have <see cref="Section.IsValid"/> unset to indicated that
        /// the <see cref="CRC32"/> validation failed.</returns>
        static internal Section Create( byte[] buffer, int offset, int length, Parser parser )
        {
            // Check for the minimum size
            if (length < 7)
                return null;

            // Decode
            byte tableIdentifier = buffer[offset + 0];
            byte flags = buffer[offset + 1];
            int lowLength = buffer[offset + 2];

            // Decode flags
            bool syntax = (0 != (0x80 & flags));
            int highLength = flags & 0xf;

            // Construct the overall size
            int size = lowLength + 256 * highLength;

            // Verify
            if ((3 + size) > length)
            {
                // Report error
                if (null != parser)
                    parser.WrongLength += 1;

                // Done
                return null;
            }

            // See if CRC check is required
            bool crcOK = true;

            // Do the check - there are tables with no CRC support
            if (tableIdentifier != 0x70)
                if (tableIdentifier != 0x71)
                    crcOK = CRC32.CheckCRC( buffer, offset, 3 + size );

            // Create the new section
            return new Section( tableIdentifier, (byte) (flags & 0xf0), syntax, buffer, offset + 3, size, crcOK );
        }