Example #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);
        }
Example #2
0
        private bool checkChannelFilters(TVStation station)
        {
            if (RunParameters.Instance.MaxService != -1 && station.ServiceID > RunParameters.Instance.MaxService)
            {
                return(false);
            }

            if (ChannelFilterEntry.ChannelFilters == null)
            {
                return(true);
            }

            ChannelFilterEntry filterEntry = ChannelFilterEntry.FindEntry(station.OriginalNetworkID, station.TransportStreamID, station.ServiceID);

            if (filterEntry != null)
            {
                return(true);
            }

            filterEntry = ChannelFilterEntry.FindEntry(station.OriginalNetworkID, station.TransportStreamID);
            if (filterEntry != null)
            {
                return(true);
            }

            filterEntry = ChannelFilterEntry.FindEntry(station.OriginalNetworkID);
            if (filterEntry != null)
            {
                return(true);
            }

            return(false);
        }
        private void processProgramMapSection(ProgramMapSection programMapSection, ProgramInfo programInfo, Collection <TVStation> tvStations)
        {
            TVStation tvStation = findTVStation(programInfo.ProgramNumber, tvStations);

            if (tvStation == null)
            {
                return;
            }

            foreach (StreamInfo streamInfo in programMapSection.StreamInfos)
            {
                if (streamInfo.StreamType == streamTypeVideo)
                {
                    tvStation.VideoPID = streamInfo.ProgramID;
                }
                if (streamInfo.StreamType == streamTypeAudio)
                {
                    tvStation.AudioPID = streamInfo.ProgramID;
                }
                if (streamInfo.StreamType == streamTypeDSMCCUserToNetwork)
                {
                    tvStation.DSMCCPID = streamInfo.ProgramID;
                }
            }
        }
Example #4
0
        private void addChannelInNameOrder(Collection <Channel> sortedChannels, Channel newChannel)
        {
            TVStation newStation = TVStation.FindStation(newChannel.OriginalNetworkID, newChannel.TransportStreamID, newChannel.ServiceID);

            if (newStation == null)
            {
                newStation = new TVStation("No Name");
            }

            foreach (Channel oldChannel in sortedChannels)
            {
                TVStation oldStation = TVStation.FindStation(oldChannel.OriginalNetworkID, oldChannel.TransportStreamID, oldChannel.ServiceID);
                if (oldStation == null)
                {
                    oldStation = new TVStation("No Name");
                }

                if (oldStation.Name.CompareTo(newStation.Name) > 0)
                {
                    sortedChannels.Insert(sortedChannels.IndexOf(oldChannel), newChannel);
                    return;
                }
            }

            sortedChannels.Add(newChannel);
        }
        /// <summary>
        /// Get a description of this instance.
        /// </summary>
        /// <returns>A string describing this instance.</returns>
        public override string ToString()
        {
            TVStation station = TVStation.FindStation(OriginalNetworkID, TransportStreamID, ServiceID);
            string    stationName;

            if (station != null)
            {
                stationName = station.Name;
            }
            else
            {
                stationName = "** No Station **";
            }

            string unknownString;

            if (unknown == null)
            {
                unknownString = "n/a";
            }
            else
            {
                unknownString = Utils.ConvertToHex(unknown);
            }

            return("ONID " + OriginalNetworkID +
                   " TSID " + TransportStreamID +
                   " SID " + ServiceID +
                   " Channel ID: " + ChannelID +
                   " Unknown: " + unknownString +
                   " Name: " + channelName +
                   " Station: " + stationName);
        }
Example #6
0
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (RunParameters.Instance.ChannelBouquet != -1)
            {
                foreach (TVStation tvStation in TVStation.StationCollection)
                {
                    bool process = checkChannelMapping(tvStation);
                    if (!process)
                    {
                        tvStation.EPGCollection.Clear();
                    }
                }
            }
            else
            {
                foreach (Bouquet bouquet in Bouquet.Bouquets)
                {
                    foreach (Region region in bouquet.Regions)
                    {
                        foreach (Channel channel in region.Channels)
                        {
                            TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                            if (station != null && station.LogicalChannelNumber == -1)
                            {
                                station.LogicalChannelNumber = channel.UserChannel;
                            }
                        }
                    }
                }
            }

            EITProgramContent.LogContentUsage();
            LanguageCode.LogUsage();
            logChannelInfo();
        }
Example #7
0
        /// <summary>
        /// Map the channel to a TV station.
        /// </summary>
        /// <param name="station">The TV station to be mapped.</param>
        public void CreateChannelMapping(TVStation station)
        {
            if (station.LogicalChannelNumber != -1)
            {
                return;
            }

            station.LogicalChannelNumber = UserChannel;
        }
        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);
                }
            }
        }
