Exemplo n.º 1
0
        private void processVirtualChannelTable(Collection <Mpeg2Section> sections, int frequency)
        {
            foreach (Mpeg2Section section in sections)
            {
                if (RunParameters.Instance.DebugIDs.Contains("VIRTUALCHANNELTABLE"))
                {
                    Logger.Instance.Dump("PSIP Virtual Channel Table", section.Data, section.Data.Length);
                }

                try
                {
                    Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();
                    mpeg2Header.Process(section.Data);
                    if (mpeg2Header.Current)
                    {
                        VirtualChannelTable virtualChannelTable = new VirtualChannelTable();
                        virtualChannelTable.Process(section.Data, mpeg2Header, (mpeg2Header.TableID == 0xc9), frequency);
                        VirtualChannelTable.AddSectionNumber(mpeg2Header.SectionNumber);
                    }
                }
                catch (ArgumentOutOfRangeException e)
                {
                    Logger.Instance.Write("PSIP error: " + e.Message);
                }
            }
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        private void processEvent(int frequency, int sourceID, EventInformationTableEntry eventEntry)
        {
            VirtualChannel channel = VirtualChannelTable.FindChannel(frequency, sourceID);

            if (channel == null)
            {
                return;
            }

            EPGEntry epgEntry = new EPGEntry();

            epgEntry.EventID = eventEntry.EventID;

            if (eventEntry.EventName != null)
            {
                epgEntry.EventName = eventEntry.EventName.ToString().Replace("\0", "");
            }
            else
            {
                epgEntry.EventName = "No Event Name";
            }

            if (eventEntry.ETMLocation == 1 || eventEntry.ETMLocation == 2)
            {
                ExtendedTextTableEntry textEntry = ExtendedTextTable.FindEntry(sourceID, eventEntry.EventID);
                if (textEntry != null)
                {
                    epgEntry.ShortDescription = textEntry.Text.ToString().Replace("\0", "");
                }
            }

            epgEntry.StartTime            = Utils.RoundTime(TimeOffsetEntry.GetAdjustedTime(eventEntry.StartTime));
            epgEntry.Duration             = Utils.RoundTime(eventEntry.Duration);
            epgEntry.EventCategory        = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, eventEntry);
            epgEntry.ParentalRating       = eventEntry.ParentalRating;
            epgEntry.ParentalRatingSystem = "VCHIP";
            epgEntry.AudioQuality         = eventEntry.AudioQuality;
            epgEntry.EPGSource            = EPGSource.PSIP;

            channel.AddEPGEntry(epgEntry);
        }
Exemplo n.º 4
0
        private void processVirtualChannelTable(Collection<Mpeg2Section> sections, int frequency)
        {
            foreach (Mpeg2Section section in sections)
            {
                if (RunParameters.Instance.DebugIDs.Contains("VIRTUALCHANNELTABLE"))
                    Logger.Instance.Dump("PSIP Virtual Channel Table", section.Data, section.Data.Length);

                try
                {
                    Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();
                    mpeg2Header.Process(section.Data);
                    if (mpeg2Header.Current)
                    {
                        VirtualChannelTable virtualChannelTable = new VirtualChannelTable();
                        virtualChannelTable.Process(section.Data, mpeg2Header, (mpeg2Header.TableID == 0xc9), frequency);
                        VirtualChannelTable.AddSectionNumber(mpeg2Header.SectionNumber);
                        virtualChannelTable.LogMessage();
                    }
                }
                catch (ArgumentOutOfRangeException e)
                {
                    Logger.Instance.Write("<e> PSIP error: " + e.Message);
                }
            }
        }
Exemplo n.º 5
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);
        }