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);
        }
Beispiel #2
0
        /// <summary>
        /// Initialize a new instance of the FrequencyScanner class.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">An optional background worker instance. Can be null.</param>
        public FrequencyScanner(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            this.dataProvider = dataProvider;
            this.worker = worker;

            pids = new int[] { BDAGraph.SdtPid };
        }
Beispiel #3
0
        /// <summary>
        /// Acquire and process Siehfern Info data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            /*getChannelSections(dataProvider, worker);*/
            getEPGSections(dataProvider, worker);

            return(CollectorReply.OK);
        }
        /// <summary>
        /// Acquire and process OpenTV data.
        /// </summary>
        /// <param name="dataProvider">A sampe data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            OpenTVProgramCategory.LoadFromCode(RunParameters.Instance.CountryCode.Trim());
            CustomProgramCategory.Load();
            ParentalRating.Load();

            bool referenceTablesLoaded = SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary " + RunParameters.Instance.CountryCode.Trim() + ".cfg"));

            if (!referenceTablesLoaded)
            {
                return(CollectorReply.ReferenceDataError);
            }

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            GetBouquetSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getTitleSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getSummarySections(dataProvider, worker);

            return(CollectorReply.OK);
        }
        private void getCategorySections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting category data", false, true);
            MediaHighwayProgramCategory.Categories.Clear();

            categoryReader = new TSStreamReader(0xc8, 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("ProcessMHW2Sections");
                if (categoryReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in categoryReader.Sections)
                    {
                        sections.Add(section);
                    }
                    categoryReader.Sections.Clear();
                }
                categoryReader.Release("ProcessMHW2Sections");

                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 0x231");
            categoryReader.Stop();

            Logger.Instance.Write("Category count: " + MediaHighwayProgramCategory.Categories.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
        /// <summary>
        /// Initialize a new instance of the FrequencyScanner class.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">An optional background worker instance. Can be null.</param>
        public FrequencyScanner(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            this.dataProvider = dataProvider;
            this.worker       = worker;

            pids = new int[] { BDAGraph.SdtPid };
        }
        /// <summary>
        /// Acquire and process EIT data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            EITProgramContent.Load();
            CustomProgramCategory.Load();

            MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T2.cfg"));

            /*GetStationData(dataProvider, worker, new int[] { 0xbba, 0xc1e, 0xf01 });*/
            GetStationData(dataProvider, worker, new int[] { 0xbba });
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            if (RunParameters.Instance.ChannelBouquet != -1 ||
                RunParameters.Instance.Options.Contains("USECHANNELID") ||
                RunParameters.Instance.Options.Contains("USELCN") ||
                RunParameters.Instance.Options.Contains("CREATEBRCHANNELS") ||
                RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                /*GetBouquetSections(dataProvider, worker, new int[] { 0xbba, oxc1e, oxf01 } );*/
                GetBouquetSections(dataProvider, worker, new int[] { 0xbba });
                if (worker.CancellationPending)
                {
                    return(CollectorReply.Cancelled);
                }
            }

            getFreeSatSections(dataProvider, worker);

            return(CollectorReply.OK);
        }
        /// <summary>
        /// Acquire and process MediaHighway1 data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            MediaHighwayProgramCategory.LoadFromFrequency("1", dataProvider.Frequency.ToString());
            CustomProgramCategory.Load();

            getChannelSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getCategorySections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getTitleSections(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getSummarySections(dataProvider, worker);

            return(CollectorReply.OK);
        }
        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);
        }
Beispiel #10
0
        private void getChannelSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting Channel data", false, true);

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

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

            int lastCount = 0;
            int repeats   = 0;

            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)
                {
                    processChannelSections(sections);
                }

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

                lastCount = SiehFernInfoChannelSection.Sections.Count;
            }

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

            Logger.Instance.Write("Section count: " + SiehFernInfoChannelSection.Sections.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
        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);
        }
        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);
        }
        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);
        }