Example #9
0
        private void updateCategoryEntries(TVStation tvStation, EITEntry eitEntry)
        {
            if (categoryEntries == null)
            {
                categoryEntries = new Collection <CategoryEntry>();
            }

            CategoryEntry newEntry = new CategoryEntry(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID, eitEntry.StartTime, eitEntry.EventName, eitEntry.ContentType, eitEntry.ContentSubType);

            foreach (CategoryEntry oldEntry in categoryEntries)
            {
                if (oldEntry.NetworkID == newEntry.NetworkID &&
                    oldEntry.TransportStreamID == newEntry.TransportStreamID &&
                    oldEntry.ServiceID == newEntry.ServiceID &&
                    oldEntry.StartTime == newEntry.StartTime)
                {
                    return;
                }

                if (oldEntry.NetworkID > newEntry.NetworkID)
                {
                    categoryEntries.Insert(categoryEntries.IndexOf(oldEntry), newEntry);
                    return;
                }

                if (oldEntry.NetworkID == newEntry.NetworkID &&
                    oldEntry.TransportStreamID > newEntry.TransportStreamID)
                {
                    categoryEntries.Insert(categoryEntries.IndexOf(oldEntry), newEntry);
                    return;
                }

                if (oldEntry.NetworkID == newEntry.NetworkID &&
                    oldEntry.TransportStreamID == newEntry.TransportStreamID &&
                    oldEntry.ServiceID > newEntry.ServiceID)
                {
                    categoryEntries.Insert(categoryEntries.IndexOf(oldEntry), newEntry);
                    return;
                }

                if (oldEntry.NetworkID == newEntry.NetworkID &&
                    oldEntry.TransportStreamID == newEntry.TransportStreamID &&
                    oldEntry.ServiceID == newEntry.ServiceID &&
                    oldEntry.StartTime > newEntry.StartTime)
                {
                    categoryEntries.Insert(categoryEntries.IndexOf(oldEntry), newEntry);
                    return;
                }
            }

            categoryEntries.Add(newEntry);
        }
        private void cmdSaveChannels_Click(object sender, EventArgs e)
        {
            includedStations = new Collection <TVStation>();

            foreach (object objchecked in lstTVStationsFound.CheckedItems)
            {
                //MessageBox.Show(objchecked.ToString());
                TVStation tmp = TVStation.StationCollection[lstTVStationsFound.Items.IndexOf(objchecked.ToString())];
                includedStations.Add(tmp);
            }

            //this.tabControl1.SelectTab(0);
            ConfigSettings.SaveFile(includedStations, TVStation.StationCollection);
            formChanged = false;
        }
        private static bool getStations(TuningFrequency frequency)
        {
            bool tuned = tuneFrequency(frequency);

            if (!tuned)
            {
                return(false);
            }

            FrequencyScanner       frequencyScanner = new FrequencyScanner(graph);
            Collection <TVStation> stations         = frequencyScanner.FindTVStations(frequency);

            if (stations != null)
            {
                Logger.Instance.Write("Found " + stations.Count + " stations on frequency " + frequency);
                int addedCount = 0;

                foreach (TVStation tvStation in stations)
                {
                    TVStation excludedStation = TVStation.FindExcludedStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (excludedStation == null)
                    {
                        if (tvStation.NextFollowingAvailable && tvStation.ScheduleAvailable)
                        {
                            bool added = TVStation.AddStation(tvStation);
                            if (added)
                            {
                                //allStations.Add(tvStation);
                                addedCount++;
                                Logger.Instance.Write("Included station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                            }
                        }
                        else
                        {
                            Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ") No EPG data");
                        }
                    }
                    else
                    {
                        Logger.Instance.Write("Excluded station: " + tvStation.FixedLengthName + " (" + tvStation.FullID + " Service type " + tvStation.ServiceType + ")");
                    }
                }

                Logger.Instance.Write("Added " + addedCount + " stations for frequency " + frequency);
            }
            frequencyScanner = null;
            return(true);
        }
Example #12
0
        private void addStation(Collection <TVStation> tvStations, TVStation newStation)
        {
            foreach (TVStation oldStation in tvStations)
            {
                if (oldStation.OriginalNetworkID == newStation.OriginalNetworkID &&
                    oldStation.TransportStreamID == newStation.TransportStreamID &&
                    oldStation.ServiceID == newStation.ServiceID)
                {
                    oldStation.Frequency = newStation.Frequency;
                    oldStation.Name      = newStation.Name;
                    return;
                }
            }

            tvStations.Add(newStation);
        }
Example #13
0
        private TuningSpec findTuningSpec(Collection <TuningSpec> tuningCollection, TVStation tvStation)
        {
            foreach (TuningSpec tuningSpec in tuningCollection)
            {
                if (tuningSpec.Satellite == tvStation.Satellite &&
                    tuningSpec.OriginalNetworkID == tvStation.OriginalNetworkID &&
                    tuningSpec.TransportStreamID == tvStation.TransportStreamID &&
                    tuningSpec.Frequency == tvStation.Frequency &&
                    tuningSpec.SymbolRate == tvStation.SymbolRate)
                {
                    return(tuningSpec);
                }
            }

            return(null);
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (MediaHighwayChannel.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station == null)
                {
                    station = new TVStation(channel.ChannelName);
                    station.OriginalNetworkID = channel.OriginalNetworkID;
                    station.TransportStreamID = channel.TransportStreamID;
                    station.ServiceID         = channel.ServiceID;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ChannelName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = channel.UserChannel;
                }

                if (station.EPGCollection.Count == 0)
                {
                    channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, CollectionType.MediaHighway2);
                }
            }

            MediaHighwayProgramCategory.LogCategories();
            Channel.LogChannelsInChannelOrder();
        }
Example #15
0
        private TVStation processStation(string epgText)
        {
            string[] parts             = epgText.Substring(3).Split(new char[] { '(' });
            string[] stationDefinition = parts[1].Split(new char[] { ')' });
            string[] stationParts      = stationDefinition[0].Split(new char[] { ',' });

            station = new TVStation(parts[0]);
            station.TransportStreamID = Int32.Parse(stationParts[1].Trim());
            station.ServiceID         = Int32.Parse(stationParts[2].Trim());

            string[] dateParts    = stationDefinition[1].Split(new char[] { ' ' });
            string[] dayMonthYear = dateParts[1].Trim().Split(new char[] { '.' });
            int      day          = Int32.Parse(dayMonthYear[0]);
            int      month        = Int32.Parse(dayMonthYear[1]);
            int      year         = Int32.Parse(dayMonthYear[2]);

            startDate     = new DateTime(year, month, day);
            lastStartTime = startDate;

            return(station);
        }
Example #16
0
        private string getStationDescription(TVStation station)
        {
            StringBuilder description = new StringBuilder(station.FixedLengthName);

            description.Append(" (");

            description.Append(station.FullID);
            description.Append(" Type: " + station.ServiceType);
            description.Append(" " + (station.Encrypted ? "Encrypted" : "Clear"));

            string epg;

            if (station.NextFollowingAvailable)
            {
                if (station.ScheduleAvailable)
                {
                    epg = "NN&S";
                }
                else
                {
                    epg = "NN";
                }
            }
            else
            {
                if (station.ScheduleAvailable)
                {
                    epg = "S";
                }
                else
                {
                    epg = "None";
                }
            }

            description.Append(" EPG: " + epg);
            description.Append(")");

            return(description.ToString());
        }
Example #17
0
        /// <summary>
        /// Get a description of this instance.
        /// </summary>
        /// <returns>A string describing this instance.</returns>
        public override string ToString()
        {
            TVStation station = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);
            string    stationName;

            if (station != null)
            {
                stationName = station.Name;
            }
            else
            {
                stationName = "** No Station **";
            }

            return("ONID " + OriginalNetworkID +
                   " TSID " + TransportStreamID +
                   " SID " + ServiceID +
                   " Channel ID: " + ChannelID +
                   " User Channel: " + UserChannel +
                   " Bouquet: " + BouquetID +
                   " Region: " + Region +
                   " Station: " + stationName);
        }
