Esempio n. 1
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);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Process an MPEG2 section from the service description table.
        /// </summary>
        /// <param name="byteData">The MPEG2 section.</param>
        /// <returns>A ServiceDescriptionSection instance.</returns>
        public static ServiceDescriptionSection ProcessServiceDescriptionTable(byte[] byteData)
        {
            if (RunParameters.Instance.DebugIDs.Contains("DUMPSDTBLOCK"))
            {
                Logger.Instance.Dump("Service Description Block", byteData, byteData.Length);
            }

            Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();

            try
            {
                mpeg2Header.Process(byteData);

                if (mpeg2Header.Current)
                {
                    try
                    {
                        ServiceDescriptionSection serviceDescriptionSection = new ServiceDescriptionSection();
                        serviceDescriptionSection.Process(byteData, mpeg2Header);
                        serviceDescriptionSection.LogMessage();
                        return(serviceDescriptionSection);
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        Logger.Instance.Write(e.Message);
                        return(null);
                    }
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Logger.Instance.Write("<e> Error processing Service Description Section message: " + e.Message);
            }

            return(null);
        }
Esempio n. 3
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);
                }
            }
        }
Esempio n. 4
0
        private Collection <TVStation> findDvbStations()
        {
            if (useActualFrequency || RunParameters.Instance.DebugIDs.Contains("CREATESATINI"))
            {
                processNITSections(worker);
            }

            dataProvider.ChangePidMapping(pids);

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

            Collection <TVStation> tvStations = new Collection <TVStation>();

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

            tables.Add(BDAGraph.SdtTable);
            if (searchOtherTable)
            {
                tables.Add(BDAGraph.SdtOtherTable);
            }

            TSStreamReader stationReader = stationReader = new TSStreamReader(tables, 2000, dataProvider.BufferAddress);

            stationReader.Run();

            Collection <Mpeg2Section> sections = null;

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

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

                Thread.Sleep(2000);

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

                sections = new Collection <Mpeg2Section>();

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

                foreach (Mpeg2Section section in sections)
                {
                    ServiceDescriptionSection serviceDescriptionSection = ServiceDescriptionSection.ProcessServiceDescriptionTable(section.Data);
                    if (serviceDescriptionSection != null)
                    {
                        processServiceDescriptionSection(serviceDescriptionSection, tvStations, dataProvider.Frequency);
                    }
                }

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

                lastCount = tvStations.Count;
            }

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

            Logger.Instance.Write("Stopping station reader for frequency " + dataProvider.Frequency);
            stationReader.Stop();

            int bufferSpaceUsed = dataProvider.BufferSpaceUsed;

            if (dataProvider.Frequency.CollectionType == CollectionType.MHEG5 && tvStations.Count != 0)
            {
                int debugPid = -1;

                foreach (string debugID in RunParameters.Instance.DebugIDs)
                {
                    if (debugID.StartsWith("MHEG5PID-"))
                    {
                        string[] parts = debugID.Split(new char[] { '-' });
                        debugPid = Int32.Parse(parts[1]);
                    }
                }

                if (debugPid == -1)
                {
                    Logger.Instance.Write("Collecting PAT/PMT data to locate MHEG5 pid(s)");

                    processPATSections(tvStations);

                    foreach (TVStation station in tvStations)
                    {
                        if (!station.Excluded && station.DSMCCPID != 0)
                        {
                            dataProvider.Frequency.DSMCCPid = station.DSMCCPID;
                        }
                    }
                }
                else
                {
                    dataProvider.Frequency.DSMCCPid = debugPid;
                }
            }

            Logger.Instance.Write("Stations: " + tvStations.Count + " buffer space used: " + bufferSpaceUsed + " discontinuities: " + stationReader.Discontinuities);

            return(tvStations);
        }
        /// <summary>
        /// Process an MPEG2 section from the service description table.
        /// </summary>
        /// <param name="byteData">The MPEG2 section.</param>
        /// <returns>A ServiceDescriptionSection instance.</returns>
        public static ServiceDescriptionSection ProcessServiceDescriptionTable(byte[] byteData)
        {
            if (RunParameters.Instance.DebugIDs.Contains("DUMPSDTBLOCK"))
                Logger.Instance.Dump("Service Description Block", byteData, byteData.Length);

            Mpeg2ExtendedHeader mpeg2Header = new Mpeg2ExtendedHeader();

            try
            {
                mpeg2Header.Process(byteData);

                if (mpeg2Header.Current)
                {
                    try
                    {
                        ServiceDescriptionSection serviceDescriptionSection = new ServiceDescriptionSection();
                        serviceDescriptionSection.Process(byteData, mpeg2Header);
                        serviceDescriptionSection.LogMessage();
                        return (serviceDescriptionSection);
                    }
                    catch (ArgumentOutOfRangeException e)
                    {
                        Logger.Instance.Write(e.Message);
                        return (null);
                    }
                }
            }
            catch (ArgumentOutOfRangeException e)
            {
                Logger.Instance.Write("<e> Error processing Service Description Section message: " + e.Message);
            }

            return (null);
        }