Beispiel #1
0
        /// <summary>
        /// Add a section to the collection.
        /// </summary>
        /// <param name="newSection">The section to be added.</param>
        /// <returns>True if the section was added; false it it already existed in the collection.</returns>
        public static bool AddSection(BouquetAssociationSection newSection)
        {
            foreach (BouquetAssociationSection oldSection in BouquetAssociationSections)
            {
                if (oldSection.BouquetID == newSection.BouquetID && oldSection.SectionNumber == newSection.SectionNumber)
                {
                    return(false);
                }

                if (oldSection.BouquetID == newSection.BouquetID && oldSection.SectionNumber > newSection.SectionNumber)
                {
                    BouquetAssociationSections.Insert(BouquetAssociationSections.IndexOf(oldSection), newSection);
                    return(true);
                }

                if (oldSection.BouquetID > newSection.BouquetID)
                {
                    BouquetAssociationSections.Insert(BouquetAssociationSections.IndexOf(oldSection), newSection);
                    return(true);
                }
            }

            BouquetAssociationSections.Add(newSection);

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Find the name of a specified bouquet.
        /// </summary>
        /// <param name="bouquetID">The ID of the bouquet.</param>
        /// <returns>The name or null if the bouquet cannot be located.</returns>
        public static string FindBouquetName(int bouquetID)
        {
            BouquetAssociationSection bouquetSection = FindBouquet(bouquetID);

            if (bouquetSection == null)
            {
                return(null);
            }

            return(bouquetSection.Name);
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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)
            {
                if (RunParameters.Instance.DebugIDs.Contains("BOUQUETSECTIONS"))
                {
                    Logger.Instance.Dump("Bouquet Section", section.Data, section.Data.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)
                                    {
                                        FreeviewChannelInfoDescriptor freeviewInfoDescriptor = descriptor as FreeviewChannelInfoDescriptor;
                                        if (freeviewInfoDescriptor != null)
                                        {
                                            processFreeviewInfoDescriptor(freeviewInfoDescriptor, transportStream.OriginalNetworkID, transportStream.TransportStreamID, bouquetSection.BouquetID);
                                        }
                                        else
                                        {
                                            OpenTVChannelInfoDescriptor openTVInfoDescriptor = descriptor as OpenTVChannelInfoDescriptor;
                                            if (openTVInfoDescriptor != null)
                                            {
                                                processOpenTVInfoDescriptor(openTVInfoDescriptor, transportStream.OriginalNetworkID, transportStream.TransportStreamID, bouquetSection.BouquetID);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Process an MPEG2 section from the bouquet association table.
        /// </summary>
        /// <param name="byteData">The MPEG2 section.</param>
        /// <returns>A Bouquet Association instance.</returns>
        public static BouquetAssociationSection ProcessBouquetAssociationTable(byte[] byteData)
        {
            Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();

            try
            {
                mpeg2Header.Process(byteData);

                if (mpeg2Header.Current)
                {
                    BouquetAssociationSection bouquetAssociationSection = new BouquetAssociationSection();

                    bouquetAssociationSection.Process(byteData, mpeg2Header);
                    bouquetAssociationSection.LogMessage();
                    return(bouquetAssociationSection);
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Logger.Instance.Write("<e> Error processing Bouquet Association Section message: " + e.Message);
            }

            return(null);
        }
        /// <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);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Process an MPEG2 section from the bouquet association table.
        /// </summary>
        /// <param name="byteData">The MPEG2 section.</param>
        /// <returns>A Bouquet Association instance.</returns>
        public static BouquetAssociationSection ProcessBouquetAssociationTable(byte[] byteData)
        {
            Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();

            try
            {
                mpeg2Header.Process(byteData);

                if (mpeg2Header.Current)
                {
                    BouquetAssociationSection bouquetAssociationSection = new BouquetAssociationSection();

                    bouquetAssociationSection.Process(byteData, mpeg2Header);
                    bouquetAssociationSection.LogMessage();
                    return (bouquetAssociationSection);
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Logger.Instance.Write("<e> Error processing Bouquet Association Section message: " + e.Message);
            }

            return (null);
        }
        /// <summary>
        /// Add a section to the collection.
        /// </summary>
        /// <param name="newSection">The section to be added.</param>
        /// <returns>True if the section was added; false it it already existed in the collection.</returns>
        public static bool AddSection(BouquetAssociationSection newSection)
        {
            foreach (BouquetAssociationSection oldSection in BouquetAssociationSections)
            {
                if (oldSection.BouquetID == newSection.BouquetID && oldSection.SectionNumber == newSection.SectionNumber)
                    return (false);

                if (oldSection.BouquetID == newSection.BouquetID && oldSection.SectionNumber > newSection.SectionNumber)
                {
                    BouquetAssociationSections.Insert(BouquetAssociationSections.IndexOf(oldSection), newSection);
                    return (true);
                }

                if (oldSection.BouquetID > newSection.BouquetID)
                {
                    BouquetAssociationSections.Insert(BouquetAssociationSections.IndexOf(oldSection), newSection);
                    return (true);
                }
            }

            BouquetAssociationSections.Add(newSection);

            return (true);
        }
        /// <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);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }