diff --git a/ChanSort.Loader.ScmFile/AnalogChannel.cs b/ChanSort.Loader.ScmFile/AnalogChannel.cs index b3ad71e..ec1c014 100644 --- a/ChanSort.Loader.ScmFile/AnalogChannel.cs +++ b/ChanSort.Loader.ScmFile/AnalogChannel.cs @@ -9,7 +9,8 @@ namespace ChanSort.Loader.ScmFile #region ctor() - public AnalogChannel(int slot, SignalSource signalSource, DataMapping mapping, decimal freq) : base(mapping) + public AnalogChannel(int slot, SignalSource signalSource, DataMapping mapping, decimal freq, int favoriteNotSetValue) : + base(mapping, favoriteNotSetValue) { this.InitCommonData(slot, signalSource, mapping); diff --git a/ChanSort.Loader.ScmFile/ChanSort.Loader.ScmFile.ini b/ChanSort.Loader.ScmFile/ChanSort.Loader.ScmFile.ini index 51fd058..516267e 100644 --- a/ChanSort.Loader.ScmFile/ChanSort.Loader.ScmFile.ini +++ b/ChanSort.Loader.ScmFile/ChanSort.Loader.ScmFile.ini @@ -10,7 +10,6 @@ map-SateD = 144 Favorites = 4 - [Series:C] SatDataBase.dat = 145 TransponderDataBase.dat = 45 @@ -31,6 +30,7 @@ map-SateD = 172 map-AstraHDPlusD = 212 Favorites = 5 + FavoriteNotSet = 0 [Series:E] SatDataBase.dat = 145 @@ -42,6 +42,7 @@ map-SateD = 168 map-AstraHDPlusD = 212 Favorites = 5 + FavoriteNotSet = -1 [Analog:28] ; map-AirA and map-CableA for B series diff --git a/ChanSort.Loader.ScmFile/DigitalChannel.cs b/ChanSort.Loader.ScmFile/DigitalChannel.cs index b1463f7..bf68cf0 100644 --- a/ChanSort.Loader.ScmFile/DigitalChannel.cs +++ b/ChanSort.Loader.ScmFile/DigitalChannel.cs @@ -7,7 +7,9 @@ namespace ChanSort.Loader.ScmFile { private const string _ChannelOrTransponder = "offChannelTransponder"; - public DigitalChannel(int slot, SignalSource signalSource, DataMapping data, IDictionary transpFreq) : base(data) + public DigitalChannel(int slot, SignalSource signalSource, DataMapping data, + IDictionary transpFreq, int favoriteNotSetValue) : + base(data, favoriteNotSetValue) { this.InitCommonData(slot, signalSource, data); this.InitDvbData(data); diff --git a/ChanSort.Loader.ScmFile/ModelConstants.cs b/ChanSort.Loader.ScmFile/ModelConstants.cs index 79219d6..6f69e15 100644 --- a/ChanSort.Loader.ScmFile/ModelConstants.cs +++ b/ChanSort.Loader.ScmFile/ModelConstants.cs @@ -14,6 +14,7 @@ namespace ChanSort.Loader.ScmFile public readonly int dvbtFineTuneLength; public readonly Favorites supportedFavorites; public readonly int ptcLength; + public readonly int favoriteNotSetValue; public ModelConstants(IniFile.Section iniSection) { @@ -31,6 +32,7 @@ namespace ChanSort.Loader.ScmFile for (int i = 0; i < numFavorites; i++) mask = (mask << 1) | 1; this.supportedFavorites = (Favorites)mask; + this.favoriteNotSetValue = iniSection.GetInt("FavoriteNotSet"); } } } diff --git a/ChanSort.Loader.ScmFile/SatChannel.cs b/ChanSort.Loader.ScmFile/SatChannel.cs index bfc741b..10d1bbd 100644 --- a/ChanSort.Loader.ScmFile/SatChannel.cs +++ b/ChanSort.Loader.ScmFile/SatChannel.cs @@ -6,7 +6,8 @@ namespace ChanSort.Loader.ScmFile { private const string _TransponderIndex = "offTransponderIndex"; - public SatChannel(int slot, DataMapping data, DataRoot dataRoot) : base(data) + public SatChannel(int slot, DataMapping data, DataRoot dataRoot, int favoriteNotSetValue) : + base(data, favoriteNotSetValue) { this.InitCommonData(slot, SignalSource.DvbS, data); if (!this.InUse) diff --git a/ChanSort.Loader.ScmFile/ScmChannelBase.cs b/ChanSort.Loader.ScmFile/ScmChannelBase.cs index e407dd1..303cd09 100644 --- a/ChanSort.Loader.ScmFile/ScmChannelBase.cs +++ b/ChanSort.Loader.ScmFile/ScmChannelBase.cs @@ -1,4 +1,5 @@ -using System.Text; +using System; +using System.Text; using ChanSort.Api; namespace ChanSort.Loader.ScmFile @@ -27,6 +28,8 @@ namespace ChanSort.Loader.ScmFile private const string _SymbolRate = "offSymbolRate"; private static readonly Encoding Utf16BigEndian = new UnicodeEncoding(true, false); + private static readonly byte[] favoriteSetValue = new byte[] { 1, 0, 0, 0 }; + private readonly byte[] favoriteNotSetValue; protected readonly DataMapping mapping; protected readonly byte[] rawData; @@ -34,12 +37,13 @@ namespace ChanSort.Loader.ScmFile internal bool InUse { get; set; } - protected ScmChannelBase(DataMapping data) + protected ScmChannelBase(DataMapping data, int favoriteNotSetValue) { this.mapping = data; this.rawData = data.Data; this.baseOffset = data.BaseOffset; this.mapping.DefaultEncoding = Utf16BigEndian; + this.favoriteNotSetValue = BitConverter.GetBytes(favoriteNotSetValue); } #region InitCommonData() @@ -71,7 +75,7 @@ namespace ChanSort.Loader.ScmFile byte mask = 0x01; foreach (int off in offsets) { - if ((System.BitConverter.ToInt32(this.rawData, baseOffset + off) + 1) > 1) // -1 and 0 mean "not set" + if ((BitConverter.ToInt32(this.rawData, baseOffset + off) + 1) > 1) // unset/set: D=0, E=-1 fav |= mask; mask <<= 1; } @@ -139,10 +143,8 @@ namespace ChanSort.Loader.ScmFile byte mask = 0x01; foreach (int off in offsets) { - this.rawData[baseOffset + off + 0] = (byte)((fav & mask) == 0 ? 0 : 1); - this.rawData[baseOffset + off + 1] = 0; - this.rawData[baseOffset + off + 2] = 0; - this.rawData[baseOffset + off + 3] = 0; + // unset/set: D-Series=0/1, E-Series=-1/1 + Array.Copy((fav & mask) == 0 ? favoriteNotSetValue : favoriteSetValue, 0, this.rawData, baseOffset + off, 4); mask <<= 1; } } diff --git a/ChanSort.Loader.ScmFile/ScmSerializer.cs b/ChanSort.Loader.ScmFile/ScmSerializer.cs index d3d1974..6c4af5f 100644 --- a/ChanSort.Loader.ScmFile/ScmSerializer.cs +++ b/ChanSort.Loader.ScmFile/ScmSerializer.cs @@ -323,7 +323,7 @@ namespace ChanSort.Loader.ScmFile #region MapAnalogChannel() private void MapAnalogChannel(DataMapping rawChannel, int slotIndex, ChannelList list, decimal freq) { - AnalogChannel ci = new AnalogChannel(slotIndex, list.SignalSource, rawChannel, freq); + AnalogChannel ci = new AnalogChannel(slotIndex, list.SignalSource, rawChannel, freq, c.favoriteNotSetValue); if (!ci.InUse) return; @@ -370,7 +370,7 @@ namespace ChanSort.Loader.ScmFile int count = data.Length / entrySize; for (int slotIndex = 0; slotIndex < count; slotIndex++) { - DigitalChannel ci = new DigitalChannel(slotIndex, list.SignalSource, rawChannel, frequency); + DigitalChannel ci = new DigitalChannel(slotIndex, list.SignalSource, rawChannel, frequency, c.favoriteNotSetValue); if (ci.OldProgramNr != 0) this.DataRoot.AddChannel(list, ci); @@ -456,7 +456,7 @@ namespace ChanSort.Loader.ScmFile mapping.SetDataPtr(dvbsFileContent, 0); for (int slotIndex = 0; slotIndex < count; slotIndex++) { - SatChannel ci = new SatChannel(slotIndex, mapping, this.DataRoot); + SatChannel ci = new SatChannel(slotIndex, mapping, this.DataRoot, c.favoriteNotSetValue); if (ci.InUse) this.DataRoot.AddChannel(this.dvbsChannels, ci); @@ -479,7 +479,7 @@ namespace ChanSort.Loader.ScmFile mapping.SetDataPtr(hdplusFileContent, 0); for (int slotIndex = 0; slotIndex < count; slotIndex++) { - SatChannel ci = new SatChannel(slotIndex, mapping, this.DataRoot); + SatChannel ci = new SatChannel(slotIndex, mapping, this.DataRoot, c.favoriteNotSetValue); if (ci.InUse) this.hdplusChannels.AddChannel(ci); mapping.BaseOffset += entrySize;