Exemple #1
0
        private bool checkChannelMapping(TVStation tvStation)
        {
            Bouquet bouquet = Bouquet.FindBouquet(RunParameters.Instance.ChannelBouquet);

            if (bouquet == null)
            {
                return(false);
            }

            Region region = bouquet.FindRegion(RunParameters.Instance.ChannelRegion);

            if (region == null)
            {
                return(false);
            }

            Channel channel = region.FindChannel(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);

            if (channel == null)
            {
                return(false);
            }

            if (tvStation.LogicalChannelNumber != -1)
            {
                return(true);
            }

            tvStation.LogicalChannelNumber = channel.UserChannel;

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Add a bouquet to the collection.
        /// </summary>
        /// <param name="newBouquet">The bouquet to be added.</param>
        public static void AddBouquet(Bouquet newBouquet)
        {
            foreach (Bouquet oldBouquet in Bouquets)
            {
                if (oldBouquet.BouquetID == newBouquet.BouquetID && oldBouquet.Region == newBouquet.Region)
                {
                    return;
                }
            }

            bouquets.Add(newBouquet);
        }
Exemple #3
0
        private void logChannelInfo()
        {
            if (!RunParameters.Instance.DebugIDs.Contains("LOGCHANNELS"))
            {
                return;
            }

            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"))
            {
                return;
            }

            Logger.Instance.WriteSeparator("Bouquet Usage");

            bool firstBouquet = true;

            foreach (Bouquet bouquet in Bouquet.GetBouquetsInNameOrder())
            {
                if (!firstBouquet)
                {
                    Logger.Instance.Write("");
                }

                firstBouquet = false;

                if (!firstBouquet)
                {
                    Logger.Instance.Write("");
                }

                firstBouquet = false;

                foreach (Region region in bouquet.Regions)
                {
                    Logger.Instance.Write("Bouquet: " + bouquet.BouquetID + " - " + bouquet.Name + " Region: " + region.Code + " (channels = " + region.Channels.Count + ")");

                    foreach (Channel channel in region.GetChannelsInNameOrder())
                    {
                        Logger.Instance.Write("    Channel: " + channel.ToString());
                    }
                }
            }
        }
Exemple #4
0
        private void processOpenTVInfoDescriptor(OpenTVChannelInfoDescriptor openTVInfoDescriptor, int originalNetworkID, int transportStreamID, int bouquetID)
        {
            if (openTVInfoDescriptor.ChannelInfoEntries == null)
            {
                return;
            }

            if (eitChannels != 0)
            {
                OpenTVChannel.Channels.Clear();
                eitChannels = 0;
                return;
            }

            foreach (OpenTVChannelInfoEntry channelInfoEntry in openTVInfoDescriptor.ChannelInfoEntries)
            {
                OpenTVChannel channel = new OpenTVChannel();
                channel.OriginalNetworkID = originalNetworkID;
                channel.TransportStreamID = transportStreamID;
                channel.ServiceID         = channelInfoEntry.ServiceID;
                channel.ChannelID         = channelInfoEntry.ChannelID;
                channel.UserChannel       = channelInfoEntry.UserNumber;
                channel.Type      = channelInfoEntry.Type;
                channel.Flags     = channelInfoEntry.Flags;
                channel.BouquetID = bouquetID;
                channel.Region    = openTVInfoDescriptor.Region;
                OpenTVChannel.AddChannel(channel);

                openTVChannels++;

                Bouquet bouquet = Bouquet.FindBouquet(channel.BouquetID);
                if (bouquet == null)
                {
                    bouquet = new Bouquet(channel.BouquetID, BouquetAssociationSection.FindBouquetName(channel.BouquetID));
                    Bouquet.AddBouquet(bouquet);
                }

                Region region = bouquet.FindRegion(channel.Region);
                if (region == null)
                {
                    region = new Region(string.Empty, channel.Region);
                    bouquet.AddRegion(region);
                }

                region.AddChannel(channel);
            }
        }
        /// <summary>
        /// Process the bouquet data.
        /// </summary>
        /// <param name="sections">A collection of MPEG2 sections containing the bouquet data.</param>
        protected override void ProcessBouquetSections(Collection <Mpeg2Section> sections)
        {
            foreach (Mpeg2Section section in sections)
            {
                if (RunParameters.Instance.TraceIDs.Contains("BOUQUETSECTIONS"))
                {
                    Logger.Instance.Dump("Bouquet Section", section.Data, section.Length);
                }

                BouquetAssociationSection bouquetSection = BouquetAssociationSection.ProcessBouquetAssociationTable(section.Data);
                if (bouquetSection != null)
                {
                    bool added = BouquetAssociationSection.AddSection(bouquetSection);
                    if (added)
                    {
                        if (bouquetSection.TransportStreams != null)
                        {
                            foreach (TransportStream transportStream in bouquetSection.TransportStreams)
                            {
                                if (transportStream.Descriptors != null)
                                {
                                    foreach (DescriptorBase descriptor in transportStream.Descriptors)
                                    {
                                        FreeSatChannelInfoDescriptor freeSatInfoDescriptor = descriptor as FreeSatChannelInfoDescriptor;
                                        if (freeSatInfoDescriptor != null)
                                        {
                                            if (freeSatInfoDescriptor.ChannelInfoEntries != null)
                                            {
                                                foreach (FreeSatChannelInfoEntry channelInfoEntry in freeSatInfoDescriptor.ChannelInfoEntries)
                                                {
                                                    FreeSatChannel channel = new FreeSatChannel();
                                                    channel.OriginalNetworkID = transportStream.OriginalNetworkID;
                                                    channel.TransportStreamID = transportStream.TransportStreamID;
                                                    channel.ServiceID         = channelInfoEntry.ServiceID;
                                                    channel.UserChannel       = channelInfoEntry.UserNumber;
                                                    channel.Unknown1          = channelInfoEntry.Unknown1;
                                                    channel.Unknown2          = channelInfoEntry.Unknown2;
                                                    channel.BouquetID         = bouquetSection.BouquetID;
                                                    FreeSatChannel.AddChannel(channel);

                                                    Bouquet bouquet = Bouquet.FindBouquet(channel.BouquetID);
                                                    if (bouquet == null)
                                                    {
                                                        bouquet = new Bouquet(channel.BouquetID, BouquetAssociationSection.FindBouquetName(channel.BouquetID));
                                                        Bouquet.AddBouquet(bouquet);
                                                    }

                                                    Region region = bouquet.FindRegion(channel.Region);
                                                    if (region == null)
                                                    {
                                                        region = new Region(string.Empty, channel.Region);
                                                        bouquet.AddRegion(region);
                                                    }

                                                    region.AddChannel(channel);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
        private static void addBouquetInNameOrder(Collection <Bouquet> sortedBouquets, Bouquet newBouquet)
        {
            foreach (Bouquet oldBouquet in sortedBouquets)
            {
                if (oldBouquet.Name.CompareTo(newBouquet.Name) > 0)
                {
                    sortedBouquets.Insert(sortedBouquets.IndexOf(oldBouquet), newBouquet);
                    return;
                }
            }

            sortedBouquets.Add(newBouquet);
        }
        /// <summary>
        /// Carry out the processing after all data has been collected for a frequency.
        /// </summary>
        public override void FinishFrequency()
        {
            if (OpenTVChannel.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger               = null;
            Logger descriptionLogger         = null;
            Logger extendedDescriptionLogger = null;
            Logger undefinedRecordLogger     = null;

            if (RunParameters.Instance.DebugIDs.Contains("LOGTITLES"))
            {
                titleLogger = new Logger("EPG Titles.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGDESCRIPTIONS"))
            {
                descriptionLogger = new Logger("EPG Descriptions.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGEXTENDEDDESCRIPTIONS"))
            {
                extendedDescriptionLogger = new Logger("EPG Extended Descriptions.log");
            }
            if (RunParameters.Instance.DebugIDs.Contains("LOGUNDEFINEDRECORDS"))
            {
                undefinedRecordLogger = new Logger("EPG Undefined Records.log");
            }

            foreach (OpenTVChannel channel in OpenTVChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station != null)
                {
                    if (station.EPGCollection.Count == 0)
                    {
                        channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, extendedDescriptionLogger, undefinedRecordLogger);
                        channel.CreateChannelMapping(station);
                    }
                }
            }

            if (RunParameters.Instance.DebugIDs.Contains("LOGCHANNELS"))
            {
                Logger.Instance.WriteSeparator("Bouquet Usage");

                bool firstBouquet = true;

                foreach (Bouquet bouquet in Bouquet.GetBouquetsInNameOrder())
                {
                    if (!firstBouquet)
                    {
                        Logger.Instance.Write("");
                    }

                    firstBouquet = false;

                    foreach (Region region in bouquet.Regions)
                    {
                        Logger.Instance.Write("Bouquet: " + bouquet.BouquetID + " - " + bouquet.Name + " Region: " + region.Code + " (channels = " + region.Channels.Count + ")");

                        foreach (Channel channel in region.GetChannelsInNameOrder())
                        {
                            Logger.Instance.Write("    Channel: " + channel.ToString());
                        }
                    }
                }
            }

            int count = 0;

            foreach (TuningFrequency frequency in TuningFrequency.FrequencyCollection)
            {
                if (frequency.CollectionType == CollectionType.OpenTV)
                {
                    count++;
                }
            }

            if (count > 1)
            {
                bool frequencyFirst = true;

                foreach (TuningFrequency frequency in TuningFrequency.FrequencyCollection)
                {
                    if (frequency.CollectionType == CollectionType.OpenTV)
                    {
                        if (frequencyFirst)
                        {
                            Logger.Instance.WriteSeparator("Frequency Usage");
                            frequencyFirst = false;
                        }
                        Logger.Instance.Write("Frequency " + frequency.Frequency + " usage count " + frequency.UsageCount);
                    }
                }
            }

            OpenTVProgramCategory.LogCategoryUsage();

            if (RunParameters.Instance.DebugIDs.Contains("LOGCHANNELDATA"))
            {
                if (OpenTVChannel.Channels.Count != 0)
                {
                    Logger.Instance.WriteSeparator("Channel Data - ID Sequence");

                    foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    {
                        channel.LogChannelMapping(Logger.Instance);
                    }

                    Collection <OpenTVChannel> sortedChannels = new Collection <OpenTVChannel>();

                    foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    {
                        addByUserChannel(sortedChannels, channel);
                    }

                    Logger.Instance.WriteSeparator("Channel Data - User Channel Sequence");

                    foreach (OpenTVChannel channel in sortedChannels)
                    {
                        channel.LogChannelMapping(Logger.Instance);
                    }

                    sortedChannels = new Collection <OpenTVChannel>();

                    foreach (OpenTVChannel channel in OpenTVChannel.Channels)
                    {
                        addByFlags(sortedChannels, channel);
                    }

                    Logger.Instance.WriteSeparator("Channel Data - Flags Sequence");

                    foreach (OpenTVChannel channel in sortedChannels)
                    {
                        channel.LogChannelMapping(Logger.Instance);
                    }
                }
            }
        }
        /// <summary>
        /// Process the bouquet data.
        /// </summary>
        /// <param name="sections">A collection of MPEG2 sections containing the bouquet data.</param>
        protected override void ProcessBouquetSections(Collection <Mpeg2Section> sections)
        {
            foreach (Mpeg2Section section in sections)
            {
                BouquetAssociationSection bouquetSection = BouquetAssociationSection.ProcessBouquetAssociationTable(section.Data);
                if (bouquetSection != null)
                {
                    bool added = BouquetAssociationSection.AddSection(bouquetSection);
                    if (added)
                    {
                        if (bouquetSection.TransportStreams != null)
                        {
                            foreach (TransportStream transportStream in bouquetSection.TransportStreams)
                            {
                                if (transportStream.Descriptors != null)
                                {
                                    foreach (DescriptorBase descriptor in transportStream.Descriptors)
                                    {
                                        OpenTVChannelInfoDescriptor infoDescriptor = descriptor as OpenTVChannelInfoDescriptor;
                                        if (infoDescriptor != null)
                                        {
                                            if (infoDescriptor.ChannelInfoEntries != null)
                                            {
                                                foreach (OpenTVChannelInfoEntry channelInfoEntry in infoDescriptor.ChannelInfoEntries)
                                                {
                                                    OpenTVChannel channel = new OpenTVChannel();
                                                    channel.OriginalNetworkID = transportStream.OriginalNetworkID;
                                                    channel.TransportStreamID = transportStream.TransportStreamID;
                                                    channel.ServiceID         = channelInfoEntry.ServiceID;
                                                    channel.ChannelID         = channelInfoEntry.ChannelID;
                                                    channel.UserChannel       = channelInfoEntry.UserNumber;
                                                    channel.Type      = channelInfoEntry.Type;
                                                    channel.Flags     = channelInfoEntry.Flags;
                                                    channel.BouquetID = bouquetSection.BouquetID;
                                                    channel.Region    = infoDescriptor.Region;
                                                    OpenTVChannel.AddChannel(channel);

                                                    Bouquet bouquet = Bouquet.FindBouquet(channel.BouquetID);
                                                    if (bouquet == null)
                                                    {
                                                        bouquet = new Bouquet(channel.BouquetID, BouquetAssociationSection.FindBouquetName(channel.BouquetID));
                                                        Bouquet.AddBouquet(bouquet);
                                                    }

                                                    Region region = bouquet.FindRegion(channel.Region);
                                                    if (region == null)
                                                    {
                                                        region = new Region(string.Empty, channel.Region);
                                                        bouquet.AddRegion(region);
                                                    }

                                                    region.AddChannel(channel);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }