- merged projects so that there is one loader for each manufacturer

This commit is contained in:
Horst Beham
2021-01-23 14:22:18 +01:00
parent 4abe7a0b35
commit 086d4683fd
288 changed files with 466 additions and 10654 deletions

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E6279FF8-362A-41E6-AC0D-D0861D43F01C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ChanSort.Loader.SatcoDX</RootNamespace>
<AssemblyName>ChanSort.Loader.SatcoDX</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>..\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Channel.cs" />
<Compile Include="Serializer.cs" />
<Compile Include="SatcoDxPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ChanSort.Api\ChanSort.Api.csproj">
<Project>{dccffa08-472b-4d17-bb90-8f513fc01392}</Project>
<Name>ChanSort.Api</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,87 @@
using System;
using System.Globalization;
using System.IO;
using ChanSort.Api;
namespace ChanSort.Loader.SatcoDX
{
internal class Channel : ChannelInfo
{
public int FileOffset { get; }
public int Length { get; }
#region ctor()
internal Channel(int pos, string line, byte[] data, int start, int length, DvbStringDecoder decoder)
{
this.FileOffset = start;
this.Length = length;
this.RecordIndex = pos;
this.RecordOrder = this.OldProgramNr = pos + 1;
if (!line.StartsWith("SATCODX"))
throw new FileLoadException("Only SAT channels are supported");
if (line.Length < 106)
throw new FileLoadException("Unrecognized channel format");
// 10-27: satellite name
this.Satellite = line.Substring(10, 18);
// 28: channel type
var type = line[28];
this.SignalSource = SignalSource.Digital | SignalSource.Sat | (type == 'T' ? SignalSource.Tv : type == 'R' ? SignalSource.Radio : 0);
this.ServiceTypeName = type == 'T' ? "TV" : type == 'R' ? "Radio" : type == 'D' ? "Data" : "Other";
// 29-32: broadcast system
// 33-41: frequency in kHz
if (int.TryParse(line.Substring(33, 9), out var khz))
this.FreqInMhz = (decimal)khz / 1000;
// 42: polarity
this.Polarity = line[42] == '1' ? 'H' : 'V';
// 43-50 + (115-126 or 115-131): channel name
byte[] nameBytes = new byte[8+17];
var nameLen2 = Math.Min(length - 115, 17); // version 103 has 12 extra bytes for channel name, version 105 has 17
Array.Copy(data, start + 43, nameBytes, 0, 8);
Array.Copy(data, start + 115, nameBytes, 8, nameLen2);
decoder.GetChannelNames(nameBytes,0, nameBytes.Length, out var longName, out var shortName);
this.Name = longName.TrimEnd();
this.ShortName = shortName.TrimEnd();
// 51-54: sat position
var spos = line.Substring(51, 4).TrimStart('0');
this.SatPosition = spos.Substring(0, spos.Length - 1) + CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator + spos.Substring(spos.Length - 1);
// 69-73: symbol rate
if (int.TryParse(line.Substring(69, 5), out var symrate))
this.SymbolRate = symrate;
// 74: FEC 0=-, 1=1/2, 2=2/3, 3=3/4, 5=5/6, 7=7/8
// 75-78: vpid or ____
// 79-82: apid or ____
// 83-86: pcrpid or ____
// 87-91: sid
if (int.TryParse(line.Substring(87, 5), out var sid))
this.ServiceId = sid;
// 92-96: nid / onid
if (int.TryParse(line.Substring(92, 5), out var onid))
this.OriginalNetworkId = onid;
// 97-101: tsid
if (int.TryParse(line.Substring(97, 5), out var tsid))
this.TransportStreamId = tsid;
// 102-104: language
// 106-107: country code
// 108-110: language code
// 111-114: crypto code
}
#endregion
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ChanSort.Loader.SilvaSchneider")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChanSort.Loader.SilvaSchneider")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("FAEFA732-0096-45AE-97ED-DBE40764DA15")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,16 @@
using ChanSort.Api;
namespace ChanSort.Loader.SatcoDX
{
public class SatcoDxPlugin : ISerializerPlugin
{
public string DllName { get; set; }
public string PluginName => "ITT/Medion/Nabo/ok./Peaq/Schaub-Lorenz/Silva-Schneider/Telefunken";
public string FileFilter => "*.sdx";
public SerializerBase CreateSerializer(string inputFile)
{
return new Serializer(inputFile);
}
}
}

View File

@@ -0,0 +1,105 @@
using System;
using System.IO;
using System.Text;
using ChanSort.Api;
namespace ChanSort.Loader.SatcoDX
{
internal class Serializer : SerializerBase
{
private readonly ChannelList allChannels = new ChannelList(0, "All");
private byte[] content;
#region ctor()
public Serializer(string inputFile) : base(inputFile)
{
this.Features.ChannelNameEdit = ChannelNameEditMode.None;
this.Features.DeleteMode = DeleteMode.Physically;
this.Features.CanSkipChannels = false;
this.Features.CanLockChannels = false;
this.Features.CanHideChannels = false;
this.Features.SortedFavorites = false;
this.Features.SupportedFavorites = 0;
this.DataRoot.AddChannelList(this.allChannels);
// hide columns for fields that don't exist in Silva-Schneider channel list
foreach (var list in this.DataRoot.ChannelLists)
{
list.VisibleColumnFieldNames.Remove("PcrPid");
list.VisibleColumnFieldNames.Remove("VideoPid");
list.VisibleColumnFieldNames.Remove("AudioPid");
list.VisibleColumnFieldNames.Remove("Lock");
list.VisibleColumnFieldNames.Remove("Skip");
list.VisibleColumnFieldNames.Remove("Hidden");
list.VisibleColumnFieldNames.Remove("Encrypted");
list.VisibleColumnFieldNames.Remove("Favorites");
list.VisibleColumnFieldNames.Remove("ServiceType");
list.VisibleColumnFieldNames.Add("ServiceTypeName");
}
}
#endregion
#region Load()
public override void Load()
{
var decoder = new DvbStringDecoder(this.DefaultEncoding);
var pos = 0;
content = File.ReadAllBytes(this.FileName);
int prevPos = 0, nextPos;
while (prevPos < content.Length && (nextPos = Array.FindIndex(content, prevPos, ch => ch == (byte)'\n')) >= 0)
{
if (nextPos - prevPos == 0)
continue;
string line = Encoding.ASCII.GetString(content, prevPos, nextPos-prevPos);
ChannelInfo channel = new Channel(pos, line, content, prevPos, nextPos-prevPos, decoder);
this.DataRoot.AddChannel(this.allChannels, channel);
pos++;
prevPos = nextPos + 1;
}
}
#endregion
#region Save()
public override void Save(string tvOutputFile)
{
if (tvOutputFile != this.FileName)
{
File.Copy(this.FileName, tvOutputFile);
this.FileName = tvOutputFile;
}
using (var file = new FileStream(tvOutputFile, FileMode.Create))
{
foreach (var channel in this.allChannels.GetChannelsByNewOrder())
{
// when a reference list was applied, the list may contain proxy entries for deleted channels, which must be ignored
if (channel.IsProxy || channel.IsDeleted)
continue;
if (channel is Channel realChannel)
file.Write(this.content, realChannel.FileOffset, realChannel.Length + 1);
}
}
}
#endregion
#region GetFileInformation()
public override string GetFileInformation()
{
var sb = new StringBuilder();
sb.Append(base.GetFileInformation());
return sb.ToString();
}
#endregion
}
}