示例#1
0
        private static bool checkChannelBouquet(OpenTVChannel channel)
        {
            if (RunParameters.Instance.ChannelBouquet == -1)
                return (true);

            if (channel.BouquetID != RunParameters.Instance.ChannelBouquet)
                return (false);

            if (channel.Region == 65535 || channel.Region == RunParameters.Instance.ChannelRegion)
                return (true);

            return (false);
        }
示例#2
0
        /// <summary>
        /// Add a channel to the collection.
        /// </summary>
        /// <param name="newChannel">The channel to be added.</param>
        public static void AddChannel(OpenTVChannel newChannel)
        {
            if (newChannel.Type == 0)
                return;

            bool process = checkChannelBouquet(newChannel);
            if (!process)
                return;

            if (RunParameters.Instance.TraceIDs.Contains("ADDCHANNEL"))
            {
                string flagsString;
                if (newChannel.Flags != null)
                    flagsString = Utils.ConvertToHex(newChannel.Flags);
                else
                    flagsString = "???";

                string bouquetName = BouquetAssociationSection.FindBouquetName(newChannel.BouquetID);
                if (bouquetName == null)
                    bouquetName = "** No Name **";

                Logger.Instance.Write("Adding channel: ONID " + newChannel.OriginalNetworkID +
                    " TSID " + newChannel.TransportStreamID +
                    " SID " + newChannel.ServiceID +
                    " Channel ID: " + newChannel.ChannelID +
                    " User Channel: " + newChannel.UserChannel +
                    " Type: " + newChannel.Type +
                    " Flags: " + flagsString +
                    " Bqt ID: " + newChannel.BouquetID +
                    " Bqt name: " + bouquetName +
                    " Region: " + newChannel.Region);
            }

            foreach (OpenTVChannel oldChannel in Channels)
            {
                if (oldChannel.OriginalNetworkID == newChannel.OriginalNetworkID &&
                    oldChannel.TransportStreamID == newChannel.TransportStreamID &&
                    oldChannel.ServiceID == newChannel.ServiceID &&
                    oldChannel.ChannelID == newChannel.ChannelID)
                {
                    if (RunParameters.Instance.TraceIDs.Contains("ADDCHANNEL"))
                    {
                        string bouquetName = BouquetAssociationSection.FindBouquetName(oldChannel.BouquetID);
                        if (bouquetName == null)
                            bouquetName = "** No Name **";
                        Logger.Instance.Write("Already exists in bouquet " + bouquetName);
                    }
                    return;
                }

                if (oldChannel.OriginalNetworkID == newChannel.OriginalNetworkID)
                {
                    if (oldChannel.TransportStreamID == newChannel.TransportStreamID)
                    {
                        if (oldChannel.ServiceID == newChannel.ServiceID)
                        {
                            if (oldChannel.ChannelID > newChannel.ChannelID)
                            {
                                Channels.Insert(Channels.IndexOf(oldChannel), newChannel);
                                return;
                            }
                        }
                        else
                        {
                            if (oldChannel.ServiceID > newChannel.ServiceID)
                            {
                                Channels.Insert(Channels.IndexOf(oldChannel), newChannel);
                                return;
                            }
                        }
                    }
                    else
                    {
                        if (oldChannel.TransportStreamID > newChannel.TransportStreamID)
                        {
                            Channels.Insert(Channels.IndexOf(oldChannel), newChannel);
                            return;
                        }
                    }
                }
                else
                {
                    if (oldChannel.OriginalNetworkID > newChannel.OriginalNetworkID)
                    {
                        Channels.Insert(Channels.IndexOf(oldChannel), newChannel);
                        return;
                    }
                }
            }

            Channels.Add(newChannel);
        }
示例#3
0
        private void addByUserChannel(Collection<OpenTVChannel> sortedChannels, OpenTVChannel newChannel)
        {
            foreach (OpenTVChannel oldChannel in sortedChannels)
            {
                if (newChannel.UserChannel < oldChannel.UserChannel)
                {
                    sortedChannels.Insert(sortedChannels.IndexOf(oldChannel), newChannel);
                    return;
                }
            }

            sortedChannels.Add(newChannel);
        }
示例#4
0
        private void addByFlags(Collection<OpenTVChannel> sortedChannels, OpenTVChannel newChannel)
        {
            foreach (OpenTVChannel oldChannel in sortedChannels)
            {
                if (compareFlags(newChannel.Flags, oldChannel.Flags) < 0)
                {
                    sortedChannels.Insert(sortedChannels.IndexOf(oldChannel), newChannel);
                    return;
                }
            }

            sortedChannels.Add(newChannel);
        }
示例#5
0
        /// <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);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#6
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);
            }
        }