complete support for Samsung J series (added DVB-T, analog and reference list support)

This commit is contained in:
hbeham
2015-06-05 06:08:40 +02:00
parent 61a53d3904
commit a6c50f48a2
12 changed files with 323 additions and 128 deletions

View File

@@ -1,4 +1,13 @@
ONID;Start;End;Name;Operator
SERVICETYPE;Number;Description
SERVICETYPE;01;SD-TV
SERVICETYPE;02;Radio
SERVICETYPE;12;Data/Test
SERVICETYPE;22;SD-TV
SERVICETYPE;25;HD-TV
SERVICETYPE;31;4K-TV
SERVICETYPE;211;Option
ONID;Start;End;Name;Operator
ONID;0x0000;0x0000;(Reserved);(Reserved)
ONID;0x0001;0x0001;Société Européenne des Satellites;Société Européenne des Satellites
ONID;0x0002;0x0002;Société Européenne des Satellites;Société Européenne des Satellites
@@ -417,11 +426,110 @@ TRANSP;118;12699
TRANSP;119;12722
TRANSP;120;12728
SERVICETYPE;Number;Description
SERVICETYPE;01;SD-TV
SERVICETYPE;02;Radio
SERVICETYPE;12;Data/Test
SERVICETYPE;22;SD-TV
SERVICETYPE;25;HD-TV
SERVICETYPE;31;4K-TV
SERVICETYPE;211;Option
DVBC;kHz;Channel
DVBC;50500;2
DVBC;57500;3
DVBC;64500;4
DVBC;71500;S 01
DVBC;78500;S 02
DVBC;85500;S 03
DVBC;107500;SE 1
DVBC;113000;SE 2
DVBC;114500;SE 2
DVBC;121000;SE 3
DVBC;121500;SE 3
DVBC;128500;SE 4
DVBC;135500;SE 5
DVBC;142500;SE 6
DVBC;149500;SE 7
DVBC;156500;SE 8
DVBC;163500;SE 9
DVBC;170500;SE 10
DVBC;177500;5
DVBC;184500;6
DVBC;191500;7
DVBC;198500;8
DVBC;205500;9
DVBC;212500;10
DVBC;219500;11
DVBC;226500;12
DVBC;233500;SE 11
DVBC;240500;SE 12
DVBC;247500;SE 13
DVBC;254500;SE 14
DVBC;261500;SE 15
DVBC;268500;SE 16
DVBC;275500;SE 17
DVBC;282500;SE 18
DVBC;289500;SE 19
DVBC;296500;SE 20
DVBC;306000;S 21
DVBC;314000;S 22
DVBC;322000;S 23
DVBC;330000;S 24
DVBC;338000;S 25
DVBC;346000;S 26
DVBC;354000;S 27
DVBC;362000;S 28
DVBC;370000;S 29
DVBC;378000;S 30
DVBC;386000;S 31
DVBC;394000;S 32
DVBC;402000;S 33
DVBC;410000;S 34
DVBC;418000;S 35
DVBC;426000;S 36
DVBC;434000;S 37
DVBC;442000;S 38
DVBC;450000;S 39
DVBC;458000;S 40
DVBC;466000;S 41
DVBC;474000;21
DVBC;482000;22
DVBC;490000;23
DVBC;498000;24
DVBC;506000;25
DVBC;514000;26
DVBC;522000;27
DVBC;530000;28
DVBC;538000;29
DVBC;546000;30
DVBC;554000;31
DVBC;562000;32
DVBC;570000;33
DVBC;578000;34
DVBC;586000;35
DVBC;594000;36
DVBC;602000;37
DVBC;610000;38
DVBC;618000;39
DVBC;626000;40
DVBC;634000;41
DVBC;642000;42
DVBC;650000;43
DVBC;658000;44
DVBC;666000;45
DVBC;674000;46
DVBC;682000;47
DVBC;690000;48
DVBC;698000;49
DVBC;706000;50
DVBC;714000;51
DVBC;722000;52
DVBC;730000;53
DVBC;738000;54
DVBC;746000;55
DVBC;754000;56
DVBC;762000;57
DVBC;770000;58
DVBC;778000;59
DVBC;786000;60
DVBC;794000;61
DVBC;802000;62
DVBC;810000;63
DVBC;818000;64
DVBC;826000;65
DVBC;834000;66
DVBC;842000;67
DVBC;850000;68
DVBC;858000;69
1 ONID SERVICETYPE;Number;Description Start End Name Operator
2 SERVICETYPE;01;SD-TV
3 SERVICETYPE;02;Radio
4 SERVICETYPE;12;Data/Test
5 SERVICETYPE;22;SD-TV
6 SERVICETYPE;25;HD-TV
7 SERVICETYPE;31;4K-TV
8 SERVICETYPE;211;Option
9 ONID;Start;End;Name;Operator
10 ONID;0x0000;0x0000;(Reserved);(Reserved)
11 ONID ONID;0x0001;0x0001;Société Européenne des Satellites;Société Européenne des Satellites 0x0000 0x0000 (Reserved) (Reserved)
12 ONID ONID;0x0002;0x0002;Société Européenne des Satellites;Société Européenne des Satellites 0x0001 0x0001 Société Européenne des Satellites Société Européenne des Satellites
13 ONID ONID;0x0003;0x0019;Société Européenne des Satellites;Société Européenne des Satellites 0x0002 0x0002 Société Européenne des Satellites Société Européenne des Satellites
426 TRANSP DVBC;kHz;Channel 120 12728
427 SERVICETYPE DVBC;50500;2 Number Description
428 SERVICETYPE DVBC;57500;3 01 SD-TV
429 SERVICETYPE DVBC;64500;4 02 Radio
430 SERVICETYPE DVBC;71500;S 01 12 Data/Test
431 SERVICETYPE DVBC;78500;S 02 22 SD-TV
432 SERVICETYPE DVBC;85500;S 03 25 HD-TV
433 SERVICETYPE DVBC;107500;SE 1 31 4K-TV
434 SERVICETYPE DVBC;113000;SE 2 211 Option
435 DVBC;114500;SE 2
436 DVBC;121000;SE 3
437 DVBC;121500;SE 3
438 DVBC;128500;SE 4
439 DVBC;135500;SE 5
440 DVBC;142500;SE 6
441 DVBC;149500;SE 7
442 DVBC;156500;SE 8
443 DVBC;163500;SE 9
444 DVBC;170500;SE 10
445 DVBC;177500;5
446 DVBC;184500;6
447 DVBC;191500;7
448 DVBC;198500;8
449 DVBC;205500;9
450 DVBC;212500;10
451 DVBC;219500;11
452 DVBC;226500;12
453 DVBC;233500;SE 11
454 DVBC;240500;SE 12
455 DVBC;247500;SE 13
456 DVBC;254500;SE 14
457 DVBC;261500;SE 15
458 DVBC;268500;SE 16
459 DVBC;275500;SE 17
460 DVBC;282500;SE 18
461 DVBC;289500;SE 19
462 DVBC;296500;SE 20
463 DVBC;306000;S 21
464 DVBC;314000;S 22
465 DVBC;322000;S 23
466 DVBC;330000;S 24
467 DVBC;338000;S 25
468 DVBC;346000;S 26
469 DVBC;354000;S 27
470 DVBC;362000;S 28
471 DVBC;370000;S 29
472 DVBC;378000;S 30
473 DVBC;386000;S 31
474 DVBC;394000;S 32
475 DVBC;402000;S 33
476 DVBC;410000;S 34
477 DVBC;418000;S 35
478 DVBC;426000;S 36
479 DVBC;434000;S 37
480 DVBC;442000;S 38
481 DVBC;450000;S 39
482 DVBC;458000;S 40
483 DVBC;466000;S 41
484 DVBC;474000;21
485 DVBC;482000;22
486 DVBC;490000;23
487 DVBC;498000;24
488 DVBC;506000;25
489 DVBC;514000;26
490 DVBC;522000;27
491 DVBC;530000;28
492 DVBC;538000;29
493 DVBC;546000;30
494 DVBC;554000;31
495 DVBC;562000;32
496 DVBC;570000;33
497 DVBC;578000;34
498 DVBC;586000;35
499 DVBC;594000;36
500 DVBC;602000;37
501 DVBC;610000;38
502 DVBC;618000;39
503 DVBC;626000;40
504 DVBC;634000;41
505 DVBC;642000;42
506 DVBC;650000;43
507 DVBC;658000;44
508 DVBC;666000;45
509 DVBC;674000;46
510 DVBC;682000;47
511 DVBC;690000;48
512 DVBC;698000;49
513 DVBC;706000;50
514 DVBC;714000;51
515 DVBC;722000;52
516 DVBC;730000;53
517 DVBC;738000;54
518 DVBC;746000;55
519 DVBC;754000;56
520 DVBC;762000;57
521 DVBC;770000;58
522 DVBC;778000;59
523 DVBC;786000;60
524 DVBC;794000;61
525 DVBC;802000;62
526 DVBC;810000;63
527 DVBC;818000;64
528 DVBC;826000;65
529 DVBC;834000;66
530 DVBC;842000;67
531 DVBC;850000;68
532 DVBC;858000;69
533
534
535

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
@@ -8,9 +9,8 @@ namespace ChanSort.Api
{
private readonly IDictionary<int, NetworkInfo> networks = new Dictionary<int, NetworkInfo>();
private readonly IDictionary<int, int> transponderNrByFreqInMhz = new Dictionary<int, int>();
private readonly IDictionary<int, int> transponderFreqInMhzByNr = new Dictionary<int, int>();
private readonly IDictionary<int, string> serviceTypeDescriptions = new Dictionary<int, string>();
private readonly IDictionary<int, int> dvbtFreqInMhzByTransponder = new Dictionary<int, int>();
private readonly IDictionary<int, string> dvbcChannels = new ConcurrentDictionary<int, string>();
public static readonly LookupData Instance = new LookupData();
@@ -28,8 +28,8 @@ namespace ChanSort.Api
}
#endregion
#region GetTransponderNumber(), GetTransponderFrequency()
public int GetTransponderNumber(int frequencyInMhz)
#region GetAstraTransponder(), GetAstraFrequency()
public int GetAstraTransponder(int frequencyInMhz)
{
int number;
bool found = this.transponderNrByFreqInMhz.TryGetValue(frequencyInMhz, out number) ||
@@ -40,7 +40,7 @@ namespace ChanSort.Api
return found ? number : 0;
}
public int GetTransponderFrequency(int transponderNr)
public int GetAstraFrequency(int transponderNr)
{
return this.transponderNrByFreqInMhz.TryGet(transponderNr);
}
@@ -59,12 +59,10 @@ namespace ChanSort.Api
public void LoadDataFromCsvFile()
{
this.networks.Clear();
this.transponderFreqInMhzByNr.Clear();
this.transponderNrByFreqInMhz.Clear();
this.serviceTypeDescriptions.Clear();
this.dvbtFreqInMhzByTransponder.Clear();
string file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lookup.csv");
string file = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "lookup.csv");
if (!File.Exists(file))
return;
using (var reader = new StreamReader(file, System.Text.Encoding.UTF8))
@@ -78,8 +76,8 @@ namespace ChanSort.Api
switch (fields[0].ToLower())
{
case "onid": this.ParseNetwork(fields); break;
case "dvbt": this.ParseDvbtTransponder(fields); break;
case "transp": this.ParseTransponder(fields); break;
case "dvbc": this.ParseDvbcChannel(fields); break;
case "servicetype": this.ParseServiceType(fields); break;
}
}
@@ -98,14 +96,6 @@ namespace ChanSort.Api
private void AddTransponderMapping(int transponderNr, int frequencyInMhz)
{
this.transponderNrByFreqInMhz[frequencyInMhz] = transponderNr;
this.transponderFreqInMhzByNr[transponderNr] = frequencyInMhz;
}
#endregion
#region AddDvbtTransponderMapping()
private void AddDvbtTransponderMapping(int transponderNr, int frequencyInMhz)
{
this.dvbtFreqInMhzByTransponder[transponderNr] = frequencyInMhz;
}
#endregion
@@ -164,17 +154,16 @@ namespace ChanSort.Api
}
#endregion
#region ParseTransponder()
private void ParseDvbtTransponder(IList<string> fields)
#region ParseDvbcChannel()
private void ParseDvbcChannel(IList<string> fields)
{
if (fields.Count < 3)
return;
int nr, freq;
int.TryParse(fields[1], out nr);
int.TryParse(fields[2], out freq);
if (nr == 0 || freq == 0)
int freq;
int.TryParse(fields[1], out freq);
if (freq == 0)
return;
this.AddDvbtTransponderMapping(nr, freq);
this.dvbcChannels[freq] = fields[2];
}
#endregion
@@ -208,24 +197,27 @@ namespace ChanSort.Api
#endregion
#region GetDvbtTransponder()
public int GetDvbtTransponder(decimal freq)
public int GetDvbtTransponder(decimal freqInMhz)
{
return (int)(freq - 106)/8;
return (int)(freqInMhz - 306)/8;
}
#endregion
#region GetDvbtFrequency()
public decimal GetDvbtFrequeny(int channelTransponder)
{
return channelTransponder * 8 + 306;
}
#endregion
#region GetDvbtFrequencyForTransponder()
public decimal GetDvbtFrequenyForTransponder(int transponder)
public int GetDvbcTransponder(decimal freqInMhz)
{
return transponder * 8 + 106;
return GetDvbtTransponder(freqInMhz) + 25; // Samsung handles it like this
}
#endregion
#region GetDvbtFrequencyForChannel()
public decimal GetDvbtFrequenyForChannel(int channel)
public string GetDvbcChannelName(decimal freqInMhz)
{
return channel * 8 + 306;
return dvbcChannels.TryGet((int)(freqInMhz * 1000)) ?? "";
}
#endregion
}
}

