protected void InitCommonData(int slot, SignalSource signalSource, DataMapping data) { this.InUse = data.GetFlag(_InUse, true); this.RecordIndex = slot; this.RecordOrder = slot; this.SignalSource = signalSource; this.OldProgramNr = (short)data.GetWord(_ProgramNr); this.Name = data.GetString(_Name, data.Settings.GetInt("lenName")); this.Favorites = this.ParseRawFavorites(); this.Lock = data.GetFlag(_Lock); int hiddenPrimary = data.GetByte(_Hidden); if (hiddenPrimary == 255) { this.Hidden = data.GetByte(_HiddenAlt) != 0; } else { this.Hidden = hiddenPrimary != 0; } this.Skip = data.GetFlag(_Skip); this.Encrypted = data.GetFlag(_Encrypted); this.IsDeleted = data.GetFlag(_Deleted, false) || !data.GetFlag(_IsActive, true); this.AddDebug(data.Data, data.BaseOffset + 25, 3); }
private void ParseNames() { mapping.SetDataPtr(this.rawData, this.baseOffset); DvbStringDecoder dec = new DvbStringDecoder(mapping.DefaultEncoding); string longName, shortName; dec.GetChannelNames(this.rawData, this.baseOffset + mapping.GetOffsets(_Name)[0], mapping.GetByte(_NameLength), out longName, out shortName); this.Name = longName; this.ShortName = shortName; }
public LnbConfig(DataMapping mapping, DataRoot dataRoot) { this.Id = mapping.GetByte("SettingId"); if (this.Id == 0) { return; } int satIndex = mapping.GetByte("SatIndex"); this.Satellite = dataRoot.Satellites[satIndex]; }
private void LoadDvbCT(ChannelList list, string path, string mappingName) { if (!ReadAndValidateChannellibFile(path, out var data, out var recordSize, out var recordCount)) { return; } var mapping = new DataMapping(this.ini.GetSection(mappingName)); mapping.SetDataPtr(data, chanLstBin.VersionMajor <= 11 ? 20 : 12); for (int i = 0; i < recordCount; i++, mapping.BaseOffset += recordSize) { var progNr = mapping.GetWord("offProgNr"); var offChannelName = mapping.BaseOffset + mapping.GetConst("offName", 0); var lenName = mapping.GetConst("lenName", 0); for (int j = 0; j < lenName; j += 2) { if (data[offChannelName + j] == 0) { lenName = j; break; } } string channelName = Encoding.Unicode.GetString(data, offChannelName, lenName); if (chanLstBin.VersionMajor <= 11) { var checksum = mapping.GetDword("offChecksum"); mapping.SetDword("offChecksum", 0); var crc = FaultyCrc32(data, mapping.BaseOffset + mapping.GetConst("offChecksum", 0), recordSize); if (crc != checksum) { throw new FileLoadException($"Invalid CRC in record {i} in {path}"); } } var ch = new Channel(list.SignalSource, i, progNr, channelName); ch.Id = mapping.GetWord("offId"); // only relevant for ChannelMap45 ch.FreqInMhz = (decimal)mapping.GetWord("offFreqTimes16") / 16; ch.OriginalNetworkId = mapping.GetWord("offOnid"); ch.TransportStreamId = mapping.GetWord("offTsid"); ch.ServiceId = mapping.GetWord("offSid"); ch.SymbolRate = (int)mapping.GetDword("offSymbolRate") / 1000; ch.Lock = mapping.GetByte("offLocked") != 0; ch.Favorites = mapping.GetByte("offIsFav") != 0 ? Favorites.A : 0; if (ch.Favorites != 0) { ch.OldFavIndex[0] = ch.OldProgramNr; } this.DataRoot.AddChannel(list, ch); } }
private Favorites ParseRawFavorites() { var offsets = mapping.GetOffsets(_Favorites); if (offsets.Length == 1) // series B,C { return((Favorites)mapping.GetByte(_Favorites)); } // series D,E,F byte fav = 0; byte mask = 0x01; int favIndex = 0; foreach (int off in offsets) { int favValue = BitConverter.ToInt32(this.rawData, baseOffset + off); if (sortedFavorites == FavoritesIndexMode.Boolean && favValue != 0) { fav |= mask; } else if (sortedFavorites != FavoritesIndexMode.Boolean && favValue != -1) { fav |= mask; } if (sortedFavorites == FavoritesIndexMode.IndividuallySorted) { this.FavIndex[favIndex] = favValue; } mask <<= 1; ++favIndex; } return((Favorites)fav); }
public DigitalChannel(int slot, SignalSource signalSource, DataMapping data, IDictionary <int, decimal> transpFreq, FavoritesIndexMode sortedFavorites, IDictionary <int, string> providerNames) : base(data, sortedFavorites) { this.InitCommonData(slot, (SignalSource)((int)signalSource & ~(int)(SignalSource.TvAndRadio)), data); if (!this.InUse || this.OldProgramNr == 0) { return; } this.InitDvbData(data, providerNames); int transp = data.GetByte(_ChannelOrTransponder); decimal freq = transpFreq.TryGet(transp); if (freq == 0) { if ((this.SignalSource & SignalSource.Antenna) != 0) { freq = transp * 8 + 306; } else if ((this.SignalSource & SignalSource.Cable) != 0) { freq = transp * 8 + 106; } } this.ChannelOrTransponder = transp.ToString(); this.FreqInMhz = freq; }
public void TestByte() { DataMapping mapping = new DataMapping(); byte[] data = new byte[12]; for (byte i = byte.MinValue; i < byte.MaxValue; i++) { Array.Clear(data, 0, 12); mapping.Data = data; mapping.SetByte(0, i); Assert.AreEqual(i, mapping.GetByte(0)); } Array.Clear(data, 0, 12); mapping.Data = data; mapping.SetByte(0, byte.MaxValue); Assert.AreEqual(byte.MaxValue, mapping.GetByte(0)); }
/* * offFavorites2 = 134 * offAudioPid2 = 182 */ public DtvChannel(int slot, DataMapping data) : base(data) { var signalSource = SignalSource.Digital; signalSource |= data.GetByte(_SignalSource) == 1 ? SignalSource.Antenna : SignalSource.Cable; this.InitCommonData(slot, signalSource, data); this.InitDvbData(data); int channel = data.GetByte(_ChannelOrTransponder); this.ChannelOrTransponder = channel.ToString("d2"); // ReSharper disable PossibleLossOfFraction this.FreqInMhz = (data.GetDword(_FrequencyLong) + 10) / 1000; // ReSharper restore PossibleLossOfFraction if (this.FreqInMhz == 0) { this.FreqInMhz = LookupData.Instance.GetDvbtFrequency(channel); } }
protected void InitDvbData(DataMapping data) { this.ServiceId = data.GetWord(_ServiceId); //this.PcrPid = data.GetWord(_PcrPid); this.VideoPid = data.GetWord(_VideoPid); this.AudioPid = data.GetWord(_AudioPid); this.OriginalNetworkId = data.GetWord(_OriginalNetworkId); this.TransportStreamId = data.GetWord(_TransportStreamId); this.ServiceType = data.GetByte(_ServiceType); this.ProgramNrPreset = data.GetWord(_ProgramNrPreset); }
private void InsertChannelData(DbCommand cmd, int listId) { PrepareChannelInsert(cmd); DvbStringDecoder decoder = new DvbStringDecoder(this.DefaultEncoding); DataMapping dvbsMapping = this.dvbsMappings.GetMapping(this.dvbsBlockSize); dvbsMapping.SetDataPtr(this.fileContent, this.dvbsBlockOffset + this.satConfig.ChannelListOffset); for (int slot = 0; slot < this.dvbsChannelCount; slot++) { cmd.Parameters["@listid"].Value = listId; cmd.Parameters["@slot"].Value = slot; cmd.Parameters["@seq"].Value = DBNull.Value; cmd.Parameters["@isdel"].Value = dvbsMapping.GetFlag("InUse") ? 0 : 1; cmd.Parameters["@progmask"].Value = dvbsMapping.GetWord("offProgramNr"); cmd.Parameters["@prognr"].Value = dvbsMapping.GetWord("offProgramNr") & 0x3FFF; cmd.Parameters["@progfix"].Value = dvbsMapping.GetWord("offProgramNrPreset"); int absNameOffset = dvbsMapping.BaseOffset + dvbsMapping.GetOffsets("offName")[0]; string longName, shortName; decoder.GetChannelNames(fileContent, absNameOffset, dvbsMapping.GetByte("offNameLength"), out longName, out shortName); cmd.Parameters["@name"].Value = longName; cmd.Parameters["@tpnr"].Value = dvbsMapping.GetWord("offTransponderIndex"); var transp = this.DataRoot.Transponder.TryGet(dvbsMapping.GetWord("offTransponderIndex")); cmd.Parameters["@satnr"].Value = transp == null ? (object)DBNull.Value : transp.Satellite.Id; cmd.Parameters["@onid"].Value = transp == null ? (object)DBNull.Value : transp.OriginalNetworkId; cmd.Parameters["@tsid"].Value = transp == null ? (object)DBNull.Value : transp.TransportStreamId; cmd.Parameters["@ssid"].Value = (int)dvbsMapping.GetWord("offServiceId"); cmd.Parameters["@uid"].Value = transp == null ? (object)DBNull.Value : transp.TransportStreamId + "-" + transp.OriginalNetworkId + "-" + dvbsMapping.GetWord("offServiceId"); cmd.Parameters["@favcrypt"].Value = (int)dvbsMapping.GetByte("offFavorites"); cmd.Parameters["@lockskiphide"].Value = (int)dvbsMapping.GetByte("offLock"); cmd.ExecuteNonQuery(); dvbsMapping.BaseOffset += this.satConfig.dvbsChannelLength; } }
public DigitalChannel(int slot, SignalSource signalSource, DataMapping data, DataRoot dataRoot, IDictionary <int, decimal> transpFreq, FavoritesIndexMode sortedFavorites, IDictionary <int, string> providerNames) : base(data, sortedFavorites) { // ToDo - ShiT this.InitCommonData(slot, signalSource & ~SignalSource.TVAndRadioAndData, data); if (!this.InUse) { return; } // "InUse" and "IsDeleted" are not always guessed correctly. If PrNr=0, the channel contains garbage if (this.OldProgramNr == 0) { this.InUse = false; return; } this.InitDvbData(data, providerNames); decimal freq = 0; int transp = data.GetByte(_ChannelOrTransponder); if (dataRoot.Transponder.TryGetValue(transp, out var tp)) { this.Polarity = tp.Polarity; } freq = transpFreq.TryGet(transp); if (freq == 0 && tp != null) { freq = tp.FrequencyInMhz; } if (freq == 0) { if ((this.SignalSource & SignalSource.Antenna) != 0) { freq = transp * 8 + 306; } else if ((this.SignalSource & SignalSource.Cable) != 0) { freq = transp * 8 + 106; } } this.ChannelOrTransponder = transp.ToString(); this.FreqInMhz = freq; }
protected void InitCommonData(int slot, SignalSource signalSource, DataMapping data) { this.RecordIndex = slot; var nr = data.GetWord(_ProgramNr); this.SignalSource = signalSource | ((nr & 0x4000) == 0 ? SignalSource.Tv : SignalSource.Radio); this.OldProgramNr = (nr & 0x3FFF); this.ParseNames(); this.Favorites = (Favorites)((data.GetByte(_Favorites2) & 0x3C) >> 2); this.Lock = data.GetFlag(_Lock); this.Skip = data.GetFlag(_Skip); this.Hidden = data.GetFlag(_Hide); this.Encrypted = data.GetFlag(_Encrypted); this.IsDeleted = data.GetFlag(_Deleted); }
protected void InitDvbData(DataMapping data, IDictionary <int, string> providerNames) { this.ShortName = data.GetString(_ShortName, data.Settings.GetInt("lenShortName")); this.ServiceId = data.GetWord(_ServiceId); //this.PcrPid = data.GetWord(_PcrPid); this.VideoPid = data.GetWord(_VideoPid); this.AudioPid = data.GetWord(_AudioPid); this.OriginalNetworkId = data.GetWord(_OriginalNetworkId); this.TransportStreamId = data.GetWord(_TransportStreamId); this.ServiceType = data.GetByte(_ServiceType); this.SymbolRate = data.GetWord(_SymbolRate); if (data.Settings.GetInt(_ServiceProviderId, -1) != -1) { int source = -1; if ((this.SignalSource & SignalSource.MaskProvider) == SignalSource.Freesat) { source = 4; } else if ((this.SignalSource & SignalSource.MaskProvider) == SignalSource.TivuSat) { source = 6; } else if ((this.SignalSource & SignalSource.Antenna) != 0) { source = 0; } else if ((this.SignalSource & SignalSource.Cable) != 0) { source = 1; } else if ((this.SignalSource & SignalSource.Sat) != 0) { source = 3; } int providerId = data.GetWord(_ServiceProviderId); this.Provider = providerNames.TryGet((source << 16) + providerId); } this.SignalSource |= LookupData.Instance.IsRadioOrTv(this.ServiceType); }
public SatTransponder(int index, DataMapping mapping, DataRoot dataRoot, int satIndexFactor) : base(index) { this.mapping = mapping; this.data = mapping.Data; this.offset = mapping.BaseOffset; this.firstChannelIndex = mapping.GetWord(_FirstChannelIndex); this.lastChannelIndex = mapping.GetWord(_LastChannelIndex); this.FrequencyInMhz = mapping.GetWord(_Frequency); this.OriginalNetworkId = mapping.GetWord(_OriginalNetworkId); this.TransportStreamId = mapping.GetWord(_TransportStreamId); this.symbolRate = mapping.GetWord(_SymbolRate); if (this.symbolRate % 100 >= 95) { this.symbolRate = (this.symbolRate / 100 + 1) * 100; } // note: a correction factor is applied later after all transponders were loaded (*0.5, *1, *2) this.Satellite = dataRoot.Satellites.TryGet(mapping.GetByte(_SatIndex) / satIndexFactor); }
public DigitalChannel(int slot, SignalSource signalSource, DataMapping data, IDictionary <int, decimal> transpFreq, FavoritesIndexMode sortedFavorites, IDictionary <int, string> providerNames) : base(data, sortedFavorites) { this.InitCommonData(slot, (SignalSource)((int)signalSource & ~(int)(SignalSource.TvAndRadio)), data); if (!this.InUse || this.OldProgramNr == 0) { return; } this.InitDvbData(data, providerNames); int transp = data.GetByte(_ChannelOrTransponder); decimal freq = transpFreq.TryGet(transp); if (freq == 0) { freq = LookupData.Instance.GetDvbtFrequeny(transp); // transp*8 + 106); // (106 = DVB-C; DVB-T=306?) } this.ChannelOrTransponder = transp.ToString(); this.FreqInMhz = freq; }