mirror of
https://github.com/PredatH0r/ChanSort.git
synced 2026-03-06 12:10:42 +01:00
- FIX: Resizing a column caused an exception
- FIX: Deleting satellite channels from an SCM file did not work correctly - Improved SCM file format detection - Samsung E/F-Series: channels in the favorite lists now use their prog# instead of all being put at #1 - fixed LG unit tests - fixed Samsung tests
This commit is contained in:
@@ -8,8 +8,8 @@ namespace ChanSort.Loader.Samsung
|
||||
|
||||
#region ctor()
|
||||
|
||||
public AnalogChannel(int slot, bool isCable, DataMapping mapping, decimal freq, int favoriteNotSetValue) :
|
||||
base(mapping, favoriteNotSetValue)
|
||||
public AnalogChannel(int slot, bool isCable, DataMapping mapping, decimal freq, bool sortedFavorites) :
|
||||
base(mapping, sortedFavorites)
|
||||
{
|
||||
var signalSource = SignalSource.Analog | SignalSource.Tv;
|
||||
signalSource |= isCable ? SignalSource.Cable : SignalSource.Antenna;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
map-SateD = 172
|
||||
map-AstraHDPlusD = 212
|
||||
Favorites = 5
|
||||
FavoriteNotSet = 0
|
||||
SortedFavorites = 0
|
||||
|
||||
[Series:E]
|
||||
SatDataBase.dat = 145
|
||||
@@ -42,7 +42,7 @@
|
||||
map-SateD = 168
|
||||
map-AstraHDPlusD = 212
|
||||
Favorites = 5
|
||||
FavoriteNotSet = -1
|
||||
SortedFavorites = 1
|
||||
|
||||
[Series:F]
|
||||
SatDataBase.dat = 145
|
||||
@@ -54,7 +54,7 @@
|
||||
map-SateD = 168
|
||||
map-AstraHDPlusD = 212
|
||||
Favorites = 5
|
||||
FavoriteNotSet = -1
|
||||
SortedFavorites = 1
|
||||
|
||||
[Analog:28]
|
||||
; map-AirA and map-CableA for B series
|
||||
@@ -87,7 +87,7 @@
|
||||
offChecksum = 39
|
||||
|
||||
[Analog:64]
|
||||
; map-AirA and map-CableA for D,E series
|
||||
; map-AirA and map-CableA for D,E and F series
|
||||
offInUse = 1
|
||||
maskInUse = 0x01
|
||||
offDeleted = 2
|
||||
@@ -183,7 +183,7 @@
|
||||
|
||||
|
||||
[DvbCT:320]
|
||||
; map-AirD and map-CableD for D and E series
|
||||
; map-AirD and map-CableD for D,E and F series
|
||||
offProgramNr = 0
|
||||
offVideoPid = 2
|
||||
offPcrPid = 4
|
||||
@@ -283,7 +283,7 @@
|
||||
offChecksum = 171
|
||||
|
||||
[DvbS:168]
|
||||
; map-SateD for E Series
|
||||
; map-SateD for E and F Series
|
||||
offProgramNr = 0
|
||||
offVideoPid = 2
|
||||
offPcrPid = 4
|
||||
@@ -308,7 +308,7 @@
|
||||
offChecksum = 167
|
||||
|
||||
[AstraHDPlusD:212]
|
||||
; map-AstraHDPlusD for D and E Series
|
||||
; map-AstraHDPlusD for D, E and F Series
|
||||
offProgramNr = 0,20
|
||||
offVideoPid=2
|
||||
offPcrId=4
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace ChanSort.Loader.Samsung
|
||||
{
|
||||
private const string _ChannelOrTransponder = "offChannelTransponder";
|
||||
|
||||
public DigitalChannel(int slot, bool isCable, DataMapping data,
|
||||
IDictionary<int, decimal> transpFreq, int favoriteNotSetValue) :
|
||||
base(data, favoriteNotSetValue)
|
||||
public DigitalChannel(int slot, bool isCable, DataMapping data,
|
||||
IDictionary<int, decimal> transpFreq, bool sortedFavorites) :
|
||||
base(data, sortedFavorites)
|
||||
{
|
||||
var signalSource = SignalSource.Digital;
|
||||
signalSource |= isCable ? SignalSource.Cable : SignalSource.Antenna;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ChanSort.Loader.Samsung
|
||||
public readonly int dvbtFineTuneLength;
|
||||
public readonly Favorites supportedFavorites;
|
||||
public readonly int ptcLength;
|
||||
public readonly int favoriteNotSetValue;
|
||||
public readonly bool SortedFavorites;
|
||||
|
||||
public ModelConstants(IniFile.Section iniSection)
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace ChanSort.Loader.Samsung
|
||||
for (int i = 0; i < numFavorites; i++)
|
||||
mask = (mask << 1) | 1;
|
||||
this.supportedFavorites = (Favorites)mask;
|
||||
this.favoriteNotSetValue = iniSection.GetInt("FavoriteNotSet");
|
||||
this.SortedFavorites = iniSection.GetInt("SortedFavorites") != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace ChanSort.Loader.Samsung
|
||||
{
|
||||
private const string _TransponderIndex = "offTransponderIndex";
|
||||
|
||||
public SatChannel(int slot, SignalSource presetList, DataMapping data, DataRoot dataRoot, int favoriteNotSetValue) :
|
||||
base(data, favoriteNotSetValue)
|
||||
public SatChannel(int slot, SignalSource presetList, DataMapping data, DataRoot dataRoot, bool sortedFavorites) :
|
||||
base(data, sortedFavorites)
|
||||
{
|
||||
this.InitCommonData(slot, SignalSource.DvbS | presetList, data);
|
||||
if (!this.InUse)
|
||||
@@ -31,5 +31,12 @@ namespace ChanSort.Loader.Samsung
|
||||
this.FreqInMhz = transponder.FrequencyInMhz;
|
||||
this.ChannelOrTransponder = "";
|
||||
}
|
||||
|
||||
public override void UpdateRawData()
|
||||
{
|
||||
if (this.NewProgramNr < 0) // "deleted" flag is currently unknown for sat channels
|
||||
this.InUse = false;
|
||||
base.UpdateRawData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ namespace ChanSort.Loader.Samsung
|
||||
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;
|
||||
private readonly bool sortedFavorites;
|
||||
|
||||
protected readonly DataMapping mapping;
|
||||
protected readonly byte[] rawData;
|
||||
@@ -37,13 +36,13 @@ namespace ChanSort.Loader.Samsung
|
||||
|
||||
internal bool InUse { get; set; }
|
||||
|
||||
protected ScmChannelBase(DataMapping data, int favoriteNotSetValue)
|
||||
protected ScmChannelBase(DataMapping data, bool sortedFavorites)
|
||||
{
|
||||
this.mapping = data;
|
||||
this.rawData = data.Data;
|
||||
this.baseOffset = data.BaseOffset;
|
||||
this.mapping.DefaultEncoding = Utf16BigEndian;
|
||||
this.favoriteNotSetValue = BitConverter.GetBytes(favoriteNotSetValue);
|
||||
this.sortedFavorites = sortedFavorites;
|
||||
}
|
||||
|
||||
#region InitCommonData()
|
||||
@@ -53,7 +52,7 @@ namespace ChanSort.Loader.Samsung
|
||||
this.RecordIndex = slot;
|
||||
this.RecordOrder = slot;
|
||||
this.SignalSource = signalSource;
|
||||
this.OldProgramNr = data.GetWord(_ProgramNr);
|
||||
this.OldProgramNr = (short)data.GetWord(_ProgramNr);
|
||||
this.Name = data.GetString(_Name, data.Settings.GetInt("lenName"));
|
||||
this.Favorites = this.ParseRawFavorites();
|
||||
this.Lock = data.GetFlag(_Lock);
|
||||
@@ -69,12 +68,13 @@ namespace ChanSort.Loader.Samsung
|
||||
if (offsets.Length == 1) // series B,C
|
||||
return (Favorites) mapping.GetByte(_Favorites);
|
||||
|
||||
// series D,E
|
||||
// series D,E,F
|
||||
byte fav = 0;
|
||||
byte mask = 0x01;
|
||||
foreach (int off in offsets)
|
||||
{
|
||||
if ((BitConverter.ToInt32(this.rawData, baseOffset + off) + 1) > 1) // unset/set: D=0, E=-1
|
||||
int favValue = BitConverter.ToInt32(this.rawData, baseOffset + off);
|
||||
if (sortedFavorites && favValue != -1 || !sortedFavorites && favValue != 0)
|
||||
fav |= mask;
|
||||
mask <<= 1;
|
||||
}
|
||||
@@ -105,7 +105,8 @@ namespace ChanSort.Loader.Samsung
|
||||
{
|
||||
mapping.SetDataPtr(this.rawData, this.baseOffset);
|
||||
mapping.SetFlag(_InUse, this.InUse);
|
||||
mapping.SetWord(_ProgramNr, this.NewProgramNr);
|
||||
if (this.NewProgramNr >= 0)
|
||||
mapping.SetWord(_ProgramNr, this.NewProgramNr);
|
||||
if (this.IsNameModified)
|
||||
{
|
||||
int bytes = mapping.SetString(_Name, this.Name, mapping.Settings.GetInt("lenName"));
|
||||
@@ -131,13 +132,17 @@ namespace ChanSort.Loader.Samsung
|
||||
return;
|
||||
}
|
||||
|
||||
// series D,E
|
||||
// series D,E,F
|
||||
byte fav = (byte)this.Favorites;
|
||||
byte mask = 0x01;
|
||||
foreach (int off in offsets)
|
||||
{
|
||||
// unset/set: D-Series=0/1, E-Series=-1/1
|
||||
Array.Copy((fav & mask) == 0 ? favoriteNotSetValue : favoriteSetValue, 0, this.rawData, baseOffset + off, 4);
|
||||
int favValue;
|
||||
if (this.sortedFavorites)
|
||||
favValue = (fav & mask) != 0 ? this.NewProgramNr : -1;
|
||||
else
|
||||
favValue = (fav & mask) != 0 ? 1 : 0;
|
||||
Array.Copy(BitConverter.GetBytes(favValue), 0, this.rawData, baseOffset + off, 4);
|
||||
mask <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ namespace ChanSort.Loader.Samsung
|
||||
private void DetectModelConstants(ZipFile zip)
|
||||
{
|
||||
if (DetectModelFromCloneInfoFile(zip)) return;
|
||||
if (DetectModelFromContentFileLengths(zip)) return;
|
||||
if (DetectModelFromFileName()) return;
|
||||
if (DetectModelFromContentFileLengths(zip)) return;
|
||||
throw new FileLoadException("Unable to determine TV model from file content or name");
|
||||
}
|
||||
#endregion
|
||||
@@ -125,7 +125,7 @@ namespace ChanSort.Loader.Samsung
|
||||
{
|
||||
string file = Path.GetFileName(this.FileName);
|
||||
System.Text.RegularExpressions.Regex regex =
|
||||
new System.Text.RegularExpressions.Regex("channel_list_[A-Z]{2}[0-9]{2}([A-Z])[0-9A-Z]+_[0-9]+\\.scm");
|
||||
new System.Text.RegularExpressions.Regex("channel_list_(?:[A-Z]{2}[0-9]{2}|BD-)([A-Z])[0-9A-Z]+_[0-9]{4}.*\\.scm");
|
||||
var match = regex.Match(file);
|
||||
if (match.Success)
|
||||
{
|
||||
@@ -336,7 +336,7 @@ namespace ChanSort.Loader.Samsung
|
||||
private void MapAnalogChannel(DataMapping rawChannel, int slotIndex, ChannelList list, decimal freq)
|
||||
{
|
||||
bool isCable = (list.SignalSource & SignalSource.Cable) != 0;
|
||||
AnalogChannel ci = new AnalogChannel(slotIndex, isCable, rawChannel, freq, c.favoriteNotSetValue);
|
||||
AnalogChannel ci = new AnalogChannel(slotIndex, isCable, rawChannel, freq, c.SortedFavorites);
|
||||
if (!ci.InUse)
|
||||
return;
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace ChanSort.Loader.Samsung
|
||||
int count = data.Length / entrySize;
|
||||
for (int slotIndex = 0; slotIndex < count; slotIndex++)
|
||||
{
|
||||
DigitalChannel ci = new DigitalChannel(slotIndex, isCable, rawChannel, frequency, c.favoriteNotSetValue);
|
||||
DigitalChannel ci = new DigitalChannel(slotIndex, isCable, rawChannel, frequency, c.SortedFavorites);
|
||||
if (ci.OldProgramNr > 0)
|
||||
this.DataRoot.AddChannel(list, ci);
|
||||
|
||||
@@ -399,9 +399,10 @@ namespace ChanSort.Loader.Samsung
|
||||
private void ReadSatellites(ZipFile zip)
|
||||
{
|
||||
byte[] data = ReadFileContent(zip, "SatDataBase.dat");
|
||||
if (data == null)
|
||||
if (data == null || data.Length < 4)
|
||||
return;
|
||||
|
||||
this.SatDatabaseVersion = System.BitConverter.ToInt32(data, 0);
|
||||
SatelliteMapping satMapping = new SatelliteMapping(data, 4);
|
||||
int count = data.Length/this.c.dvbsSatelliteLength;
|
||||
for (int i = 0; i < count; i++)
|
||||
@@ -472,7 +473,7 @@ namespace ChanSort.Loader.Samsung
|
||||
mapping.SetDataPtr(dvbsFileContent, 0);
|
||||
for (int slotIndex = 0; slotIndex < count; slotIndex++)
|
||||
{
|
||||
SatChannel ci = new SatChannel(slotIndex, SignalSource.StandardSat, mapping, this.DataRoot, c.favoriteNotSetValue);
|
||||
SatChannel ci = new SatChannel(slotIndex, SignalSource.StandardSat, mapping, this.DataRoot, c.SortedFavorites);
|
||||
if (ci.InUse)
|
||||
this.DataRoot.AddChannel(this.dvbsChannels, ci);
|
||||
|
||||
@@ -495,7 +496,7 @@ namespace ChanSort.Loader.Samsung
|
||||
mapping.SetDataPtr(hdplusFileContent, 0);
|
||||
for (int slotIndex = 0; slotIndex < count; slotIndex++)
|
||||
{
|
||||
SatChannel ci = new SatChannel(slotIndex, SignalSource.AstraHdPlus, mapping, this.DataRoot, c.favoriteNotSetValue);
|
||||
SatChannel ci = new SatChannel(slotIndex, SignalSource.AstraHdPlus, mapping, this.DataRoot, c.SortedFavorites);
|
||||
if (ci.InUse)
|
||||
this.DataRoot.AddChannel(this.hdplusChannels, ci);
|
||||
mapping.BaseOffset += entrySize;
|
||||
@@ -590,5 +591,6 @@ namespace ChanSort.Loader.Samsung
|
||||
internal int DigitalChannelLength { get { return c.dvbtChannelLength; } }
|
||||
internal int SatChannelLength { get { return c.dvbsChannelLength; } }
|
||||
internal int HdPlusChannelLength { get { return c.hdplusChannelLength; } }
|
||||
internal int SatDatabaseVersion { get; private set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user