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 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); }