View File

@@ -26,7 +26,7 @@ namespace ChanSort.Loader.LG
this.FreqInMhz = (data.GetDword(_FrequencyLong)+10) / 1000;
// ReSharper restore PossibleLossOfFraction
if (this.FreqInMhz == 0)
this.FreqInMhz = LookupData.Instance.GetDvbtFrequenyForChannel(channel);
this.FreqInMhz = LookupData.Instance.GetDvbtFrequeny(channel);
}
}
}

View File

@@ -106,7 +106,9 @@ namespace ChanSort.Loader.Panasonic
{
freq /= 1000;
this.FreqInMhz = freq;
this.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(freq).ToString();
this.ChannelOrTransponder = (this.SignalSource & SignalSource.Antenna) != 0 ?
LookupData.Instance.GetDvbtTransponder(freq).ToString() :
LookupData.Instance.GetDvbcTransponder(freq).ToString();
this.Satellite = (this.SignalSource & SignalSource.Antenna) != 0 ? "DVB-T" : "DVB-C";
}

View File

@@ -21,9 +21,9 @@ namespace ChanSort.Loader.Samsung
int transp = data.GetByte(_ChannelOrTransponder);
decimal freq = transpFreq.TryGet(transp);
if (freq == 0)
freq = transp*8 + 106; // (106 = DVB-C; DVB-T=306?)
freq = LookupData.Instance.GetDvbtFrequeny(transp); // transp*8 + 106); // (106 = DVB-C; DVB-T=306?)
this.ChannelOrTransponder = LookupData.Instance.GetDvbtTransponder(freq).ToString();
this.ChannelOrTransponder = transp.ToString();
this.FreqInMhz = freq;
}
}