Beispiel #14
0
        /// <summary>
        /// Acquire and process EIT data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            EITProgramContent.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            if (RunParameters.Instance.Options.Contains("USEFREESATTABLES"))
            {
                MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T2.cfg"));
            }

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            bool bouquetNeeded = checkBouquetNeeded();

            if (RunParameters.Instance.ChannelBouquet != -1 ||
                RunParameters.Instance.Options.Contains("USECHANNELID") ||
                RunParameters.Instance.Options.Contains("USELCN") ||
                RunParameters.Instance.Options.Contains("CREATEBRCHANNELS") ||
                RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                GetBouquetSections(dataProvider, worker);

                string bouquetType;

                if (eitChannels > 0)
                {
                    bouquetType = "Freeview";
                }
                else
                {
                    bouquetType = "OpenTV";
                }

                Logger.Instance.Write("Used " + bouquetType + " channel descriptors");

                if (worker.CancellationPending)
                {
                    return(CollectorReply.Cancelled);
                }
            }

            getEITSections(dataProvider, worker);

            return(CollectorReply.OK);
        }
Beispiel #15
0
        /// <summary>
        /// Acquire and process Bell TV data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            BellTVProgramCategory.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getBellTVData(dataProvider, worker);

            return(CollectorReply.OK);
        }
        /// <summary>
        /// Acquire and process ATSC PSIP Info data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            AtscPsipProgramCategory.Load();
            CustomProgramCategory.Load();

            bool referenceTablesLoaded = MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary ATSC PSIP T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary ATSC PSIP T2.cfg"));

            if (!referenceTablesLoaded)
            {
                return(CollectorReply.ReferenceDataError);
            }

            getMasterGuideData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getVirtualChannelData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            /*getRatingRegionData(dataProvider, worker);
             * if (worker.CancellationPending)
             *  return (CollectorReply.Cancelled);*/

            getExtendedTextData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getEventInformationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            OutputFile.UseUnicodeEncoding = MultipleString.UseUnicodeEncoding;

            return(CollectorReply.OK);
        }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HystrixMetricsStreamServer"/> class.
        /// </summary>
        /// <param name="httpListenerPrefix">The http listener prefix for listening incoming connections.
        /// For examples 'http://+:8888/hystrix/' which accepts connections on any domain on the port 8888 for the url '/hystrix/'.</param>
        /// <param name="maxConcurrentConnections">The maximum number of concurrent connections. New clients will be refused if
        /// the number of concurrent connections reach this maximum.</param>
        /// <param name="sampleInterval">The interval between sampling the Hystrix metrics.
        /// Passed through to the <see cref="HystrixMetricsSampler"/></param>
        public HystrixMetricsStreamServer(string httpListenerPrefix, int maxConcurrentConnections, TimeSpan sampleInterval, ISampleDataProvider dataProvider = null)
            : base(ThreadName)
        {
            if (string.IsNullOrEmpty(httpListenerPrefix))
            {
                throw new ArgumentNullException("httpListenerPrefix");
            }

            if (maxConcurrentConnections <= 0)
            {
                throw new ArgumentException("Maximum number of concurrent connections must be a positive number.", "maxConcurrentConnections");
            }

            this.HttpListenerPrefix       = httpListenerPrefix;
            this.MaxConcurrentConnections = maxConcurrentConnections;
            this.SampleInterval           = sampleInterval;
            this.dataProvider             = dataProvider ?? new HystrixSampleDataProvider();
            this.sampler = new HystrixMetricsSampler(sampleInterval, this.dataProvider);
        }
        /// <summary>
        /// Acquire and process Dish Network data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            DishNetworkProgramCategory.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary Dish Network 128.cfg"), 1);
            SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary Dish Network 255.cfg"), 2);
            SingleTreeDictionaryEntry.OffsetStart = false;

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
            {
                return(CollectorReply.Cancelled);
            }

            getDishNetworkData(dataProvider, worker);

            return(CollectorReply.OK);
        }
Beispiel #19
0
        private void setMHEG5Pid(ISampleDataProvider dataProvider, Collection <TVStation> stations)
        {
            if (dataProvider.Frequency.CollectionType != CollectionType.MHEG5)
            {
                return;
            }

            foreach (TVStation station in stations)
            {
                if (dataProvider.Frequency.DSMCCPid == 0)
                {
                    dataProvider.Frequency.DSMCCPid = station.DSMCCPID;
                }

                if (!station.Excluded && station.DSMCCPID != 0 && station.Frequency == dataProvider.Frequency.Frequency)
                {
                    dataProvider.Frequency.DSMCCPid = station.DSMCCPID;
                }
            }
        }