Example #18
0
        /// <summary>
        /// Log all the channel mappings.
        /// </summary>
        /// <param name="logger">The logger instance to be used.</param>
        public void LogChannelMapping(Logger logger)
        {
            TVStation station = TVStation.FindStation(OriginalNetworkID, TransportStreamID, ServiceID);

            string stationName;

            if (station != null)
            {
                stationName = station.Name;
            }
            else
            {
                stationName = "** No Station **";
            }

            logger.Write("Channel: ONID " + OriginalNetworkID +
                         " TSID " + TransportStreamID +
                         " SID " + ServiceID +
                         " Channel ID: " + ChannelID +
                         " User Channel: " + UserChannel +
                         " Bouquet: " + BouquetID +
                         " Region: " + Region +
                         " Name: " + stationName);
        }
Example #19
0
        /// <summary>
        /// Get the stations using specified pid's.
        /// </summary>
        /// <param name="dataProvider">The sample data provider.</param>
        /// <param name="worker">The BackgroundWorker instance running the collection.</param>
        /// <param name="pids">An array of pid's to search.</param>
        protected void GetStationData(ISampleDataProvider dataProvider, BackgroundWorker worker, int[] pids)
        {
            Collection <TVStation> stations;

            if (!RunParameters.Instance.Options.Contains("USESTOREDSTATIONINFO"))
            {
                FrequencyScanner frequencyScanner = new FrequencyScanner(dataProvider, pids, true, worker);
                frequencyScanner.UseActualFrequency = false;
                stations = frequencyScanner.FindTVStations();
                if (worker.CancellationPending)
                {
                    return;
                }
            }
            else
            {
                if (!stationCacheLoaded)
                {
                    stations = TVStation.Load(Path.Combine(RunParameters.DataDirectory, "Station Cache.xml"));
                    if (stations == null)
                    {
                        return;
                    }

                    setMHEG5Pid(dataProvider, stations);
                    stationCacheLoaded = true;
                }
                else
                {
                    setMHEG5Pid(dataProvider, TVStation.StationCollection);
                    return;
                }
            }

            foreach (TVStation tvStation in stations)
            {
                bool include = checkChannelFilters(tvStation);

                if (include)
                {
                    TVStation existingStation = TVStation.FindStation(tvStation.OriginalNetworkID, tvStation.TransportStreamID, tvStation.ServiceID);
                    if (existingStation == null)
                    {
                        tvStation.CollectionType = dataProvider.Frequency.CollectionType;
                        bool added = TVStation.AddStation(tvStation);
                        if (added)
                        {
                            Logger.Instance.Write("Included station: " + getStationDescription(tvStation));
                        }
                    }
                    else
                    {
                        if (!existingStation.Excluded)
                        {
                            existingStation.Update(tvStation);
                            Logger.Instance.Write("Included station: " + getStationDescription(tvStation));
                        }
                        else
                        {
                            Logger.Instance.Write("Excluded station: " + getStationDescription(tvStation));
                        }
                    }
                }
                else
                {
                    Logger.Instance.Write("Excluded station: " + getStationDescription(tvStation));
                }
            }

            Logger.Instance.Write("Station count now: " + TVStation.StationCollection.Count);
        }
        private void SaveFile()
        {
            SaveFileDialog saveFile = new SaveFileDialog();

            saveFile.Filter = "INI Files (*.ini)|*.ini";
            saveFile.Title  = "Save INI file";

            if (saveFile.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            if (createNew)
            {
                CopyFile(saveFile.FileName);
            }

            try
            {
                ConfigSettings.IniFileName = saveFile.FileName;
            }
            catch (Exception)
            {
                MessageBox.Show("Error saving file", "File Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            // Update settings then write them all out...
            ConfigSettings.OutputFileName = this.txtOutputFile.Text;

            if (this.rbDVBT.Checked)
            {
                ConfigSettings.TuningFile = cboCountry.Text + "." + cboArea.Text + ".xml";
            }
            else
            {
                ConfigSettings.TuningFile = cboCountry.Text + ".xml";
            }

            if (cboTuners.SelectedIndex > 0)
            {
                ConfigSettings.TunerIndex = cboTuners.SelectedIndex + 1;
            }
            else
            {
                ConfigSettings.TunerIndex = 1; //default value
            }
            ConfigSettings.SignalLockTimeout     = Convert.ToInt16(txtSignalLockTimeout.Text);
            ConfigSettings.DataCollectionTimeout = Convert.ToInt16(txtDataCollectionTimeout.Text);
            if (txtScanRetries.Text != null)
            {
                ConfigSettings.ScanRetries = Convert.ToInt16(txtScanRetries.Text);
            }

            if (this.txtOptions.Text.Length > 0)
            {
                ConfigSettings.OptionsString = this.txtOptions.Text;
            }

            ConfigSettings.OptionsString = "";
            if (this.chkACCEPTBREAKS.Checked)
            {
                ConfigSettings.OptionsString = "ACCEPTBREAKS,";
            }
            if (this.chkNOSIGLOCK.Checked)
            {
                ConfigSettings.OptionsString = ConfigSettings.OptionsString + "NOSIGLOCK,";
            }
            if (this.chkROUNDTIME.Checked)
            {
                ConfigSettings.OptionsString = ConfigSettings.OptionsString + "ROUNDTIME,";
            }
            if (this.chkUSECHANNELID.Checked)
            {
                ConfigSettings.OptionsString = ConfigSettings.OptionsString + "USECHANNELID,";
            }
            if (this.chkUSEIMAGE.Checked)
            {
                ConfigSettings.OptionsString = ConfigSettings.OptionsString + "USEIMAGE,";
            }
            if (ConfigSettings.OptionsString.Length > 0)
            {
                ConfigSettings.OptionsString = ConfigSettings.OptionsString.Substring(0, ConfigSettings.OptionsString.Length - 1);
            }


            if (this.rbSatellite.Checked)
            {
                ConfigSettings.LnbLow    = txtLNBLow.Text;
                ConfigSettings.LnbHigh   = txtLNBHigh.Text;
                ConfigSettings.LnbSwitch = txtLNBSwitch.Text;
                ConfigSettings.Azimuth   = Convert.ToInt32(txtAzimuth.Text);
            }


            //ConfigSettings.ScanningFrequency = "";
            includedStations = new Collection <TVStation>();
            foreach (object objchecked in lstTVStationsFound.CheckedItems)
            {
                //MessageBox.Show(objchecked.ToString());
                TVStation tmp = TVStation.StationCollection[lstTVStationsFound.Items.IndexOf(objchecked.ToString())];
                includedStations.Add(tmp);
            }

            try
            {
                if (ConfigSettings.SaveFile(includedStations, TVStation.StationCollection))
                {
                    MessageBox.Show("Configuration File Saved as \n" + ConfigSettings.IniFileName, "Saved");
                }
                else
                {
                    MessageBox.Show("Unable to save configuration file...\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                TuningFrequency.FrequencyCollection.Clear();
                ConfigSettings.ReadFile();
                UpdateForm();
            }
            catch (Exception x)
            {
                MessageBox.Show("Unable to save configuration file...\n" + x.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            formChanged = false;
        }
Example #21
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            try
            {
                transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                segmentLastSectionNumber = (int)byteData[lastIndex];
                lastIndex++;

                lastTableID = (int)byteData[lastIndex];
                lastIndex++;
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The FreeSat EIT section is short"));
            }

            TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);

            if (tvStation == null)
            {
                return;
            }

            bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber);

            if (!newSection)
            {
                return;
            }

            while (lastIndex < byteData.Length - 4)
            {
                FreeSatEntry freeSatEntry = new FreeSatEntry();
                freeSatEntry.Process(byteData, lastIndex);

                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID;
                epgEntry.TransportStreamID = tvStation.TransportStreamID;
                epgEntry.ServiceID         = tvStation.ServiceID;
                epgEntry.EPGSource         = EPGSource.FreeSat;

                switch (freeSatEntry.ComponentTypeAudio)
                {
                case 3:
                    epgEntry.AudioQuality = "stereo";
                    break;

                case 5:
                    epgEntry.AudioQuality = "dolby digital";
                    break;

                default:
                    break;
                }

                if (freeSatEntry.ComponentTypeVideo > 9)
                {
                    epgEntry.VideoQuality = "HDTV";
                }

                epgEntry.Duration  = Utils.RoundTime(freeSatEntry.Duration);
                epgEntry.EventID   = freeSatEntry.EventID;
                epgEntry.EventName = freeSatEntry.EventName;

                if (freeSatEntry.ParentalRating > 11)
                {
                    epgEntry.ParentalRating = "AO";
                }
                else
                {
                    if (freeSatEntry.ParentalRating > 8)
                    {
                        epgEntry.ParentalRating = "PGR";
                    }
                    else
                    {
                        epgEntry.ParentalRating = "G";
                    }
                }

                setSeriesEpisode(epgEntry, freeSatEntry);

                epgEntry.RunningStatus    = freeSatEntry.RunningStatus;
                epgEntry.Scrambled        = freeSatEntry.Scrambled;
                epgEntry.ShortDescription = freeSatEntry.ShortDescription;
                epgEntry.StartTime        = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(freeSatEntry.StartTime));

                epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, freeSatEntry.ContentType, freeSatEntry.ContentSubType);

                tvStation.AddEPGEntry(epgEntry);

                if (titleLogger != null)
                {
                    logTitle(freeSatEntry.EventName, epgEntry, titleLogger);
                }
                if (descriptionLogger != null)
                {
                    logDescription(freeSatEntry.ShortDescription, epgEntry, descriptionLogger);
                }

                lastIndex = freeSatEntry.Index;
            }
        }
        /// <summary>
        /// Create the EPG entries from the stored title and summary data.
        /// </summary>
        /// <param name="station">The station that the EPG records are for.</param>
        /// <param name="titleLogger">A Logger instance for the program titles.</param>
        /// <param name="descriptionLogger">A Logger instance for the program descriptions.</param>
        /// <param name="collectionType">The type of collection, MHW1 or MHW2.</param>
        public void ProcessChannelForEPG(TVStation station, Logger titleLogger, Logger descriptionLogger, CollectionType collectionType)
        {
            bool     first             = true;
            DateTime expectedStartTime = new DateTime();

            foreach (MediaHighwayTitle title in Titles)
            {
                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = OriginalNetworkID;
                epgEntry.TransportStreamID = TransportStreamID;
                epgEntry.ServiceID         = ServiceID;
                epgEntry.EventID           = title.EventID;

                processEventName(epgEntry, title.EventName);

                MediaHighwaySummary summary = null;

                if (title.SummaryAvailable)
                {
                    summary = findSummary(title.EventID);
                    if (summary != null)
                    {
                        processShortDescription(epgEntry, summary.ShortDescription);
                    }
                    else
                    {
                        if (RunParameters.Instance.DebugIDs.Contains("MHW2SUMMARYMISSING"))
                        {
                            Logger.Instance.Write("Summary missing for event ID " + title.EventID);
                        }
                    }
                }
                if (summary == null)
                {
                    epgEntry.ShortDescription = "No Synopsis Available";
                }

                if (collectionType == CollectionType.MediaHighway1)
                {
                    epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(title.StartTime));
                }
                else
                {
                    epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetAdjustedTime(title.StartTime));
                }
                epgEntry.Duration = Utils.RoundTime(title.Duration);

                epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, title.CategoryID);

                if (collectionType == CollectionType.MediaHighway1)
                {
                    epgEntry.EPGSource = EPGSource.MediaHighway1;
                }
                else
                {
                    epgEntry.EPGSource = EPGSource.MediaHighway2;
                }

                epgEntry.VideoQuality = getVideoQuality(epgEntry.EventName);

                epgEntry.PreviousPlayDate = title.PreviousPlayDate;

                station.AddEPGEntry(epgEntry);

                if (first)
                {
                    expectedStartTime = new DateTime();
                    first             = false;
                }
                else
                {
                    if (epgEntry.StartTime < expectedStartTime)
                    {
                        if (titleLogger != null)
                        {
                            titleLogger.Write(" ** Overlap In Schedule **");
                        }
                    }
                    else
                    {
                        if (RunParameters.Instance.Options.Contains("ACCEPTBREAKS"))
                        {
                            if (epgEntry.StartTime > expectedStartTime + new TimeSpan(0, 5, 0))
                            {
                                if (titleLogger != null)
                                {
                                    titleLogger.Write(" ** Gap In Schedule **");
                                }
                            }
                        }
                        else
                        {
                            if (epgEntry.StartTime > expectedStartTime)
                            {
                                if (titleLogger != null)
                                {
                                    titleLogger.Write(" ** Gap In Schedule **");
                                }
                            }
                        }
                    }
                }

                expectedStartTime = epgEntry.StartTime + epgEntry.Duration;

                if (titleLogger != null)
                {
                    if (collectionType == CollectionType.MediaHighway1)
                    {
                        titleLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                          " Evt ID " + title.EventID +
                                          " Cat ID " + title.CategoryID.ToString("00") +
                                          " Summary " + title.SummaryAvailable + ":" + (summary != null) + " " +
                                          " Orig Day " + title.LogDay +
                                          " Orig Hours " + title.LogHours +
                                          " YDay " + title.LogYesterday +
                                          " Day " + title.Day +
                                          " Hours " + title.Hours +
                                          " Mins " + title.Minutes + " " +
                                          epgEntry.StartTime.ToShortDateString() + " " +
                                          epgEntry.StartTime.ToString("HH:mm") + " - " +
                                          epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                          title.EventName);
                    }
                    else
                    {
                        titleLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                          " Evt ID " + title.EventID +
                                          " Cat ID " + title.CategoryID.ToString("000") +
                                          " Main cat " + title.MainCategory +
                                          " Sub cat " + title.SubCategory +
                                          " Summary " + title.SummaryAvailable + ":" + (summary != null) +
                                          " Unknown " + Utils.ConvertToHex(title.Unknown) + " " +
                                          epgEntry.StartTime.ToShortDateString() + " " +
                                          epgEntry.StartTime.ToString("HH:mm") + " - " +
                                          epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                          title.EventName);
                    }
                }

                if (descriptionLogger != null && summary != null)
                {
                    if (collectionType == CollectionType.MediaHighway1)
                    {
                        descriptionLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                                " Evt ID " + title.EventID +
                                                " Rpts: " + summary.ReplayCount + " " +
                                                epgEntry.StartTime.ToShortDateString() + " " +
                                                epgEntry.StartTime.ToString("HH:mm") + " - " +
                                                epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                                summary.ShortDescription);
                    }
                    else
                    {
                        descriptionLogger.Write(epgEntry.OriginalNetworkID + ":" + epgEntry.TransportStreamID + ":" + epgEntry.ServiceID + " " +
                                                " Evt ID " + title.EventID + " " +
                                                " Unknown " + Utils.ConvertToHex(summary.Unknown) + " " +
                                                epgEntry.StartTime.ToShortDateString() + " " +
                                                epgEntry.StartTime.ToString("HH:mm") + " - " +
                                                epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                                summary.ShortDescription);
                    }
                }

                if (!RunParameters.Instance.Options.Contains("ACCEPTBREAKS"))
                {
                    if (epgEntry.StartTime.Second != 0)
                    {
                        if (titleLogger != null)
                        {
                            titleLogger.Write("** Suspect Start Time **");
                        }
                    }
                }
            }
        }
