- new: applying channel names from .csv reference lists to current channel list

- fixed: samsung channel data wasn't updated anymore after the file was saved the 1st time
- fixed: deleted channels for samsung B series
- fixed: samsung channel name length reduced to 50char/100byte
This commit is contained in:
hbeham
2013-11-16 21:00:51 +01:00
parent 8ce26520ac
commit dfd44c1950
11 changed files with 112 additions and 52 deletions

View File

@@ -126,7 +126,9 @@
offProgramNr = 0
offVideoPid = 2
offPcrPid = 4
offFavOld = 6
; "Deleted"-flag is implemented in reverse by IsActive
offIsActive = 6
maskIsActive = 0x02
offQam = 7
offInUse = 8
maskInUse = 0x80
@@ -175,7 +177,7 @@
offLogicalProgramNr = 44
offTransportStreamId = 48
offName = 64
lenName = 200
lenName = 100
offShortName = 264
lenShortName = 18
offVideoFormat = 282
@@ -210,7 +212,7 @@
offLogicalProgramNr = 44
offTransportStreamId = 48
offName = 64
lenName = 200
lenName = 100
offShortName = 264
lenShortName = 18
offVideoFormat = 282

View File

@@ -19,7 +19,9 @@ namespace ChanSort.Loader.Samsung
Transponder transponder = dataRoot.Transponder.TryGet(transponderIndex);
if (transponder == null)
{
dataRoot.Warnings.AppendLine("Invalid transponder index: " + transponderIndex);
var list = dataRoot.GetChannelList(this.SignalSource|SignalSource.Tv);
dataRoot.Warnings.AppendFormat("{0} channel record #{1} (Pr# {2} \"{3}\") contains invalid transponder index {4}\r\n",
list.ShortCaption, slot, this.OldProgramNr, this.Name, transponderIndex);
return;
}

View File