Beispiel #20
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);
        }
Beispiel #21
0
        /// <summary>
        /// Get the stations using specified pid's.
        /// </summary>
        /// <param name="dataProvider">The sample data provider.</param>
        /// <param name="worker">The BackgroundWorker instance running the collection.</param>
        /// <param name="pids">An array of pid's to search.</param>
        protected void GetStationData(ISampleDataProvider dataProvider, BackgroundWorker worker, int[] pids)
        {
            Collection<TVStation> stations;

            if (!RunParameters.Instance.Options.Contains("USESTOREDSTATIONINFO"))
            {
                FrequencyScanner frequencyScanner = new FrequencyScanner(dataProvider, pids, true, worker);
                frequencyScanner.UseActualFrequency = false;
                stations = frequencyScanner.FindTVStations();
                if (worker.CancellationPending)
                    return;
            }
            else
            {
                if (!stationCacheLoaded)
                {
                    stations = TVStation.Load(Path.Combine(RunParameters.DataDirectory, "Station Cache.xml"));
                    if (stations == null)
                        return;

                    setMHEG5Pid(dataProvider, stations);
                    stationCacheLoaded = true;
                }
                else
                {
                    setMHEG5Pid(dataProvider, TVStation.StationCollection);
                    return;
                }
            }

            foreach (TVStation tvStation in stations)
            {
                bool include = checkChannelFilters(tvStation);

                if (include)
                {
                    TVStation existingStation = TVStation.FindStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (existingStation == null)
                    {
                        tvStation.CollectionType = dataProvider.Frequency.CollectionType;
                        bool added = TVStation.AddStation(tvStation);
                        if (added)
                            Logger.Instance.Write("Included station: " + getStationDescription(tvStation));
                    }
                    else
                    {
                        if (!existingStation.Excluded)
                        {
                            existingStation.Update(tvStation);
                            Logger.Instance.Write("Included station: " + getStationDescription(tvStation));
                        }
                        else
                            Logger.Instance.Write("Excluded station: " + getStationDescription(tvStation));
                    }
                }
                else
                    Logger.Instance.Write("Excluded station: " + getStationDescription(tvStation));

            }

            Logger.Instance.Write("Station count now: " + TVStation.StationCollection.Count);
        }
        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);
        }
Beispiel #23
0
 /// <summary>
 /// Collect EPG data.
 /// </summary>
 /// <param name="dataProvider">The provider for the data samples.</param>
 /// <param name="worker">The BackgroundWorker instance running the collection.</param>        
 /// <returns>A CollectorReply code.</returns>
 public abstract CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker);
Beispiel #24
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);
        }
Beispiel #25
0
        /// <summary>
        /// Start the collection process.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="tuningFrequency">The tuning frequency.</param>
        public void Run(ISampleDataProvider dataProvider, TuningFrequency tuningFrequency)
        {
            epgWorker = new BackgroundWorker();
            epgWorker.WorkerSupportsCancellation = true;
            epgWorker.DoWork += new DoWorkEventHandler(epgWorkerDoWork);
            epgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(epgWorkerRunWorkerCompleted);
            epgWorker.RunWorkerAsync(new BackgroundParameters(dataProvider, tuningFrequency));

            running = true;
        }
Beispiel #26
0
 public DataService(ISampleDataProvider sampleProvider, SampleMapper sampleMapper)
 {
     _sampleProvider = sampleProvider;
     _sampleMapper   = sampleMapper;
 }
        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);
        }
Beispiel #28
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);
        }
Beispiel #29
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);
        }
        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);
        }
Beispiel #31
0
 /// <summary>
 /// Initialize a new instance of the FrequencyScanner.
 /// </summary>
 /// <param name="dataProvider">A sample data provider.</param>
 /// <param name="pids">A collection of PID's to be searched.</param>
 /// <param name="searchOtherTable">True to include the 'other' stations; false otherwise</param>
 public FrequencyScanner(ISampleDataProvider dataProvider, int[] pids, bool searchOtherTable)
     : this(dataProvider, pids)
 {
     this.searchOtherTable = searchOtherTable;
 }