Example #23
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex);
            lastIndex        += 2;

            originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
            lastIndex        += 2;

            segmentLastSectionNumber = (int)byteData[lastIndex];
            lastIndex++;

            lastTableID = (int)byteData[lastIndex];
            lastIndex++;

            TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);

            if (tvStation == null)
            {
                if (!RunParameters.Instance.DebugIDs.Contains("CREATESTATIONS"))
                {
                    return;
                }
                else
                {
                    tvStation = new TVStation("Auto Generated Station: " + originalNetworkID + ":" + transportStreamID + ":" + serviceID);
                    tvStation.OriginalNetworkID = originalNetworkID;
                    tvStation.TransportStreamID = transportStreamID;
                    tvStation.ServiceID         = serviceID;

                    TVStation.StationCollection.Add(tvStation);
                }
            }

            bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber);

            if (!newSection)
            {
                return;
            }

            while (lastIndex < byteData.Length - 4)
            {
                EITEntry eitEntry = new EITEntry();
                eitEntry.Process(byteData, lastIndex);

                if (eitEntry.StartTime != DateTime.MinValue)
                {
                    EPGEntry epgEntry = new EPGEntry();
                    epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID;
                    epgEntry.TransportStreamID = tvStation.TransportStreamID;
                    epgEntry.ServiceID         = tvStation.ServiceID;
                    epgEntry.EPGSource         = EPGSource.EIT;

                    switch (eitEntry.ComponentTypeAudio)
                    {
                    case 3:
                        epgEntry.AudioQuality = "stereo";
                        break;

                    case 5:
                        epgEntry.AudioQuality = "dolby digital";
                        break;

                    default:
                        break;
                    }

                    if (eitEntry.ComponentTypeVideo > 9)
                    {
                        epgEntry.VideoQuality = "HDTV";
                    }

                    if (!RunParameters.Instance.Options.Contains("USEDESCASCATEGORY"))
                    {
                        epgEntry.EventCategory = getEventCategory(eitEntry.EventName, eitEntry.Description, eitEntry.ContentType, eitEntry.ContentSubType);
                    }
                    else
                    {
                        epgEntry.EventCategory = eitEntry.ShortDescription;
                    }

                    epgEntry.Duration  = Utils.RoundTime(eitEntry.Duration);
                    epgEntry.EventID   = eitEntry.EventID;
                    epgEntry.EventName = eitEntry.EventName;

                    if (RunParameters.Instance.CountryCode != null)
                    {
                        epgEntry.ParentalRating     = ParentalRating.FindRating(RunParameters.Instance.CountryCode, "EIT", (eitEntry.ParentalRating + 3).ToString());
                        epgEntry.MpaaParentalRating = ParentalRating.FindMpaaRating(RunParameters.Instance.CountryCode, "EIT", (eitEntry.ParentalRating + 3).ToString());
                    }
                    else
                    {
                        if (eitEntry.ParentalRating > 11)
                        {
                            epgEntry.ParentalRating     = "AO";
                            epgEntry.MpaaParentalRating = "AO";
                        }
                        else
                        {
                            if (eitEntry.ParentalRating > 8)
                            {
                                epgEntry.ParentalRating     = "PGR";
                                epgEntry.MpaaParentalRating = "PG";
                            }
                            else
                            {
                                epgEntry.ParentalRating     = "G";
                                epgEntry.MpaaParentalRating = "G";
                            }
                        }
                    }

                    epgEntry.RunningStatus = eitEntry.RunningStatus;
                    epgEntry.Scrambled     = eitEntry.Scrambled;

                    if (!RunParameters.Instance.Options.Contains("USEDESCASCATEGORY"))
                    {
                        epgEntry.ShortDescription = eitEntry.Description;
                    }
                    else
                    {
                        epgEntry.ShortDescription = eitEntry.ExtendedDescription;
                    }

                    epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(eitEntry.StartTime));

                    epgEntry.Cast      = eitEntry.Cast;
                    epgEntry.Directors = eitEntry.Directors;
                    epgEntry.Date      = eitEntry.Year;
                    if (eitEntry.TVRating != null)
                    {
                        epgEntry.ParentalRating = eitEntry.TVRating;
                    }
                    epgEntry.StarRating = eitEntry.StarRating;

                    if (eitEntry.TVRating != null)
                    {
                        epgEntry.ParentalRating = eitEntry.TVRating;
                    }

                    setSeriesEpisode(epgEntry, eitEntry);

                    /*if (eitEntry.PreviousPlayDate != null)
                     * {
                     *  try
                     *  {
                     *      TimeSpan offset = new TimeSpan(Int32.Parse(eitEntry.PreviousPlayDate) * TimeSpan.TicksPerSecond);
                     *      epgEntry.PreviousPlayDate = epgEntry.StartTime - offset;
                     *  }
                     *  catch (FormatException) { }
                     * }*/

                    epgEntry.Country = eitEntry.Country;

                    tvStation.AddEPGEntry(epgEntry);

                    if (titleLogger != null)
                    {
                        logTitle(eitEntry.EventName, eitEntry, epgEntry, titleLogger);
                    }
                    if (descriptionLogger != null)
                    {
                        logTitle(eitEntry.Description, eitEntry, epgEntry, descriptionLogger);
                    }

                    if (RunParameters.Instance.DebugIDs.Contains("CATXREF"))
                    {
                        updateCategoryEntries(tvStation, eitEntry);
                    }
                }

                lastIndex = eitEntry.Index;
            }
        }
