Ejemplo n.º 1
0
        private void processProgramInfo(ProgramInfo programInfo, Collection <TVStation> tvStations)
        {
            dataProvider.ChangePidMapping(new int[] { programInfo.ProgramID });

            TSReaderBase pmtReader = new TSStreamReader(BDAGraph.PmtTable, 2000, dataProvider.BufferAddress);

            pmtReader.Run();

            Collection <Mpeg2Section> sections = new Collection <Mpeg2Section>();

            int  repeats = 0;
            bool done    = false;

            while (!done)
            {
                Thread.Sleep(10);

                pmtReader.Lock("ProcessPMTSections");
                if (pmtReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in pmtReader.Sections)
                    {
                        sections.Add(section);
                    }
                    pmtReader.Sections.Clear();
                }
                pmtReader.Release("ProcessPMTSections");

                done = (sections.Count != 0);

                if (!done)
                {
                    repeats++;
                    done = (repeats == 500);
                }
            }

            pmtReader.Stop();

            if (sections.Count == 0)
            {
                Logger.Instance.Write("No PMT sections received");
                return;
            }
            else
            {
                foreach (Mpeg2Section section in sections)
                {
                    ProgramMapSection programMapSection = ProgramMapSection.ProcessProgramMapTable(section.Data);
                    processProgramMapSection(programMapSection, programInfo, tvStations);
                }
            }
        }