Beispiel #32
0
 /// <summary>
 /// Initialize a new instance of the FrequencyScanner.
 /// </summary>
 /// <param name="dataProvider">A sample data provider.</param>
 /// <param name="pids">A collection of PID's to be searched.</param>
 /// <param name="searchOtherTable">True to include the 'other' stations; false otherwise</param>
 /// <param name="worker">An optional background worker instance. Can be null.</param>
 public FrequencyScanner(ISampleDataProvider dataProvider, int[] pids, bool searchOtherTable, BackgroundWorker worker)
     : this(dataProvider, pids, searchOtherTable)
 {
     this.worker = worker;
 }
Beispiel #33
0
        private void setMHEG5Pid(ISampleDataProvider dataProvider, Collection<TVStation> stations)
        {
            if (dataProvider.Frequency.CollectionType != CollectionType.MHEG5)
                return;

            foreach (TVStation station in stations)
            {
                if (dataProvider.Frequency.DSMCCPid == 0)
                    dataProvider.Frequency.DSMCCPid = station.DSMCCPID;

                if (!station.Excluded && station.DSMCCPID != 0 && station.Frequency == dataProvider.Frequency.Frequency)
                    dataProvider.Frequency.DSMCCPid = station.DSMCCPID;
            }
        }
        private void getSummarySections(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            Logger.Instance.Write("Collecting summary data", false, true);

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

            summaryReader = new TSStreamReader(0x90, 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("ProcessMHW1Sections");

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

                summaryReader.Release("ProcessMHW1Sections");

                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 0x" + pid2.ToString("X").ToLowerInvariant());
            summaryReader.Stop();

            Logger.Instance.Write("Summary count: " + MediaHighwaySummary.Summaries.Count + " buffer space used: " + dataProvider.BufferSpaceUsed);
        }
        /// <summary>
        /// Acquire and process ATSC PSIP Info data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            AtscPsipProgramCategory.Load();
            CustomProgramCategory.Load();

            bool referenceTablesLoaded = MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary ATSC PSIP T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary ATSC PSIP T2.cfg"));
            if (!referenceTablesLoaded)
                return (CollectorReply.ReferenceDataError);

            getMasterGuideData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            getVirtualChannelData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            /*getRatingRegionData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);*/

            getExtendedTextData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            getEventInformationData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            OutputFile.UseUnicodeEncoding = MultipleString.UseUnicodeEncoding;

            return (CollectorReply.OK);
        }
Beispiel #36
0
        /// <summary>
        /// Acquire and process OpenTV data.
        /// </summary>
        /// <param name="dataProvider">A sampe data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            OpenTVProgramCategory.LoadFromCode(RunParameters.Instance.CountryCode.Trim());
            CustomProgramCategory.Load();
            ParentalRating.Load();

            bool referenceTablesLoaded = SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary " + RunParameters.Instance.CountryCode.Trim() + ".cfg"));
            if (!referenceTablesLoaded)
                return (CollectorReply.ReferenceDataError);

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            GetBouquetSections(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            getTitleSections(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            getSummarySections(dataProvider, worker);

            return (CollectorReply.OK);
        }
        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);
        }
        /// <summary>
        /// Acquire and process Dish Network data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            DishNetworkProgramCategory.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary Dish Network 128.cfg"), 1);
            SingleTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary Dish Network 255.cfg"), 2);
            SingleTreeDictionaryEntry.OffsetStart = false;

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            getDishNetworkData(dataProvider, worker);

            return (CollectorReply.OK);
        }
Beispiel #39
0
        /// <summary>
        /// Initialize a new instance of the FrequencyScanner class.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        public FrequencyScanner(ISampleDataProvider dataProvider)
        {
            this.dataProvider = dataProvider;

            pids = new int[] { BDAGraph.SdtPid } ;
        }
Beispiel #40
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);
        }
        /// <summary>
        /// Acquire and process Siehfern Info data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            /*getChannelSections(dataProvider, worker);*/
            getEPGSections(dataProvider, worker);

            return (CollectorReply.OK);
        }
 public DataTransferTestBase()
 {
     testSettings = new Lazy <ITestSettings>(LoadSettings, true);
     SampleData   = new SampleDataProvider();
 }
 public DataTransferTestBase()
 {
     testSettings = new Lazy<ITestSettings>(LoadSettings, true);
     SampleData = new SampleDataProvider();
 }