Example #24
0
        /// <summary>
        /// Parse the section.
        /// </summary>
        /// <param name="byteData">The MPEG2 section containing the section.</param>
        /// <param name="mpeg2Header">The MPEG2 header that preceedes the section.</param>
        public void Process(byte[] byteData, Mpeg2ExtendedHeader mpeg2Header)
        {
            lastIndex = mpeg2Header.Index;
            serviceID = mpeg2Header.TableIDExtension;

            try
            {
                transportStreamID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                originalNetworkID = Utils.Convert2BytesToInt(byteData, lastIndex);
                lastIndex        += 2;

                segmentLastSectionNumber = (int)byteData[lastIndex];
                lastIndex++;

                lastTableID = (int)byteData[lastIndex];
                lastIndex++;
            }
            catch (IndexOutOfRangeException)
            {
                throw (new ArgumentOutOfRangeException("The Bell TV section is short"));
            }

            TVStation tvStation = TVStation.FindStation(originalNetworkID, transportStreamID, serviceID);

            if (tvStation == null)
            {
                if (!RunParameters.Instance.DebugIDs.Contains("CREATESTATIONS"))
                {
                    return;
                }
                else
                {
                    tvStation = new TVStation("Auto Generated Station: " + originalNetworkID + ":" + transportStreamID + ":" + serviceID);
                    tvStation.OriginalNetworkID = originalNetworkID;
                    tvStation.TransportStreamID = transportStreamID;
                    tvStation.ServiceID         = serviceID;

                    TVStation.StationCollection.Add(tvStation);
                }
            }

            bool newSection = tvStation.AddMapEntry(mpeg2Header.TableID, mpeg2Header.SectionNumber, lastTableID, mpeg2Header.LastSectionNumber, segmentLastSectionNumber);

            if (!newSection)
            {
                return;
            }

            while (lastIndex < byteData.Length - 4)
            {
                BellTVEntry bellTVEntry = new BellTVEntry();
                bellTVEntry.Process(byteData, lastIndex, mpeg2Header.TableID);

                EPGEntry epgEntry = new EPGEntry();
                epgEntry.OriginalNetworkID = tvStation.OriginalNetworkID;
                epgEntry.TransportStreamID = tvStation.TransportStreamID;
                epgEntry.ServiceID         = tvStation.ServiceID;
                epgEntry.EPGSource         = EPGSource.BellTV;

                if (bellTVEntry.HighDefinition)
                {
                    epgEntry.VideoQuality = "HDTV";
                }
                if (bellTVEntry.ClosedCaptions)
                {
                    epgEntry.SubTitles = "teletext";
                }
                if (bellTVEntry.Stereo)
                {
                    epgEntry.AudioQuality = "stereo";
                }

                epgEntry.Duration  = Utils.RoundTime(bellTVEntry.Duration);
                epgEntry.EventID   = bellTVEntry.EventID;
                epgEntry.EventName = bellTVEntry.EventName;

                getParentalRating(epgEntry, bellTVEntry);

                epgEntry.RunningStatus    = bellTVEntry.RunningStatus;
                epgEntry.Scrambled        = bellTVEntry.Scrambled;
                epgEntry.ShortDescription = bellTVEntry.ShortDescription;
                if (bellTVEntry.SubTitle != bellTVEntry.EventName)
                {
                    epgEntry.EventSubTitle = bellTVEntry.SubTitle;
                }
                epgEntry.StartTime = Utils.RoundTime(TimeOffsetEntry.GetOffsetTime(bellTVEntry.StartTime));

                epgEntry.EventCategory = getEventCategory(epgEntry.EventName, epgEntry.ShortDescription, bellTVEntry.ContentType, bellTVEntry.ContentSubType);

                epgEntry.StarRating = getStarRating(bellTVEntry);
                epgEntry.Date       = bellTVEntry.Date;
                epgEntry.Cast       = bellTVEntry.Cast;

                getSeriesEpisode(epgEntry, bellTVEntry.Series, bellTVEntry.Episode);

                epgEntry.HasGraphicLanguage     = bellTVEntry.HasStrongLanguage;
                epgEntry.HasStrongSexualContent = bellTVEntry.HasSexualContent;
                epgEntry.HasGraphicViolence     = bellTVEntry.HasViolence;
                epgEntry.HasNudity = bellTVEntry.HasNudity;

                epgEntry.PreviousPlayDate = bellTVEntry.OriginalAirDate;

                tvStation.AddEPGEntry(epgEntry);

                if (titleLogger != null)
                {
                    logTitle(bellTVEntry.EventName, epgEntry, titleLogger);
                }
                if (descriptionLogger != null)
                {
                    if (!RunParameters.Instance.DebugIDs.Contains("LOGORIGINAL"))
                    {
                        logDescription(bellTVEntry.ShortDescription, epgEntry, descriptionLogger);
                    }
                    else
                    {
                        logDescription(bellTVEntry.OriginalDescription, epgEntry, descriptionLogger);
                    }
                }

                lastIndex = bellTVEntry.Index;
            }
        }
