private void processProgramMapSection(ProgramMapSection programMapSection, ProgramInfo programInfo, Collection <TVStation> tvStations)
        {
            TVStation tvStation = findTVStation(programInfo.ProgramNumber, tvStations);

            if (tvStation == null)
            {
                return;
            }

            foreach (StreamInfo streamInfo in programMapSection.StreamInfos)
            {
                if (streamInfo.StreamType == streamTypeVideo)
                {
                    tvStation.VideoPID = streamInfo.ProgramID;
                }
                if (streamInfo.StreamType == streamTypeAudio)
                {
                    tvStation.AudioPID = streamInfo.ProgramID;
                }
                if (streamInfo.StreamType == streamTypeDSMCCUserToNetwork)
                {
                    tvStation.DSMCCPID = streamInfo.ProgramID;
                }
            }
        }
        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);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex         = mpeg2Header.Index;
            transportStreamID = mpeg2Header.TableIDExtension;
            sectionNumber     = mpeg2Header.SectionNumber;
            lastSectionNumber = mpeg2Header.LastSectionNumber;

            while (lastIndex < byteData.Length - 4)
            {
                ProgramInfo programInfo = new ProgramInfo();
                programInfo.Process(byteData, lastIndex);
                programInfos.Add(programInfo);

                lastIndex = programInfo.Index;
            }
        }
Beispiel #4
0
        private void processProgramMapSection(ProgramMapSection programMapSection, ProgramInfo programInfo, Collection<TVStation> tvStations)
        {
            TVStation tvStation = findTVStation(programInfo.ProgramNumber, tvStations);
            if (tvStation == null)
                return;

            foreach (StreamInfo streamInfo in programMapSection.StreamInfos)
            {
                if (streamInfo.StreamType == streamTypeVideo)
                    tvStation.VideoPID = streamInfo.ProgramID;
                if (streamInfo.StreamType == streamTypeAudio)
                    tvStation.AudioPID = streamInfo.ProgramID;
                if (streamInfo.StreamType == streamTypeDSMCCUserToNetwork)
                    tvStation.DSMCCPID = streamInfo.ProgramID;
            }
        }
Beispiel #5
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);
                }
            }
        }
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        internal void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            transportStreamID = mpeg2Header.TableIDExtension;
            sectionNumber = mpeg2Header.SectionNumber;
            lastSectionNumber = mpeg2Header.LastSectionNumber;

            while (lastIndex < byteData.Length - 4)
            {
                ProgramInfo programInfo = new ProgramInfo();
                programInfo.Process(byteData, lastIndex);
                programInfos.Add(programInfo);

                lastIndex = programInfo.Index;
            }
        }