Пример #1
0
        /// <summary>
        /// Process an MPEG2 section from the network information table.
        /// </summary>
        /// <param name="byteData">The MPEG2 section.</param>
        /// <returns>A Network Information section instance.</returns>
        public static NetworkInformationSection ProcessNetworkInformationTable(byte[] byteData)
        {
            Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();

            try
            {
                mpeg2Header.Process(byteData);

                if (mpeg2Header.Current)
                {
                    NetworkInformationSection networkInformationSection = new NetworkInformationSection();
                    networkInformationSection.Process(byteData, mpeg2Header);

                    if (RunParameters.Instance.DebugIDs.Contains("NITSECTIONS"))
                    {
                        networkInformationSection.LogMessage();
                    }

                    return(networkInformationSection);
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Logger.Instance.Write("<e> Error processing Network Information Section message: " + e.Message);
            }

            return(null);
        }
Пример #2
0
        private void processServiceDescriptionSection(ServiceDescriptionSection serviceDescriptionSection, Collection <TVStation> tvStations, TuningFrequency frequency)
        {
            foreach (ServiceDescription serviceDescription in serviceDescriptionSection.ServiceDescriptions)
            {
                bool processStation = checkServiceInfo(serviceDescription);

                if (processStation)
                {
                    TVStation tvStation = new TVStation(serviceDescription.ServiceName);
                    tvStation.ProviderName = serviceDescription.ProviderName;
                    if (useActualFrequency)
                    {
                        tvStation.Frequency = NetworkInformationSection.GetFrequency(serviceDescriptionSection.OriginalNetworkID, serviceDescriptionSection.TransportStreamID) * 10;
                        if (tvStation.Frequency == 0)
                        {
                            tvStation.Frequency = frequency.Frequency;
                            Logger.Instance.Write("Station : " + tvStation.Name + " not found in Network Information Table");
                        }
                    }
                    else
                    {
                        tvStation.Frequency = frequency.Frequency;
                    }

                    tvStation.OriginalNetworkID      = serviceDescriptionSection.OriginalNetworkID;
                    tvStation.TransportStreamID      = serviceDescriptionSection.TransportStreamID;
                    tvStation.ServiceID              = serviceDescription.ServiceID;
                    tvStation.Encrypted              = serviceDescription.Scrambled;
                    tvStation.ServiceType            = serviceDescription.ServiceType;
                    tvStation.ScheduleAvailable      = serviceDescription.EITSchedule;
                    tvStation.NextFollowingAvailable = serviceDescription.EITPresentFollowing;

                    tvStation.TunerType = frequency.TunerType;
                    if (frequency.TunerType == TunerType.Satellite)
                    {
                        Satellite satellite = ((SatelliteFrequency)frequency).Provider as Satellite;
                        if (satellite != null)
                        {
                            tvStation.Satellite = satellite;
                        }
                    }

                    if (RunParameters.Instance.Options.Contains("USECHANNELID"))
                    {
                        if (serviceDescription.ChannelNumber != -1)
                        {
                            tvStation.OriginalChannelNumber = serviceDescription.ChannelNumber;
                        }
                    }

                    addStation(tvStations, tvStation);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Add a network information section.
        /// </summary>
        /// <param name="newSection">The section to be added.</param>
        /// <returns>True if the section was added; false otherwise.</returns>
        public static bool AddSection(NetworkInformationSection newSection)
        {
            foreach (NetworkInformationSection oldSection in NetworkInformationSections)
            {
                if (oldSection.NetworkID == newSection.NetworkID && oldSection.SectionNumber == newSection.SectionNumber)
                {
                    return(false);
                }

                if (oldSection.NetworkID == newSection.NetworkID && oldSection.SectionNumber > newSection.SectionNumber)
                {
                    NetworkInformationSections.Insert(NetworkInformationSections.IndexOf(oldSection), newSection);
                    if (Logger.ProtocolLogger != null)
                    {
                        Logger.ProtocolLogger.Write("NID " + newSection.NetworkID + " Section " + newSection.SectionNumber + " inserted");
                    }
                    return(true);
                }

                if (oldSection.NetworkID > newSection.NetworkID)
                {
                    NetworkInformationSections.Insert(NetworkInformationSections.IndexOf(oldSection), newSection);
                    if (Logger.ProtocolLogger != null)
                    {
                        Logger.ProtocolLogger.Write("NID " + newSection.NetworkID + " Section " + newSection.SectionNumber + " inserted");
                    }
                    return(true);
                }
            }

            NetworkInformationSections.Add(newSection);
            if (Logger.ProtocolLogger != null)
            {
                Logger.ProtocolLogger.Write("NID " + newSection.NetworkID + " Section " + newSection.SectionNumber + " added");
            }

            return(true);
        }
Пример #4
0
        private void processNITSections(BackgroundWorker worker)
        {
            if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
            {
                Logger.Instance.Write("Collecting network information data", false, true);
            }
            else
            {
                Logger.Instance.Write("Collecting network information data");
            }

            dataProvider.ChangePidMapping(new int[] { BDAGraph.NitPid });

            Collection <byte> tables = new Collection <byte>();

            tables.Add(0x40);
            tables.Add(0x41);
            TSReaderBase nitReader = new TSStreamReader(tables, 50000, dataProvider.BufferAddress);

            nitReader.Run();

            bool done      = false;
            int  lastCount = 0;
            int  repeats   = 0;

            while (!done)
            {
                if (worker != null && worker.CancellationPending)
                {
                    nitReader.Stop();
                    return;
                }

                Thread.Sleep(2000);

                if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
                {
                    Logger.Instance.Write(".", false, false);
                }
                else
                {
                    Logger.Instance.Write("Buffer space used " + dataProvider.BufferSpaceUsed);
                }

                Collection <Mpeg2Section> sections = new Collection <Mpeg2Section>();

                nitReader.Lock("ProcessNITSections");
                if (nitReader.Sections.Count != 0)
                {
                    foreach (Mpeg2Section section in nitReader.Sections)
                    {
                        sections.Add(section);
                    }
                    nitReader.Sections.Clear();
                }
                nitReader.Release("ProcessNITSections");

                foreach (Mpeg2Section section in sections)
                {
                    NetworkInformationSection networkInformationSection = NetworkInformationSection.ProcessNetworkInformationTable(section.Data);
                    if (networkInformationSection != null)
                    {
                        NetworkInformationSection.AddSection(networkInformationSection);
                    }
                }

                if (NetworkInformationSection.NetworkInformationSections.Count == lastCount)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
                else
                {
                    repeats = 0;
                }

                lastCount = NetworkInformationSection.NetworkInformationSections.Count;
            }

            if (!RunParameters.Instance.TraceIDs.Contains("BDA"))
            {
                Logger.Instance.Write("", true, false);
            }

            Logger.Instance.Write("Stopping network information reader for frequency " + dataProvider.Frequency);
            nitReader.Stop();
        }
        /// <summary>
        /// Process an MPEG2 section from the network information table.
        /// </summary>
        /// <param name="byteData">The MPEG2 section.</param>
        /// <returns>A Network Information section instance.</returns>
        public static NetworkInformationSection ProcessNetworkInformationTable(byte[] byteData)
        {
            Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();

            try
            {
                mpeg2Header.Process(byteData);

                if (mpeg2Header.Current)
                {
                    NetworkInformationSection networkInformationSection = new NetworkInformationSection();
                    networkInformationSection.Process(byteData, mpeg2Header);

                    if (RunParameters.Instance.DebugIDs.Contains("NITSECTIONS"))
                        networkInformationSection.LogMessage();

                    return (networkInformationSection);
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Logger.Instance.Write("<e> Error processing Network Information Section message: " + e.Message);
            }

            return (null);
        }
        /// <summary>
        /// Add a network information section.
        /// </summary>
        /// <param name="newSection">The section to be added.</param>
        /// <returns>True if the section was added; false otherwise.</returns>
        public static bool AddSection(NetworkInformationSection newSection)
        {
            foreach (NetworkInformationSection oldSection in NetworkInformationSections)
            {
                if (oldSection.NetworkID == newSection.NetworkID && oldSection.SectionNumber == newSection.SectionNumber)
                    return (false);

                if (oldSection.NetworkID == newSection.NetworkID && oldSection.SectionNumber > newSection.SectionNumber)
                {
                    NetworkInformationSections.Insert(NetworkInformationSections.IndexOf(oldSection), newSection);
                    if (Logger.ProtocolLogger != null)
                        Logger.ProtocolLogger.Write("NID " + newSection.NetworkID + " Section " + newSection.SectionNumber + " inserted");
                    return (true);
                }

                if (oldSection.NetworkID > newSection.NetworkID)
                {
                    NetworkInformationSections.Insert(NetworkInformationSections.IndexOf(oldSection), newSection);
                    if (Logger.ProtocolLogger != null)
                        Logger.ProtocolLogger.Write("NID " + newSection.NetworkID + " Section " + newSection.SectionNumber + " inserted");
                    return (true);
                }
            }

            NetworkInformationSections.Add(newSection);
            if (Logger.ProtocolLogger != null)
                Logger.ProtocolLogger.Write("NID " + newSection.NetworkID + " Section " + newSection.SectionNumber + " added");

            return (true);
        }