Example #25
0
        private Collection <TVStation> findAtscStations()
        {
            Logger.Instance.Write("Collecting ATSC Channel data", false, true);

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

            VirtualChannelTable.Clear();

            dataProvider.ChangePidMapping(new int[] { 0x1ffb });

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

            tables.Add(0xc8);
            tables.Add(0xc9);
            TSStreamReader guideReader = new TSStreamReader(tables, 50000, dataProvider.BufferAddress);

            guideReader.Run();

            int  repeats = 0;
            bool done    = false;

            while (!done)
            {
                if (worker.CancellationPending)
                {
                    return(tvStations);
                }

                Thread.Sleep(2000);
                Logger.Instance.Write(".", false, false);

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

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

                if (sections.Count != 0)
                {
                    processVirtualChannelTable(sections, dataProvider.Frequency.Frequency);
                }

                done = VirtualChannelTable.Complete;
                if (!done)
                {
                    repeats++;
                    done = (repeats == RunParameters.Instance.Repeats);
                }
            }

            Logger.Instance.Write("", true, false);
            Logger.Instance.Write("Stopping reader");
            guideReader.Stop();

            foreach (VirtualChannel channel in VirtualChannelTable.Channels)
            {
                TVStation station = new TVStation(channel.ShortName);
                station.StationType       = TVStationType.Atsc;
                station.OriginalNetworkID = channel.CollectionFrequency;
                station.TransportStreamID = channel.MajorChannelNumber;
                station.ServiceID         = channel.MinorChannelNumber;
                tvStations.Add(station);
            }

            return(tvStations);
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (RunParameters.Instance.DebugIDs.Contains("LOGPSIPEXTENDEDTEXT"))
            {
                ExtendedTextTable.LogEntries();
            }

            AtscPsipProgramCategory.LogCategoryUsage();

            if (VirtualChannelTable.Channels.Count == 0)
            {
                return;
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            foreach (VirtualChannel channel in VirtualChannelTable.Channels)
            {
                TVStation station = TVStation.FindStation(channel.CollectionFrequency, channel.MajorChannelNumber, channel.MinorChannelNumber);
                if (station == null)
                {
                    station = new TVStation(channel.ShortName);
                    station.OriginalNetworkID = channel.CollectionFrequency;
                    station.TransportStreamID = channel.MajorChannelNumber;
                    station.ServiceID         = channel.MinorChannelNumber;
                    station.ChannelID         = channel.MajorChannelNumber + ":" + channel.MinorChannelNumber + ":" + channel.ShortName;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ShortName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = (channel.MajorChannelNumber * 100) + channel.MinorChannelNumber;
                }

                station.MinorChannelNumber = channel.MinorChannelNumber;

                if (station.EPGCollection.Count == 0)
                {
                    foreach (EPGEntry epgEntry in channel.EPGCollection)
                    {
                        station.EPGCollection.Add(epgEntry);

                        if (titleLogger != null)
                        {
                            titleLogger.Write(epgEntry.ServiceID + " " +
                                              epgEntry.StartTime.ToShortDateString() + " " +
                                              epgEntry.StartTime.ToString("HH:mm") + " - " +
                                              epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                              epgEntry.EventName);
                        }

                        if (descriptionLogger != null && epgEntry.ShortDescription != null)
                        {
                            descriptionLogger.Write(epgEntry.ServiceID + " " +
                                                    " Evt ID " + epgEntry.EventID +
                                                    epgEntry.StartTime.ToShortDateString() + " " +
                                                    epgEntry.StartTime.ToString("HH:mm") + " - " +
                                                    epgEntry.StartTime.Add(epgEntry.Duration).ToString("HH:mm") + " " +
                                                    epgEntry.ShortDescription);
                        }
                    }
                }
            }
        }
Example #27
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            #region Test Data
            TVStation new1 = new TVStation("TVOne");
            new1.AudioPID          = 1;
            new1.DSMCCPID          = 1332;
            new1.Frequency         = 538000;
            new1.MappedServiceID   = 29;
            new1.Name              = "TVOne";
            new1.OriginalNetworkID = 100;
            new1.ServiceID         = 1200;
            new1.ServiceType       = 22;
            new1.TransportStreamID = 3;
            TVStation.StationCollection.Add(new1);

            new1                   = new TVStation("TVTwo");
            new1.AudioPID          = 2;
            new1.DSMCCPID          = 2332;
            new1.Frequency         = 638000;
            new1.MappedServiceID   = 25;
            new1.Name              = "TVTwo";
            new1.OriginalNetworkID = 200;
            new1.ServiceID         = 1201;
            new1.ServiceType       = 22;
            new1.TransportStreamID = 4;
            TVStation.StationCollection.Add(new1);

            new1                   = new TVStation("TV3");
            new1.AudioPID          = 3;
            new1.DSMCCPID          = 4332;
            new1.Frequency         = 738000;
            new1.MappedServiceID   = 21;
            new1.Name              = "TV3";
            new1.OriginalNetworkID = 300;
            new1.ServiceID         = 1203;
            new1.ServiceType       = 22;
            new1.TransportStreamID = 4;
            TVStation.StationCollection.Add(new1);
            #endregion

            BindingList <TVStation> stations = new BindingList <TVStation>();

            _dgCars.AutoGenerateColumns = false;

            foreach (TVStation item in TVStation.StationCollection)
            {
                stations.Add(item);
            }

            _dgCars.DataSource = stations;

            // network ID, transport ID, service ID, channel ID, name
            DataGridViewCheckBoxColumn selectChannel = new DataGridViewCheckBoxColumn();

            selectChannel.HeaderText = "Collect EPG Data";

            DataGridViewTextBoxColumn nidColumn = new DataGridViewTextBoxColumn();
            nidColumn.DataPropertyName = "OriginalNetworkID";
            nidColumn.HeaderText       = "Network ID (NID)";
            nidColumn.ReadOnly         = true;

            DataGridViewTextBoxColumn tidColumn = new DataGridViewTextBoxColumn();
            tidColumn.DataPropertyName = "TransportStreamID";
            tidColumn.HeaderText       = "Transport ID (TID)";
            tidColumn.ReadOnly         = true;

            DataGridViewTextBoxColumn sidColumn = new DataGridViewTextBoxColumn();
            sidColumn.DataPropertyName = "ServiceID";
            sidColumn.HeaderText       = "Service ID (SID)";
            sidColumn.ReadOnly         = true;

            DataGridViewTextBoxColumn channelIDColumn = new DataGridViewTextBoxColumn();
            channelIDColumn.DataPropertyName = "MappedServiceID";
            channelIDColumn.HeaderText       = "Original Channel ID";

            DataGridViewTextBoxColumn nameColumn = new DataGridViewTextBoxColumn();
            nameColumn.DataPropertyName = "Name";
            nameColumn.HeaderText       = "Original Name";

            _dgCars.Columns.Add(selectChannel);
            _dgCars.Columns.Add(nidColumn);
            _dgCars.Columns.Add(tidColumn);
            _dgCars.Columns.Add(sidColumn);
            _dgCars.Columns.Add(channelIDColumn);
            _dgCars.Columns.Add(nameColumn);
        }