View File

@@ -2,53 +2,61 @@
using System.Data.SQLite;
using ChanSort.Api;
namespace ChanSort.Loader.Toshiba
namespace ChanSort.Loader.SamsungJ
{
internal class DbChannel : ChannelInfo
{
internal Dictionary<int,int> OriginalFavIndex = new Dictionary<int, int>();
#region ctor()
internal DbChannel(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Dictionary<long, string> providers)
internal DbChannel(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Dictionary<long, string> providers, Satellite sat, Transponder tp)
{
var chType = r.GetInt32(field["chType"]);
if (chType == 7)
this.SignalSource = SignalSource.DvbS;
else if (chType == 4)
this.SignalSource = SignalSource.DvbC;
this.SignalSource = DbSerializer.ChTypeToSignalSource(chType);
this.RecordIndex = r.GetInt64(field["SRV.srvId"]);
this.OldProgramNr = r.GetInt32(field["major"]);
this.FreqInMhz = (decimal)r.GetInt32(field["freq"]) / 1000;
this.ChannelOrTransponder =
(this.SignalSource & SignalSource.Cable) != 0 ? LookupData.Instance.GetDvbtTransponder(this.FreqInMhz).ToString() :
(this.SignalSource & SignalSource.Sat) != 0 ? LookupData.Instance.GetTransponderNumber((int)this.FreqInMhz).ToString() :
(this.SignalSource & SignalSource.DvbT) == SignalSource.DvbT ? LookupData.Instance.GetDvbtTransponder(this.FreqInMhz).ToString() :
(this.SignalSource & SignalSource.DvbC) == SignalSource.DvbC ? LookupData.Instance.GetDvbcTransponder(this.FreqInMhz).ToString() :
(this.SignalSource & SignalSource.Sat) == SignalSource.DvbS ? LookupData.Instance.GetAstraTransponder((int)this.FreqInMhz).ToString() :
"";
this.Name = DbSerializer.ReadUtf16(r, 2);
this.Name = DbSerializer.ReadUtf16(r, 6);
this.Hidden = r.GetBoolean(field["hidden"]);
this.Encrypted = r.GetBoolean(field["scrambled"]);
this.Lock = r.GetBoolean(field["lockMode"]);
this.Skip = !r.GetBoolean(field["numSel"]);
//if (isAnalog)
// this.ReadAnalogData(r, field);
//else
if (sat != null)
{
this.Satellite = sat.Name;
this.SatPosition = sat.OrbitalPosition;
}
if (tp != null)
{
this.Transponder = tp;
this.SymbolRate = tp.SymbolRate;
}
if ((this.SignalSource & SignalSource.Digital) != 0)
this.ReadDvbData(r, field, dataRoot, providers);
else
this.ReadAnalogData(r, field);
}
#endregion
#region ReadAnalogData()
private void ReadAnalogData(SQLiteDataReader r, IDictionary<string, int> field)
{
this.Name = r.GetString(field["channel_label"]);
this.FreqInMhz = (decimal)r.GetInt32(field["frequency"]) / 1000000;
}
#endregion
#region ReadDvbData()
protected void ReadDvbData(SQLiteDataReader r, IDictionary<string, int> field, DataRoot dataRoot, Dictionary<long, string> providers)
{
this.ShortName = DbSerializer.ReadUtf16(r, 3);
this.ShortName = DbSerializer.ReadUtf16(r, 16);
this.RecordOrder = r.GetInt32(field["major"]);
int serviceType = r.GetInt32(field["srvType"]);
this.ServiceType = serviceType;
@@ -61,6 +69,7 @@ namespace ChanSort.Loader.Toshiba
this.Provider = providers.TryGet(r.GetInt64(field["provId"]));
if ((this.SignalSource & SignalSource.Sat) != 0)
{
//int satId = r.GetInt32(field["sat_id"]);
//var sat = dataRoot.Satellites.TryGet(satId);
//if (sat != null)

View File

@@ -8,15 +8,16 @@ using System.Windows.Forms;
using ChanSort.Api;
using ICSharpCode.SharpZipLib.Zip;
namespace ChanSort.Loader.Toshiba
namespace ChanSort.Loader.SamsungJ
{
class DbSerializer : SerializerBase
{
private readonly Dictionary<long, DbChannel> channelById = new Dictionary<long, DbChannel>();
private readonly Dictionary<ChannelList, string> dbPathByChannelList = new Dictionary<ChannelList, string>();
private string tempDir;
private Dictionary<int, Transponder> transponderByFreq;
private enum FileType { Unknown, SatDb, ChannelDb }
private enum FileType { Unknown, SatDb, ChannelDbDvb, ChannelDbAnalog }
#region ctor()
public DbSerializer(string inputFile) : base(inputFile)
@@ -37,6 +38,19 @@ namespace ChanSort.Loader.Toshiba
public override void Load()
{
this.UnzipDataFile();
if (File.Exists(tempDir + "\\sat"))
{
try
{
using (var conn = new SQLiteConnection("Data Source=" + tempDir + "\\sat"))
{
conn.Open();
this.ReadSatDatabase(conn);
}
}
catch { }
}
foreach (var filePath in Directory.GetFiles(tempDir, "*."))
{
try
@@ -53,11 +67,12 @@ namespace ChanSort.Loader.Toshiba
switch (type)
{
case FileType.SatDb:
//ReadSatDatabase(conn);
case FileType.SatDb: break;
case FileType.ChannelDbAnalog:
ReadChannelDatabase(conn, filePath, false);
break;
case FileType.ChannelDb:
ReadChannelDatabase(conn, filePath);
case FileType.ChannelDbDvb:
ReadChannelDatabase(conn, filePath, true);
break;
}
}
@@ -131,8 +146,12 @@ namespace ChanSort.Loader.Toshiba
return FileType.SatDb;
cmd.CommandText = "select count(1) from sqlite_master where type='table' and name in ('CHNL','SRV','SRV_DVB')";
if ((long) cmd.ExecuteScalar() == 3)
return FileType.ChannelDb;
if ((long)cmd.ExecuteScalar() == 3)
return FileType.ChannelDbDvb;
cmd.CommandText = "select count(1) from sqlite_master where type='table' and name in ('CHNL','SRV','SRV_ANL')";
if ((long)cmd.ExecuteScalar() == 3)
return FileType.ChannelDbAnalog;
return FileType.Unknown;
}
@@ -153,7 +172,7 @@ namespace ChanSort.Loader.Toshiba
#region ReadSatellites()
private void ReadSatellites(SQLiteCommand cmd)
{
cmd.CommandText = "select distinct satId, satName, satPos, satDir from SAT";
cmd.CommandText = "select distinct satId, cast(satName as blob), satPos, satDir from SAT";
using (var r = cmd.ExecuteReader())
{
while (r.Read())
@@ -161,7 +180,7 @@ namespace ChanSort.Loader.Toshiba
Satellite sat = new Satellite(r.GetInt32(0));
int pos = Math.Abs(r.GetInt32(2));
sat.OrbitalPosition = string.Format("{0}.{1}{2}", pos / 10, pos % 10, r.GetInt32(3) == 1 ? "E" : "W");
sat.Name = r.GetString(1) + " " + sat.OrbitalPosition;
sat.Name = ReadUtf16(r, 1);
this.DataRoot.AddSatellite(sat);
}
}
@@ -186,7 +205,7 @@ namespace ChanSort.Loader.Toshiba
tp.Number = r.GetInt32(4);
tp.Polarity = r.GetInt32(2) == 0 ? 'H' : 'V';
tp.Satellite = this.DataRoot.Satellites.TryGet(satId);
tp.SymbolRate = r.GetInt32(3) / 1000;
tp.SymbolRate = r.GetInt32(3);
this.DataRoot.AddTransponder(tp.Satellite, tp);
}
}
@@ -195,15 +214,14 @@ namespace ChanSort.Loader.Toshiba
#region ReadChannelDatabase()
private void ReadChannelDatabase(SQLiteConnection conn, string dbPath)
private void ReadChannelDatabase(SQLiteConnection conn, string dbPath, bool digital)
{
this.channelById.Clear();
using (var cmd = conn.CreateCommand())
{
this.RepairCorruptedDatabaseImage(cmd);
var providers = this.ReadProviders(cmd);
//this.ReadAnalogChannels(cmd);
var channelList = this.ReadDtvChannels(cmd, dbPath, providers);
var providers = digital ? this.ReadProviders(cmd) : null;
var channelList = this.ReadChannels(cmd, dbPath, providers, digital);
this.ReadFavorites(cmd);
this.dbPathByChannelList.Add(channelList, dbPath);
}
@@ -230,43 +248,23 @@ namespace ChanSort.Loader.Toshiba
}
#endregion
#region ReadAnalogChannels()
private void ReadAnalogChannels(SQLiteCommand cmd)
#region ReadChannels()
private ChannelList ReadChannels(SQLiteCommand cmd, string dbPath, Dictionary<long, string> providers, bool digital)
{
//string[] fieldNames = {"channel_handle", "channel_number", "list_bits", "channel_label", "frequency"};
//var sql = this.GetQuery("EuroATVChanList", fieldNames);
//var fields = this.GetFieldMap(fieldNames);
//cmd.CommandText = sql;
//using (var r = cmd.ExecuteReader())
//{
// while (r.Read())
// {
// ChannelInfo channel = new DbChannel(SignalSource.Analog, r, fields, this.DataRoot);
// if (!channel.IsDeleted)
// this.DataRoot.AddChannel(this.atvChannels, channel);
// }
//}
}
#endregion
var signalSource = DetectSignalSource(cmd, digital);
var sat = (signalSource & SignalSource.Sat) == 0 ? null : this.DetectSatellite(cmd);
#region ReadDtvChannels()
private ChannelList ReadDtvChannels(SQLiteCommand cmd, string dbPath, Dictionary<long, string> providers)
{
string name = Path.GetFileName(dbPath);
ChannelList channelList = new ChannelList(SignalSource.Digital, name);
this.ReadDigitalChannels(cmd, "SRV_DVB", channelList, providers);
this.DataRoot.AddChannelList(channelList);
return channelList;
}
#endregion
ChannelList channelList = new ChannelList(signalSource, name);
string table = digital ? "SRV_DVB" : "SRV_ANL";
List<string> fieldNames = new List<string> {
"chType", "chNum", "freq", // CHNL
"SRV.srvId", "major", "progNum", "cast(srvName as blob)", "srvType", "hidden", "scrambled", "lockMode", "numSel", // SRV
};
if (digital)
fieldNames.AddRange(new[] { "onid", "tsid", "vidPid", "provId", "cast(shrtSrvName as blob)" }); // SRV_DVB
#region ReadDigitalChannels()
private void ReadDigitalChannels(SQLiteCommand cmd, string table, ChannelList channelList, Dictionary<long, string> providers)
{
string[] fieldNames = { "SRV.srvId", "major", "cast(srvName as blob)", "cast(shrtSrvName as blob)", "chType", "chNum",
"srvType", "onid", "tsid", "vidPid", "progNum", "freq", "hidden", "scrambled", "lockMode", "numSel", "provId" };
var sql = this.GetQuery(table, fieldNames);
var sql = this.BuildQuery(table, fieldNames);
var fields = this.GetFieldMap(fieldNames);
cmd.CommandText = sql;
@@ -274,7 +272,8 @@ namespace ChanSort.Loader.Toshiba
{
while (r.Read())
{
var channel = new DbChannel(r, fields, this.DataRoot, providers);
var tp = this.transponderByFreq != null ? this.transponderByFreq.TryGet(r.GetInt32(2)) : null;
var channel = new DbChannel(r, fields, this.DataRoot, providers, sat, tp);
if (!channel.IsDeleted)
{
this.DataRoot.AddChannel(channelList, channel);
@@ -282,14 +281,93 @@ namespace ChanSort.Loader.Toshiba
}
}
}
this.DataRoot.AddChannelList(channelList);
return channelList;
}
#endregion
#region GetQuery()
private string GetQuery(string table, string[] fieldNames)
#region DetectSignalSource()
private static SignalSource DetectSignalSource(SQLiteCommand cmd, bool digital)
{
var signalSource = digital ? SignalSource.Digital : SignalSource.Analog;
cmd.CommandText = "select distinct chType from CHNL";
using (var r = cmd.ExecuteReader())
{
if (r.Read())
{
var ss = ChTypeToSignalSource(r.GetInt32(0));
if (ss != 0)
signalSource = ss;
}
}
return signalSource | SignalSource.TvAndRadio;
}
#endregion
#region ChTypeToSignalSource()
internal static SignalSource ChTypeToSignalSource(int chType)
{
switch (chType)
{
case 1: return SignalSource.AnalogT;
case 2: return SignalSource.DvbT;
case 3: return SignalSource.AnalogC;
case 4: return SignalSource.DvbC;
case 7: return SignalSource.DvbS;
default: return 0;
}
}
#endregion
#region DetectSatellite()
/// <summary>
/// I haven't found a direct way to link a dvbs database file or its channels to a satId.
/// This workaround compares the transponder frequencies in the channel list with the transponder frequencies of each satellite to find a match.
/// </summary>
private Satellite DetectSatellite(SQLiteCommand cmd)
{
List<int> tpFreq = new List<int>();
cmd.CommandText = "select freq from CHNL where chType=7";
using (var r = cmd.ExecuteReader())
{
while (r.Read())
tpFreq.Add(r.GetInt32(0));
}
this.transponderByFreq = null;
foreach (var sat in DataRoot.Satellites.Values)
{
Dictionary<int, Transponder> satFreq = new Dictionary<int, Transponder>();
foreach (var tp in sat.Transponder.Values)
satFreq.Add((int) (tp.FrequencyInMhz*1000), tp);
int mismatch = 0;
foreach (int freq in tpFreq)
{
if (satFreq.ContainsKey(freq) || satFreq.ContainsKey(freq - 1000) || satFreq.ContainsKey(freq + 1000))
continue;
++mismatch;
}
if (mismatch < 10)
{
this.transponderByFreq = satFreq;
return sat;
}
}
return null;
}
#endregion
#region BuildQuery()
private string BuildQuery(string table, IList<string> fieldNames)
{
string sql = "select ";
for (int i = 0; i < fieldNames.Length; i++)
for (int i = 0; i < fieldNames.Count; i++)
{
if (i > 0)
sql += ",";
@@ -301,10 +379,10 @@ namespace ChanSort.Loader.Toshiba
#endregion
#region GetFieldMap()
private IDictionary<string, int> GetFieldMap(string[] fieldNames)
private IDictionary<string, int> GetFieldMap(IList<string> fieldNames)
{
Dictionary<string, int> field = new Dictionary<string, int>();
for (int i = 0; i < fieldNames.Length; i++)
for (int i = 0; i < fieldNames.Count; i++)
field[fieldNames[i]] = i;
return field;
}

View File

@@ -1,6 +1,6 @@
using ChanSort.Api;
namespace ChanSort.Loader.Toshiba
namespace ChanSort.Loader.SamsungJ
{
public class DbSerializerPlugin : ISerializerPlugin
{

View File

@@ -112,23 +112,23 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="DevExpress.XtraEditors.v14.2" name="DevExpress.XtraEditors.v14.2, Version=14.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<data name="lblWebsite.AutoSizeMode" type="DevExpress.XtraEditors.LabelAutoSizeMode, DevExpress.XtraEditors.v14.2">
<value>Vertical</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="lblWebsite.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 92</value>
</data>
<data name="lblWebsite.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 13</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="lblWebsite.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
@@ -147,12 +147,12 @@
<data name="&gt;&gt;lblWebsite.ZOrder" xml:space="preserve">
<value>9</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="lnkDownload.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Left, Right</value>
</data>
<data name="lnkDownload.EditValue" xml:space="preserve">
<value>http://sourceforge.net/p/chansort/</value>
<value>http://github.com/PredatH0r/ChanSort</value>
</data>
<data name="lnkDownload.Location" type="System.Drawing.Point, System.Drawing">
<value>108, 90</value>
@@ -161,7 +161,7 @@
<value>Transparent</value>
</data>
<data name="lnkDownload.Size" type="System.Drawing.Size, System.Drawing">
<value>338, 18</value>
<value>205, 18</value>
</data>
<data name="lnkDownload.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
@@ -409,7 +409,7 @@
<data name="&gt;&gt;txtAuthor.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">

View File

@@ -25,7 +25,7 @@ namespace ChanSort.Ui
{
public partial class MainForm : XtraForm
{
public const string AppVersion = "v2015-04-18";
public const string AppVersion = "v2015-05-06";
private const int MaxMruEntries = 10;

View File

@@ -0,0 +1 @@
DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v14.2, Version=14.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

View File

@@ -1,6 +1,11 @@
ChanSort Change Log
===================
2015-05-06
- added support for Samsung J-Series DVB-T and analog channel lists
- fixed reference lists with Samsung J-Series
- web site and source code moved to http://github.com/PredatH0r/ChanSort
2015-04-18
- added support for Samsung J-Series DVB-C and DVB-S channel lists
(analog channels and DVB-T are not supported yet)