@@ -13,6 +13,7 @@ namespace ChanSort.Loader.Samsung
private const string _NameLength = "offNameLength";
private const string _ShortName = "offShortName";
private const string _Favorites = "offFavorites";
private const string _IsActive = "IsActive";
private const string _Deleted = "Deleted";
private const string _Encrypted = "Encrypted";
private const string _Lock = "Lock";
@@ -57,7 +58,7 @@ namespace ChanSort.Loader.Samsung
this.Favorites = this.ParseRawFavorites();
this.Lock = data.GetFlag(_Lock);
this.Encrypted = data.GetFlag(_Encrypted);
this.IsDeleted = data.GetFlag(_Deleted);
this.IsDeleted = data.GetFlag(_Deleted, false) || !data.GetFlag(_IsActive, true);
if (this.IsDeleted)
this.OldProgramNr = -1;
}
@@ -123,11 +124,19 @@ namespace ChanSort.Loader.Samsung
this.UpdateRawFavorites();
mapping.SetFlag(_Lock, this.Lock);
mapping.SetFlag(_Deleted, this.NewProgramNr < 0);
mapping.SetFlag(_IsActive, this.NewProgramNr >= 0);
this.UpdateChecksum();
}
#endregion
#region EraseRawData()
internal virtual void EraseRawData()
{
int len = this.mapping.Settings.GetInt("offChecksum") + 1;
Tools.MemSet(this.rawData, this.baseOffset, 0, len);
}
#endregion
#region UpdateRawFavorites()
private void UpdateRawFavorites()
{
@@ -146,9 +155,9 @@ namespace ChanSort.Loader.Samsung
{
int favValue;
if (this.sortedFavorites)
favValue = (fav & mask) != 0 ? this.FavIndex[favIndex] : -1;
favValue = (fav & mask) != 0 ? this.FavIndex[favIndex] : -1; // E,F series
else
favValue = (fav & mask) != 0 ? 1 : 0;
favValue = (fav & mask) != 0 ? 1 : 0; // D series
Array.Copy(BitConverter.GetBytes(favValue), 0, this.rawData, baseOffset + off, 4);
mask <<= 1;
++favIndex;

View File

@@ -2,7 +2,7 @@
using System.IO;
using System.Reflection;
using System.Linq;
using System.Windows.Forms;
using System.Text;
using ChanSort.Api;
using ICSharpCode.SharpZipLib.Zip;
@@ -48,6 +48,7 @@ namespace ChanSort.Loader.Samsung
{
this.ReadConfigurationFromIniFile();
this.Features.ChannelNameEdit = true;
this.Features.CleanUpChannelData = true;
}
#endregion
@@ -546,21 +547,21 @@ namespace ChanSort.Loader.Samsung
using (ZipFile zip = new ZipFile(tvOutputFile))
{
zip.BeginUpdate();
this.SaveChannels(zip, "map-AirA", this.avbtChannels, ref this.avbtFileContent);
this.SaveChannels(zip, "map-CableA", this.avbcChannels, ref this.avbcFileContent);
this.SaveChannels(zip, "map-AirD", this.dvbtChannels, ref this.dvbtFileContent);
this.SaveChannels(zip, "map-CableD", this.dvbcChannels, ref this.dvbcFileContent);
this.SaveChannels(zip, "map-SateD", this.dvbsChannels, ref this.dvbsFileContent);
this.SaveChannels(zip, "map-AstraHDPlusD", this.hdplusChannels, ref this.hdplusFileContent);
this.SaveChannels(zip, "map-CablePrime_D", this.primeChannels, ref this.primeFileContent);
this.SaveChannels(zip, "map-FreesatD", this.freesatChannels, ref this.freesatFileContent);
this.SaveChannels(zip, "map-AirA", this.avbtChannels, this.avbtFileContent);
this.SaveChannels(zip, "map-CableA", this.avbcChannels, this.avbcFileContent);
this.SaveChannels(zip, "map-AirD", this.dvbtChannels, this.dvbtFileContent);
this.SaveChannels(zip, "map-CableD", this.dvbcChannels, this.dvbcFileContent);
this.SaveChannels(zip, "map-SateD", this.dvbsChannels, this.dvbsFileContent);
this.SaveChannels(zip, "map-AstraHDPlusD", this.hdplusChannels, this.hdplusFileContent);
this.SaveChannels(zip, "map-CablePrime_D", this.primeChannels, this.primeFileContent);
this.SaveChannels(zip, "map-FreesatD", this.freesatChannels, this.freesatFileContent);
zip.CommitUpdate();
}
}
#endregion
#region SaveChannels()
private void SaveChannels(ZipFile zip, string fileName, ChannelList channels, ref byte[] fileContent)
private void SaveChannels(ZipFile zip, string fileName, ChannelList channels, byte[] fileContent)
{
if (fileContent == null)
return;
@@ -570,11 +571,6 @@ namespace ChanSort.Loader.Samsung
using (var stream = new FileStream(tempFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
this.WriteChannels(channels, fileContent, stream);
stream.Flush();
stream.Seek(0, SeekOrigin.Begin);
int size = (int)new FileInfo(tempFilePath).Length;
fileContent = new byte[size];
stream.Read(fileContent, 0, size);
}
zip.Add(tempFilePath, fileName);
@@ -594,6 +590,46 @@ namespace ChanSort.Loader.Samsung
}
#endregion
// -------- cleanup --------
#region CleanUpChannelData()
public override string CleanUpChannelData()
{
StringBuilder log = new StringBuilder();
RemoveChannelsWithServiceType0(log);
RemoveDuplicateAnalogList(log);
return log.ToString();
}
private void RemoveChannelsWithServiceType0(StringBuilder log)
{
foreach (var list in this.DataRoot.ChannelLists)
{
if ((list.SignalSource & SignalSource.Digital) == 0)
continue;
var listOfChannels = new List<ChannelInfo>(list.Channels);
foreach (ScmChannelBase channel in listOfChannels)
{
if (channel.ServiceType == 0)
{
channel.EraseRawData();
list.Channels.Remove(channel);
log.AppendFormat("{0} channel at index {1} (Pr# {2} \"{3}\") was erased due to invalid service type 0\r\n",
list.ShortCaption, channel.RecordIndex, channel.OldProgramNr, channel.Name);
}
}
}
}
private void RemoveDuplicateAnalogList(StringBuilder log)
{
if (this.avbtChannels.Count == 0 || this.avbcChannels.Count == 0)
return;
// TODO
}
#endregion
// ------- testing -----------
internal string Series { get { return c.series; } }