Example #28
0
        /// <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);
                    }
                }
            }
        }
Example #29
0
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            int byteArraySize = 0;

            foreach (SiehFernInfoEPGSection epgSection in SiehFernInfoEPGSection.Sections)
            {
                byteArraySize += epgSection.Data.Length;
            }

            byte[] epgBuffer = new byte[byteArraySize];

            int putIndex = 0;

            foreach (SiehFernInfoEPGSection epgSection in SiehFernInfoEPGSection.Sections)
            {
                epgSection.Data.CopyTo(epgBuffer, putIndex);
                putIndex += epgSection.Data.Length;
            }

            int getIndex = 0;

            while (epgBuffer[getIndex] != '@')
            {
                getIndex++;
            }

            TVStation currentStation = null;

            while (getIndex < epgBuffer.Length)
            {
                byte[] epgLine = getLine(epgBuffer, getIndex);
                getIndex += epgLine.Length;

                for (int scan = 0; scan < epgLine.Length; scan++)
                {
                    if (epgLine[scan] == 0x0d || epgLine[scan] == 0x0a)
                    {
                        epgLine[scan] = (byte)'|';
                    }
                    else
                    {
                        if (epgLine[scan] == 0x8a)
                        {
                            epgLine[scan] = (byte)' ';
                        }
                    }
                }

                string epgText = Utils.GetString(epgLine, 0, epgLine.Length);

                switch (epgText.Substring(0, 3))
                {
                case "@P:":
                    currentStation = processStation(epgText);
                    TVStation.StationCollection.Add(currentStation);
                    break;

                case "@E:":
                    processProgramTitle(epgText, titleLogger);
                    break;

                case "@S:":
                    processProgramDescription(epgText, descriptionLogger);
                    break;

                default:
                    break;
                }
            }
        }
        /// <summary>
        /// Create the EPG entries.
        /// </summary>
        public override void FinishFrequency()
        {
            if (MediaHighwayChannel.Channels.Count == 0)
            {
                return;
            }

            foreach (MediaHighwaySummary summary in MediaHighwaySummary.Summaries)
            {
                if (summary.Replays != null)
                {
                    MediaHighwayChannelTitle title = MediaHighwayChannel.FindChannelTitle(summary.EventID);
                    if (title != null)
                    {
                        foreach (MediaHighway1Replay replay in summary.Replays)
                        {
                            MediaHighwayTitle replayTitle = new MediaHighwayTitle();
                            replayTitle.EventID          = title.Title.EventID;
                            replayTitle.EventName        = title.Title.EventName;
                            replayTitle.CategoryID       = title.Title.CategoryID;
                            replayTitle.StartTime        = replay.ReplayTime;
                            replayTitle.Duration         = title.Title.Duration;
                            replayTitle.SummaryAvailable = true;
                            replayTitle.PreviousPlayDate = title.Title.StartTime;
                            ((MediaHighwayChannel)Channel.FindChannel(replay.Channel)).AddTitleData(replayTitle);

                            if (RunParameters.Instance.DebugIDs.Contains("REPLAYS"))
                            {
                                Logger.Instance.Write("Replay: ch" + replay.Channel + " " +
                                                      title.Title.EventName + " " +
                                                      title.Title.StartTime + " " +
                                                      title.Title.Duration + " " +
                                                      replay.ReplayTime);
                            }
                        }
                    }
                }
            }

            Logger titleLogger       = null;
            Logger descriptionLogger = 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");
            }

            foreach (MediaHighwayChannel channel in MediaHighwayChannel.Channels)
            {
                TVStation station = TVStation.FindStation(channel.OriginalNetworkID, channel.TransportStreamID, channel.ServiceID);
                if (station == null)
                {
                    station = new TVStation(channel.ChannelName);
                    station.OriginalNetworkID = channel.OriginalNetworkID;
                    station.TransportStreamID = channel.TransportStreamID;
                    station.ServiceID         = channel.ServiceID;
                    TVStation.AddStation(station);
                }

                station.Name = channel.ChannelName;

                if (station.LogicalChannelNumber == -1)
                {
                    station.LogicalChannelNumber = channel.UserChannel;
                }

                if (station.EPGCollection.Count == 0)
                {
                    channel.ProcessChannelForEPG(station, titleLogger, descriptionLogger, CollectionType.MediaHighway1);
                }
            }

            MediaHighwayProgramCategory.LogCategories();
            Channel.LogChannelsInChannelOrder();
        }