Beispiel #44
0
        /// <summary>
        /// Acquire and process EIT data.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        /// <param name="worker">The background worker that is running this collection.</param>
        /// <returns>A CollectorReply code.</returns>
        public override CollectorReply Process(ISampleDataProvider dataProvider, BackgroundWorker worker)
        {
            EITProgramContent.Load();
            CustomProgramCategory.Load();
            ParentalRating.Load();

            if (RunParameters.Instance.Options.Contains("USEFREESATTABLES"))
                MultiTreeDictionaryEntry.Load(Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T1.cfg"), Path.Combine(RunParameters.ConfigDirectory, "Huffman Dictionary FreeSat T2.cfg"));

            GetStationData(dataProvider, worker);
            if (worker.CancellationPending)
                return (CollectorReply.Cancelled);

            bool bouquetNeeded = checkBouquetNeeded();
            if (RunParameters.Instance.ChannelBouquet != -1 ||
                RunParameters.Instance.Options.Contains("USECHANNELID") ||
                RunParameters.Instance.Options.Contains("USELCN") ||
                RunParameters.Instance.Options.Contains("CREATEBRCHANNELS") ||
                RunParameters.Instance.Options.Contains("CREATEARCHANNELS"))
            {
                GetBouquetSections(dataProvider, worker);

                string bouquetType;

                if (eitChannels > 0)
                    bouquetType = "Freeview";
                else
                    bouquetType = "OpenTV";

                Logger.Instance.Write("Used " + bouquetType + " channel descriptors");

                if (worker.CancellationPending)
                    return (CollectorReply.Cancelled);
            }

            getEITSections(dataProvider, worker);

            return (CollectorReply.OK);
        }
Beispiel #45
0
 /// <summary>
 /// Get the bouquet data from the standard PID.
 /// </summary>
 /// <param name="dataProvider">The sample data provider.</param>
 /// <param name="worker">The BackgroundWorker instance running the collection.</param>
 protected void GetBouquetSections(ISampleDataProvider dataProvider, BackgroundWorker worker)
 {
     GetBouquetSections(dataProvider, worker, new int[] { 0x11 } );
 }
        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);
        }
Beispiel #47
0
 /// <summary>
 /// Get the stations using the standard SDT pid.
 /// </summary>
 /// <param name="dataProvider">The sample data provider.</param>
 /// <param name="worker">The BackgroundWorker instance running the collection.</param>
 protected void GetStationData(ISampleDataProvider dataProvider, BackgroundWorker worker)
 {
     GetStationData(dataProvider, worker, new int[] { BDAGraph.SdtPid });
 }
 /// <summary>
 /// Initialize a new instance of the FrequencyScanner.
 /// </summary>
 /// <param name="dataProvider">A sample data provider.</param>
 /// <param name="pids">A collection of PID's to be searched.</param>
 /// <param name="searchOtherTable">True to include the 'other' stations; false otherwise</param>
 public FrequencyScanner(ISampleDataProvider dataProvider, int[] pids, bool searchOtherTable) : this(dataProvider, pids)
 {
     this.searchOtherTable = searchOtherTable;
 }
Beispiel #49
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);
        }
 /// <summary>
 /// Initialize a new instance of the FrequencyScanner.
 /// </summary>
 /// <param name="dataProvider">A sample data provider.</param>
 /// <param name="pids">A collection of PID's to be searched.</param>
 /// <param name="searchOtherTable">True to include the 'other' stations; false otherwise</param>
 /// <param name="worker">An optional background worker instance. Can be null.</param>
 public FrequencyScanner(ISampleDataProvider dataProvider, int[] pids, bool searchOtherTable, BackgroundWorker worker) : this(dataProvider, pids, searchOtherTable)
 {
     this.worker = worker;
 }
