Ejemplo n.º 1
0
        /// <summary>
        /// Get the bouquet data.
        /// </summary>
        /// <param name="dataProvider">The sample data provider.</param>
        /// <param name="worker">The BackgroundWorker instance running the collection.</param>
        /// <param name="pids">The PID's to scan.</param>
        protected void GetBouquetSections(ISampleDataProvider dataProvider, BackgroundWorker worker, int[] pids)
        {
            BouquetAssociationSection.BouquetAssociationSections.Clear();

            dataProvider.ChangePidMapping(pids);

            Logger.Instance.Write("Collecting channel data", false, true);

            bouquetReader = new TSStreamReader(0x4a, 2000, dataProvider.BufferAddress);
            Channel.Channels.Clear();

            bouquetReader.Run();

            int lastCount = 0;
            int repeats = 0;

            bool bouquetSectionsDone = false;

            while (!bouquetSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    ProcessBouquetSections(sections);

                if (OpenTVChannel.Channels.Count == lastCount)
                {
                    repeats++;
                    bouquetSectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = OpenTVChannel.Channels.Count;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping bouquet reader");
            bouquetReader.Stop();

            Logger.Instance.Write("Channel count: " + OpenTVChannel.Channels.Count + " buffer space used: " + dataProvider.BufferSpaceUsed + " discontinuities: " + bouquetReader.Discontinuities);
        }
Ejemplo n.º 2
0
        private void getDishNetworkData(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Dish Network data", false, true);

            dataProvider.ChangePidMapping(0x300);

            dishNetworkReader = new TSStreamReader(2000, dataProvider.BufferAddress);
            dishNetworkReader.Run();

            int lastCount = 0;
            int repeats = 0;

            while (!dishNetworkSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processSections(sections);

                if (TVStation.EPGCount == lastCount)
                {
                    repeats++;
                    dishNetworkSectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = TVStation.EPGCount;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            dishNetworkReader.Stop();

            Logger.Instance.Write("EPG count: " + TVStation.EPGCount + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 3
0
        private void getEPGSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting EPG data", false, true);

            dataProvider.ChangePidMapping(new int[] { 0x711 });

            guideReader = new TSStreamReader(0x3e, 50000, dataProvider.BufferAddress);
            guideReader.Run();

            int lastCount = 0;
            int repeats = 0;
            guideDone = false;

            while (!guideDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processEPGSections(sections);

                if (SiehFernInfoEPGSection.Sections.Count == lastCount)
                {
                    repeats++;
                    guideDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = SiehFernInfoEPGSection.Sections.Count;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            Logger.Instance.Write("Section count: " + SiehFernInfoEPGSection.Sections.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 4
0
        private void getCategorySections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting category data", false, true);
            MediaHighwayProgramCategory.Categories.Clear();

            dataProvider.ChangePidMapping(new int[] { pid2 });

            categoryReader = new TSStreamReader(0x92, 2000, dataProvider.BufferAddress);
            categoryReader.Run();

            int lastCount = 0;
            int repeats = 0;

            bool categorySectionsDone = false;

            while (!categorySectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processCategorySections(sections);

                if (MediaHighwayProgramCategory.Categories.Count == lastCount)
                {
                    repeats++;
                    categorySectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = MediaHighwayProgramCategory.Categories.Count;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping category reader for PID 0x" + pid2.ToString("X").ToLowerInvariant());
            categoryReader.Stop();

            Logger.Instance.Write("Category count: " + MediaHighwayProgramCategory.Categories.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 6
0
        private void getExtendedTextData(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Extended Text data", false, true);
            ExtendedTextTable.Clear();

            int[] extendedTextPids = masterGuideTable.GetETTPids();
            if (extendedTextPids.Length == 0)
            {
                Logger.Instance.Write("", true, false);
                Logger.Instance.Write("No Extended Text Data PID's in Master Guide Table");
                return;
            }

            dataProvider.ChangePidMapping(masterGuideTable.GetETTPids());

            guideReader = new TSStreamReader(0xcc, 2000, dataProvider.BufferAddress);
            guideReader.Run();

            int lastCount = 0;
            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processExtendedTextTable(sections);

                if (ExtendedTextTable.TextEntries.Count == lastCount)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = ExtendedTextTable.TextEntries.Count;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            Logger.Instance.Write("Extended Text Data: Entry count: " + ExtendedTextTable.TextEntries.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 7
0
        private void getRatingRegionData(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Rating Region data", false, true);
            RatingRegionTable.Clear();

            dataProvider.ChangePidMapping(masterGuideTable.GetRRTPids());

            guideReader = new TSStreamReader(0xca, 2000, dataProvider.BufferAddress);
            guideReader.Run();

            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processRatingRegionTable(sections);

                if (RatingRegionTable.CheckComplete(masterGuideTable.GetRRTRegions()))
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            Logger.Instance.Write("Rating Region Data: Regions: " + RatingRegionTable.Regions.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 8
0
        private void getTitleSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                initialCount += channel.TitleData.Count;

            dataProvider.ChangePidMapping(new int[] { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37 });

            Logger.Instance.Write("Collecting title data", false, true);

            Collection<byte> tables = new Collection<byte>();
            tables.Add(0xa0);
            tables.Add(0xa1);
            tables.Add(0xa2);
            tables.Add(0xa3);
            titleReader = new TSStreamReader(tables, 2000, dataProvider.BufferAddress);
            titleReader.Run();

            int lastCount = 0;
            int repeats = 0;
            titleDataCount = 0;

            bool titleSectionsDone = false;

            while (!titleSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(1000);
                Logger.Instance.Write(".", false, false);

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

                titleReader.Lock("ProcessOpenTVSections");

                if (titleReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in titleReader.Sections)
                        sections.Add(section);
                    titleReader.Sections.Clear();
                }

                titleReader.Release("ProcessOpenTVSections");

                if (sections.Count != 0)
                    processTitleSections(sections);

                titleDataCount = 0;
                foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    titleDataCount += channel.TitleData.Count;

                if (titleDataCount == lastCount)
                {
                    repeats++;
                    titleSectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = titleDataCount;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping title reader");
            titleReader.Stop();

            dataProvider.Frequency.UsageCount = titleDataCount - initialCount;
            Logger.Instance.Write("Title count: " + titleDataCount +
                " buffer space used: " + dataProvider.BufferSpaceUsed +
                " discontinuities: " + titleReader.Discontinuities);
        }
Ejemplo n.º 9
0
        private Collection<TVStation> findAtscStations()
        {
            Logger.Instance.Write("Collecting ATSC Channel data", false, true);

            Collection<TVStation> tvStations = new Collection<TVStation>();

            VirtualChannelTable.Clear();

            dataProvider.ChangePidMapping(new int[] { 0x1ffb });

            Collection<byte> tables = new Collection<byte>();
            tables.Add(0xc8);
            tables.Add(0xc9);
            TSStreamReader guideReader = new TSStreamReader(tables, 50000, dataProvider.BufferAddress);
            guideReader.Run();

            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker.CancellationPending)
                    return (tvStations);

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processVirtualChannelTable(sections, dataProvider.Frequency.Frequency);

                done = VirtualChannelTable.Complete;
                if (!done)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            foreach (VirtualChannel channel in VirtualChannelTable.Channels)
            {
                TVStation station = new TVStation(channel.ShortName);
                station.StationType = TVStationType.Atsc;
                station.OriginalNetworkID = channel.CollectionFrequency;
                station.TransportStreamID = channel.MajorChannelNumber;
                station.ServiceID = channel.MinorChannelNumber;
                tvStations.Add(station);
            }

            return (tvStations);
        }
Ejemplo n.º 10
0
        private void getEITSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting EIT data", false, true);

            int actualPid;
            if (RunParameters.Instance.EITPid == -1)
                actualPid = BDAGraph.EitPid;
            else
                actualPid = RunParameters.Instance.EITPid;

            dataProvider.ChangePidMapping(new int[] { actualPid });

            eitReader = new TSStreamReader(2000, dataProvider.BufferAddress);
            eitReader.Run();

            int lastCount = 0;
            int repeats = 0;

            while (!eitSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processSections(sections);

                if (TVStation.EPGCount == lastCount)
                {
                    repeats++;
                    eitSectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = TVStation.EPGCount;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            eitReader.Stop();

            Logger.Instance.Write("EPG count: " + TVStation.EPGCount + " buffer space used: " + dataProvider.BufferSpaceUsed + " discontinuities: " + eitReader.Discontinuities);
        }
Ejemplo n.º 11
0
        private void getSummarySections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            dataProvider.ChangePidMapping(new int[] { 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47 });

            Logger.Instance.Write("Collecting summary data", false, true);

            Collection<byte> tables = new Collection<byte>();
            tables.Add(0xa8);
            tables.Add(0xa9);
            tables.Add(0xaa);
            tables.Add(0xab);

            summaryReader = new TSStreamReader(tables, 2000, dataProvider.BufferAddress);
            summaryReader.Run();

            int lastCount = 0;
            int repeats = 0;
            summaryCount = 0;

            bool summarySectionsDone = false;

            while (!summarySectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(1000);

                Logger.Instance.Write(".", false, false);

                Collection<Mpeg2Section> sections = new Collection<Mpeg2Section>();
                OpenTVSummarySection.OpenTVSummarySections.Clear();

                summaryReader.Lock("ProcessOpenTVSections");

                if (summaryReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in summaryReader.Sections)
                        sections.Add(section);
                    summaryReader.Sections.Clear();
                }

                summaryReader.Release("ProcessOpenTVSections");

                if (sections.Count != 0)
                    processSummarySections(sections);

                summaryCount = 0;
                foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    summaryCount += channel.SummaryData.Count;

                if (summaryCount == lastCount)
                {
                    repeats++;
                    summarySectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = summaryCount;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping summary reader");
            summaryReader.Stop();

            Logger.Instance.Write("Summary count: " + summaryCount +
                " buffer space used: " + dataProvider.BufferSpaceUsed +
                " discontinuities: " + titleReader.Discontinuities);
        }
Ejemplo n.º 12
0
        private void getTitleSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting title data", false, true);

            dataProvider.ChangePidMapping(new int[] { 0x234 });

            titleReader = new TSStreamReader(0xe6, 2000, dataProvider.BufferAddress);
            titleReader.Run();

            int lastCount = 0;
            int repeats = 0;
            int titleDataCount = 0;

            bool titleSectionsDone = false;

            while (!titleSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(1000);
                Logger.Instance.Write(".", false, false);

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

                titleReader.Lock("ProcessMHW2Sections");

                if (titleReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in titleReader.Sections)
                        sections.Add(section);
                    titleReader.Sections.Clear();
                }

                titleReader.Release("ProcessMHW2Sections");

                if (sections.Count != 0)
                    processTitleSections(sections);

                titleDataCount = 0;
                foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
                    titleDataCount += channel.Titles.Count;

                if (titleDataCount == lastCount)
                {
                    repeats++;
                    titleSectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = titleDataCount;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping title reader for PID 0x234");
            titleReader.Stop();

            Logger.Instance.Write("Title count: " + titleDataCount + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 13
0
        private void getSummarySections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting summary data", false, true);

            dataProvider.ChangePidMapping(new int[] { 0x236 });

            summaryReader = new TSStreamReader(0x96, 2000, dataProvider.BufferAddress);
            summaryReader.Run();

            int lastCount = 0;
            int repeats = 0;

            bool summarySectionsDone = false;

            while (!summarySectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(1000);

                Logger.Instance.Write(".", false, false);

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

                summaryReader.Lock("ProcessMHW2Sections");

                if (summaryReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in summaryReader.Sections)
                        sections.Add(section);
                    summaryReader.Sections.Clear();
                }

                summaryReader.Release("ProcessMHW2Sections");

                if (sections.Count != 0)
                    processSummarySections(sections);

                if (MediaHighwaySummary.Summaries.Count == lastCount)
                {
                    repeats++;
                    summarySectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = MediaHighwaySummary.Summaries.Count;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping summary reader for PID 0x236");
            summaryReader.Stop();

            Logger.Instance.Write("Summary count: " + MediaHighwaySummary.Summaries.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 14
0
        private void getChannelSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting channel data", false, true);
            Channel.Channels.Clear();

            dataProvider.ChangePidMapping(new int[] { 0x231 });

            channelReader = new TSStreamReader(0xc8, 2000, dataProvider.BufferAddress);
            channelReader.Run();

            int lastCount = 0;
            int repeats = 0;

            bool channelSectionsDone = false;

            while (!channelSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processChannelSections(sections);

                if (Channel.Channels.Count == lastCount)
                {
                    repeats++;
                    channelSectionsDone = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = Channel.Channels.Count;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping channel reader for PID 0x231");
            channelReader.Stop();

            Logger.Instance.Write("Channel count: " + Channel.Channels.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Get the time offset data.
        /// </summary>
        /// <param name="dataProvider">The sample data provider.</param>
        /// <param name="worker">The BackgroundWorker instance running the collection.</param>
        protected void GetTimeOffsetSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            if (omitTimeZoneSections)
                return;

            if (RunParameters.Instance.TimeZoneSet)
            {
                TimeOffsetEntry.CurrentTimeOffset = RunParameters.Instance.TimeZone;
                Logger.Instance.Write("Local time offset set from Timezone ini parameter");
                omitTimeZoneSections = true;
                return;
            }

            dataProvider.ChangePidMapping(new int[] { 0x14 });

            Logger.Instance.Write("Collecting time zone data", false, true);

            timeOffsetReader = new TSStreamReader(0x73, 50000, dataProvider.BufferAddress);
            timeOffsetReader.Run();

            bool timeOffsetSectionsDone = false;

            while (!timeOffsetSectionsDone)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processTimeOffsetSections(sections);

                timeOffsetSectionsDone = (TimeOffsetEntry.TimeOffsets.Count != 0);
            }

            Logger.Instance.Write("", true, false);

            foreach (TimeOffsetEntry timeOffsetEntry in TimeOffsetEntry.TimeOffsets)
                Logger.Instance.Write("Time offset: " + timeOffsetEntry.CountryCode + " region " + timeOffsetEntry.Region +
                    " offset " + timeOffsetEntry.TimeOffset + " next offset: " + timeOffsetEntry.NextTimeOffset +
                    " date: " + timeOffsetEntry.ChangeTime);

            Logger.Instance.Write("Stopping time offset reader");
            timeOffsetReader.Stop();

            setTimeOffset();

            Logger.Instance.Write("Time zone count: " + TimeOffsetEntry.TimeOffsets.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 16
0
        private Collection<TVStation> findDvbStations()
        {
            if (useActualFrequency || RunParameters.Instance.DebugIDs.Contains("CREATESATINI"))
                processNITSections(worker);

            dataProvider.ChangePidMapping(pids);

            if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                Logger.Instance.Write("Collecting station data", false, true);
            else
                Logger.Instance.Write("Collecting station data");

            Collection<TVStation> tvStations = new Collection<TVStation>();

            Collection<byte> tables = new Collection<byte>();
            tables.Add(BDAGraph.SdtTable);
            if (searchOtherTable)
                tables.Add(BDAGraph.SdtOtherTable);

            TSStreamReader stationReader = stationReader = new TSStreamReader(tables, 2000, dataProvider.BufferAddress);
            stationReader.Run();

            Collection<Mpeg2Section> sections = null;

            int lastCount = 0;
            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker != null && worker.CancellationPending)
                {
                    stationReader.Stop();
                    return (null);
                }

                Thread.Sleep(2000);

                if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                    Logger.Instance.Write(".", false, false);
                else
                    Logger.Instance.Write("BDA Buffer space used " + dataProvider.BufferSpaceUsed);

                sections = new Collection<Mpeg2Section>();

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

                foreach (Mpeg2Section section in sections)
                {
                    ServiceDescriptionSection serviceDescriptionSection = ServiceDescriptionSection.ProcessServiceDescriptionTable(section.Data);
                    if (serviceDescriptionSection != null)
                        processServiceDescriptionSection(serviceDescriptionSection, tvStations, dataProvider.Frequency);
                }

                if (tvStations.Count == lastCount)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = tvStations.Count;
            }

            if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                Logger.Instance.Write("", true, false);

            Logger.Instance.Write("Stopping station reader for frequency " + dataProvider.Frequency);
            stationReader.Stop();

            int bufferSpaceUsed = dataProvider.BufferSpaceUsed;

            if (dataProvider.Frequency.CollectionType == CollectionType.MHEG5 && tvStations.Count != 0)
            {
                int debugPid = -1;

                foreach (string debugID in RunParameters.Instance.DebugIDs)
                {
                    if (debugID.StartsWith("MHEG5PID-"))
                    {
                        string[] parts = debugID.Split(new char[] { '-' });
                        debugPid = Int32.Parse(parts[1]);
                    }
                }

                if (debugPid == -1)
                {
                    Logger.Instance.Write("Collecting PAT/PMT data to locate MHEG5 pid(s)");

                    processPATSections(tvStations);

                    foreach (TVStation station in tvStations)
                    {
                        if (!station.Excluded && station.DSMCCPID != 0)
                            dataProvider.Frequency.DSMCCPid = station.DSMCCPID;
                    }
                }
                else
                    dataProvider.Frequency.DSMCCPid = debugPid;
            }

            Logger.Instance.Write("Stations: " + tvStations.Count + " buffer space used: " + bufferSpaceUsed + " discontinuities: " + stationReader.Discontinuities);

            return (tvStations);
        }
Ejemplo n.º 17
0
        private void getEventInformationData(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Event Information data", false, true);

            dataProvider.ChangePidMapping(masterGuideTable.GetEITPids());

            guideReader = new TSStreamReader(0xcb, 2000, dataProvider.BufferAddress);
            guideReader.Run();

            int lastCount = 0;
            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processEventInformationTable(sections, dataProvider.Frequency.Frequency);

                if (VirtualChannelTable.EPGCount == lastCount)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = VirtualChannelTable.EPGCount;
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            Logger.Instance.Write("Event Information Data: EPG count: " + VirtualChannelTable.EPGCount + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 18
0
        private void processNITSections(BackgroundWorker worker)
        {
            if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                Logger.Instance.Write("Collecting network information data", false, true);
            else
                Logger.Instance.Write("Collecting network information data");

            dataProvider.ChangePidMapping(new int[] { BDAGraph.NitPid });

            Collection<byte> tables = new Collection<byte>();
            tables.Add(0x40);
            tables.Add(0x41);
            TSReaderBase nitReader = new TSStreamReader(tables, 50000, dataProvider.BufferAddress);
            nitReader.Run();

            bool done = false;
            int lastCount = 0;
            int repeats = 0;

            while (!done)
            {
                if (worker != null && worker.CancellationPending)
                {
                    nitReader.Stop();
                    return;
                }

                Thread.Sleep(2000);

                if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                    Logger.Instance.Write(".", false, false);
                else
                    Logger.Instance.Write("Buffer space used " + dataProvider.BufferSpaceUsed);

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

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

                foreach (Mpeg2Section section in sections)
                {
                    NetworkInformationSection networkInformationSection = NetworkInformationSection.ProcessNetworkInformationTable(section.Data);
                    if (networkInformationSection != null)
                        NetworkInformationSection.AddSection(networkInformationSection);
                }

                if (NetworkInformationSection.NetworkInformationSections.Count == lastCount)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
                else
                    repeats = 0;

                lastCount = NetworkInformationSection.NetworkInformationSections.Count;
            }

            if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                Logger.Instance.Write("", true, false);

            Logger.Instance.Write("Stopping network information reader for frequency " + dataProvider.Frequency);
            nitReader.Stop();
        }
Ejemplo n.º 19
0
        private void getMasterGuideData(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Master Guide data", false, true);

            dataProvider.ChangePidMapping(new int[] { 0x1ffb });

            guideReader = new TSStreamReader(0xc7, 2000, dataProvider.BufferAddress);
            guideReader.Run();

            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                {
                    processMasterGuideTable(sections);
                    done = true;
                }
                else
                    done = (repeats == RunParameters.Instance.Repeats);
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            Logger.Instance.Write("Master Guide Data: " + "buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 20
0
        private void processPATSections(Collection<TVStation> tvStations)
        {
            dataProvider.ChangePidMapping(new int[] { BDAGraph.PatPid } );

            TSReaderBase patReader = new TSStreamReader(BDAGraph.PatTable, 2000, dataProvider.BufferAddress);
            patReader.Run();

            Thread.Sleep(2000);

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

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

            patReader.Stop();

            Collection<int> sectionNumbers = new Collection<int>();

            if (sections == null)
            {
                Logger.Instance.Write("No PAT sections received");
                return;
            }
            else
            {
                foreach (Mpeg2Section section in sections)
                {
                    ProgramAssociationSection programAssociationSection = ProgramAssociationSection.ProcessProgramAssociationTable(section.Data);
                    if (programAssociationSection != null)
                    {
                        if (!sectionNumbers.Contains(programAssociationSection.SectionNumber))
                        {
                            processProgramAssociationSection(programAssociationSection, tvStations);
                            sectionNumbers.Add(programAssociationSection.SectionNumber);
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private void getVirtualChannelData(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Virtual Channel data", false, true);
            VirtualChannelTable.Clear();

            dataProvider.ChangePidMapping(new int[] { 0x1ffb });

            Collection<byte> tables = new Collection<byte>();
            tables.Add(0xc8);
            tables.Add(0xc9);
            guideReader = new TSStreamReader(tables, 2000, dataProvider.BufferAddress);
            guideReader.Run();

            int repeats = 0;
            bool done = false;

            while (!done)
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                    processVirtualChannelTable(sections, dataProvider.Frequency.Frequency);

                done = VirtualChannelTable.Complete;
                if (!done)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            Logger.Instance.Write("Virtual Channel Data: Channel count: " + VirtualChannelTable.Channels.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
Ejemplo n.º 22
0
        private void getDSMCCSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            int pid = dataProvider.Frequency.DSMCCPid;

            if (pid == 0)
            {
                noMHEGPid = true;
                Logger.Instance.Write("No MHEG5 PID's on frequency " + dataProvider.Frequency);
                return;
            }

            Logger.Instance.Write("Collecting MHEG5 data from PID 0x" + pid.ToString("X").ToLowerInvariant(), false, true);

            dataProvider.ChangePidMapping(new int[] { pid });

            dsmccReader = new TSStreamReader(500, dataProvider.BufferAddress);
            dsmccReader.Run();

            while (!checkAllDataLoaded())
            {
                if (worker.CancellationPending)
                    return;

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                foreach (Mpeg2Section section in sections)
                {
                    switch (section.Table)
                    {
                        case 0x3b:
                            processControlSection(section);
                            break;
                        case 0x3c:
                            processDataSection(section);
                            break;
                        default:
                            break;
                    }
                }
            }

            Logger.Instance.Write("", true, false);

            Logger.Instance.Write("Stopping reader for frequency " + dataProvider.Frequency + " PID 0x" + pid.ToString("X").ToLowerInvariant());
            dsmccReader.Stop();

            int totalBlocks = 0;
            foreach (DSMCCModule module in modules)
            {
                module.LogMessage();
                totalBlocks += module.Blocks.Count;
            }

            Logger.Instance.Write("Data blocks: " + totalBlocks + " buffer space used: " + dataProvider.BufferSpaceUsed + " discontinuities: " + dsmccReader.Discontinuities);
        }