Beispiel #51
0
        private void getData(ISampleDataProvider dataProvider, AnalysisParameters analysisParameters, BackgroundWorker worker)
        {
            Logger.Instance.Write("Starting analysis");

            analysisParameters.ScanningFrequency.CollectionType = CollectionType.MHEG5;
            FrequencyScanner       frequencyScanner = new FrequencyScanner(dataProvider, worker);
            Collection <TVStation> stations         = frequencyScanner.FindTVStations();

            pidList = new Collection <PidSpec>();

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

            IntPtr memoryPointer = dataProvider.BufferAddress;
            int    currentOffset = 0;

            byte[]   buffer       = new byte[188];
            DateTime startTime    = DateTime.Now;
            int      packetCount  = 0;
            int      errorPackets = 0;
            int      nullPackets  = 0;

            while ((DateTime.Now - startTime).TotalSeconds < analysisParameters.DataCollectionTimeout && !worker.CancellationPending)
            {
                if (currentOffset >= dataProvider.BufferSpaceUsed)
                {
                    Thread.Sleep(2000);
                    if (currentOffset >= dataProvider.BufferSpaceUsed)
                    {
                        Logger.Instance.Write("Analysis resetting pid after " + packetCount + " packets (errors = " + errorPackets + " null = " + nullPackets + ")");
                        dataProvider.ChangePidMapping(new int[] { -1 });
                        currentOffset = 0;
                    }
                }
                else
                {
                    IntPtr currentPointer = new IntPtr(memoryPointer.ToInt64() + currentOffset + 136);
                    Marshal.Copy(currentPointer, buffer, 0, 188);
                    packetCount++;

                    /*if (dumpCount < 10000)
                     * {
                     *  Logger.Instance.Dump("atsc " + dumpCount, buffer, buffer.Length);
                     *  dumpCount++;
                     * }*/

                    TransportPacket transportPacket = new TransportPacket();

                    try
                    {
                        transportPacket.Process(buffer);

                        if (transportPacket.ErrorIndicator)
                        {
                            errorPackets++;
                        }
                        if (transportPacket.IsNullPacket)
                        {
                            nullPackets++;
                        }

                        if (!transportPacket.ErrorIndicator)
                        {
                            bool ignorePid = checkPid(transportPacket.PID, stations);
                            if (!ignorePid)
                            {
                                PidSpec pidSpec = findPidSpec(pidList, transportPacket.PID);
                                if (pidSpec == null)
                                {
                                    pidSpec = new PidSpec(transportPacket.PID);
                                    addPid(pidList, new PidSpec(transportPacket.PID));
                                }
                                pidSpec.ProcessPacket(buffer, transportPacket);
                            }
                        }
                        else
                        {
                            Logger.Instance.Write("Transport packet error in packet " + packetCount);
                        }
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        Logger.Instance.Write("Failed to parse packet " + packetCount);
                    }

                    currentOffset += buffer.Length;
                }
            }

            Logger.Instance.Write("Analysis completed: " + pidList.Count + " PID's loaded from " + packetCount + " packets");
        }
        /// <summary>
        /// Initialize a new instance of the FrequencyScanner class.
        /// </summary>
        /// <param name="dataProvider">A sample data provider.</param>
        public FrequencyScanner(ISampleDataProvider dataProvider)
        {
            this.dataProvider = dataProvider;

            pids = new int[] { BDAGraph.SdtPid };
        }
        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);
        }
        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);
        }
        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);
        }
 /// <summary>
 /// Initialize a new instance of the FrequencyScanner.
 /// </summary>
 /// <param name="dataProvider">A sample data provider.</param>
 /// <param name="pids">A collection of PID's to be searched.</param>
 public FrequencyScanner(ISampleDataProvider dataProvider, int[] pids) : this(dataProvider)
 {
     this.pids = pids;
 }
        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);
        }
Beispiel #58
0
 internal BackgroundParameters(ISampleDataProvider dataProvider, TuningFrequency tuningFrequency)
 {
     this.dataProvider = dataProvider;
     this.tuningFrequency = tuningFrequency;
 }
        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);
        }
Beispiel #60
0
 /// <summary>
 /// Initialize a new instance of the FrequencyScanner.
 /// </summary>
 /// <param name="dataProvider">A sample data provider.</param>
 /// <param name="pids">A collection of PID's to be searched.</param>
 public FrequencyScanner(ISampleDataProvider dataProvider, int[] pids)
     : this(dataProvider)
 {
     this.pids = pids;
 }