Neues Trikolor sample.

This commit is contained in:
feyris-tan 2025-09-04 23:00:51 +02:00
parent 8e57830409
commit cee4a4ad44
16 changed files with 351 additions and 78 deletions

View File

@ -982,7 +982,14 @@ namespace SDL2Demo.Jobs
public void DsmCcModuleComplete(int elementaryPid, ushort moduleModuleId, byte moduleModuleVersion)
{
throw new NotImplementedException();
DsmCcModuleIdentifier id = new DsmCcModuleIdentifier();
id.pid = elementaryPid;
id.moduleId = moduleModuleId;
id.moduleVersion = moduleModuleVersion;
lock (dsmCcDisplay)
{
dsmCcDisplay.Remove(id);
}
}
@ -1436,7 +1443,7 @@ namespace SDL2Demo.Jobs
public void NotifyScte35(ushort programNumber, SpliceInsert spliceInsert)
{
throw new NotImplementedException();
}
public void NotifyScte35(ushort programNumber, TimeSignal spliceInsert)
@ -1446,7 +1453,7 @@ namespace SDL2Demo.Jobs
public void SetMemorySaverMode(bool saveMemory)
{
throw new NotImplementedException();
}
public void NotifyDocsisCarrier(DocsisEnvironment docsisEnvironment)

View File

@ -8,6 +8,7 @@ using skyscraper5.DsmCc.Message;
using skyscraper5.Dvb.DataBroadcasting.DataCarouselDescriptors;
using skyscraper5.Mhp.Descriptors;
using skyscraper5.Mpeg2;
using skyscraper5.Mpeg2.Descriptors;
using skyscraper5.Mpeg2.Psi.Model;
using skyscraper5.Skyscraper.IO;
@ -98,6 +99,9 @@ namespace skyscraper5.Dvb.DataBroadcasting.Biop
case nameof(LabelDescriptor):
this.Label = ((LabelDescriptor)tsDescriptor).Label;
break;
case nameof(UserDefinedDescriptor):
//TODO: Check private data specifiers and friends
break;
default:
throw new NotImplementedException(name);
}

View File

@ -46,6 +46,11 @@ namespace skyscraper8.Experimentals.NdsSsu
_pid = pid;
}
protected override void HandleTable(byte tableId, int sourcePid, byte[] payload)
{
_handler.OnNdsSsuError(_pid, NdsSsuError.SectionSyntaxIndicatorMissing);
}
protected override void HandleTable(byte tableId, int sourcePid, byte sectionNumber, byte lastSectionNumber, ushort tableIdExtension,
byte[] payload)
{
@ -55,7 +60,7 @@ namespace skyscraper8.Experimentals.NdsSsu
return;
}
if (payload[0] != 0x01)
if (payload[0] >= 0x02)
{
_handler.OnNdsSsuError(_pid, NdsSsuError.InvalidMagic);
return;
@ -84,11 +89,11 @@ namespace skyscraper8.Experimentals.NdsSsu
if (tidExtensions[tableIdExtension])
{
_handler.OnNdsSsuProgress(_pid,tableIdExtension, sectionNumber, lastSectionNumber, payload[3]);
_handler.OnNdsSsuProgress(_pid,tableIdExtension, sectionNumber, lastSectionNumber, false);
}
else
{
_handler.OnNdsFileAccouncement(_pid,tableIdExtension);
_handler.OnNdsSsuFileAnnouncement(_pid,tableIdExtension);
tidExtensions[tableIdExtension] = true;
}
}
@ -104,14 +109,43 @@ namespace skyscraper8.Experimentals.NdsSsu
throw new NotImplementedException();
}
public void OnNdsSsuProgress(int pid, ushort tableIdExtension, byte sectionNumber, byte lastSectionNumber, byte b)
private int maxNumFiles;
private int numFiles;
public void OnNdsSsuFileAnnouncement(int pid, ushort tableIdExtension)
{
if (pid == 0x157e)
ToString();
if (maxNumFiles == 0)
{
maxNumFiles = 2;
return;
}
numFiles++;
if (numFiles == maxNumFiles)
{
maxNumFiles *= 2;
Score--;
}
}
public void OnNdsSsuFileComplete(int pid, ushort tableIdExtension, NdsSsuDataMap dataMap)
{
throw new NotImplementedException();
}
public void OnNdsSsuProgress(int pid, ushort tableIdExtension, int blocksDone, int blocksTotal, bool theresMore)
{
if (pid == 0x157e)
ToString();
Score++;
}
public void OnNdsFileAccouncement(int pid, ushort tableIdExtension)
public bool TestNdsSsuFileExists(int pid, ushort tableIdExtension)
{
Score--;
throw new NotImplementedException();
}
}
}

View File

@ -9,13 +9,16 @@ namespace skyscraper8.Experimentals.NdsSsu
interface NdsSsuHandler
{
void OnNdsSsuError(int pid, NdsSsuError error);
void OnNdsSsuProgress(int pid, ushort tableIdExtension, byte sectionNumber, byte lastSectionNumber, byte b);
void OnNdsFileAccouncement(int pid, ushort tableIdExtension);
void OnNdsSsuFileAnnouncement(int pid, ushort tableIdExtension);
void OnNdsSsuFileComplete(int pid, ushort tableIdExtension, NdsSsuDataMap dataMap);
void OnNdsSsuProgress(int pid, ushort tableIdExtension, int blocksDone, int blocksTotal, bool theresMore);
bool TestNdsSsuFileExists(int pid, ushort tableIdExtension);
}
public enum NdsSsuError
{
WrongTable,
InvalidMagic
InvalidMagic,
SectionSyntaxIndicatorMissing
}
}

View File

@ -1,6 +1,8 @@
using skyscraper8.Mpeg2.Psi;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
@ -19,6 +21,12 @@ namespace skyscraper8.Experimentals.NdsSsu
_pid = pid;
}
private int error;
protected override void HandleTable(byte tableId, int sourcePid, byte[] payload)
{
error++;
}
protected override void HandleTable(byte tableId, int sourcePid, byte sectionNumber, byte lastSectionNumber, ushort tableIdExtension, byte[] payload)
{
if (tableId != 0x9e)
@ -51,90 +59,231 @@ namespace skyscraper8.Experimentals.NdsSsu
return;
}
if (payload[3] > 0x10)
if (payload[3] > 0x20)
{
_handler.OnNdsSsuError(_pid, NdsSsuError.InvalidMagic);
return;
}
if (dataMaps == null)
dataMaps = new DataMap[ushort.MaxValue];
dataMaps = new NdsSsuDataMap[ushort.MaxValue];
if (dataMaps[tableIdExtension] == null)
{
dataMaps[tableIdExtension] = new DataMap();
_handler.OnNdsFileAccouncement(_pid, tableIdExtension);
dataMaps[tableIdExtension] = new NdsSsuDataMap();
if (!_handler.TestNdsSsuFileExists(_pid, tableIdExtension))
{
_handler.OnNdsSsuFileAnnouncement(_pid, tableIdExtension);
}
else
{
return;
}
}
if (dataMaps[tableIdExtension].WasProcessed)
{
return;
}
if (dataMaps[tableIdExtension].WasAlreadyPushed(payload, sectionNumber, lastSectionNumber))
{
throw new NotImplementedException("the file is completed!");
if (dataMaps[tableIdExtension].IsComplete)
{
_handler.OnNdsSsuFileComplete(_pid, tableIdExtension, dataMaps[tableIdExtension]);
dataMaps[tableIdExtension].SetSucessfullyProcessed();
}
return;
}
dataMaps[tableIdExtension].PushPacket(payload,sectionNumber,lastSectionNumber);
Tuple<int, int, bool> completionStatus = dataMaps[tableIdExtension].GetCompletionStatus();
_handler.OnNdsSsuProgress(_pid, tableIdExtension, completionStatus.Item1, completionStatus.Item2, completionStatus.Item3);
}
private DataMap[] dataMaps;
class DataMap
{
private NdsSsuDataMap[] dataMaps;
}
private Superblock[] superblocks;
public void PushPacket(byte[] payload,byte currentSection, byte lastSection)
public class NdsSsuDataMap : IDisposable
{
private Superblock[] superblocks;
public void PushPacket(byte[] payload, byte currentSection, byte lastSection)
{
byte maxNumSuperblocks = payload[3];
maxNumSuperblocks++;
if (superblocks == null)
superblocks = new Superblock[maxNumSuperblocks];
if (superblocks.Length < maxNumSuperblocks)
Array.Resize(ref superblocks, maxNumSuperblocks);
if (superblocks[payload[3]] == null)
{
byte maxNumSuperblocks = payload[3];
maxNumSuperblocks++;
if (superblocks == null)
superblocks = new Superblock[maxNumSuperblocks];
if (superblocks.Length < maxNumSuperblocks)
Array.Resize(ref superblocks, maxNumSuperblocks);
if (superblocks[payload[3]] == null)
{
superblocks[payload[3]] = new Superblock(lastSection);
}
superblocks[payload[3]].PushPacket(payload,currentSection,lastSection);
superblocks[payload[3]] = new Superblock(lastSection);
}
class Superblock
superblocks[payload[3]].PushPacket(payload, currentSection, lastSection);
}
class Superblock : IDisposable
{
private byte[][] blocks;
public Superblock(byte lastSection)
{
private byte[][] blocks;
public Superblock(byte lastSection)
{
int maxNumBlocks = lastSection;
maxNumBlocks++;
blocks = new byte[maxNumBlocks][];
}
int maxNumBlocks = lastSection;
maxNumBlocks++;
blocks = new byte[maxNumBlocks][];
}
public void PushPacket(byte[] payload, byte currentSection, byte lastSection)
{
int maxNumBlocks = lastSection;
maxNumBlocks++;
if (blocks.Length > maxNumBlocks)
Array.Resize(ref blocks, maxNumBlocks);
blocks[currentSection] = payload;
}
public void PushPacket(byte[] payload, byte currentSection, byte lastSection)
{
int maxNumBlocks = lastSection;
maxNumBlocks++;
if (blocks.Length > maxNumBlocks)
Array.Resize(ref blocks, maxNumBlocks);
blocks[currentSection] = payload;
}
public bool WasAlreadyPushed(byte currentSection)
{
byte maxNumBlocks = currentSection;
maxNumBlocks++;
public bool WasAlreadyPushed(byte currentSection)
{
byte maxNumBlocks = currentSection;
maxNumBlocks++;
if (blocks.Length < currentSection)
if (blocks.Length < currentSection)
return false;
return blocks[currentSection] != null;
}
public bool IsComplete
{
get
{
if (blocks == null)
return false;
return blocks[currentSection] != null;
for (int i = 0; i < blocks.Length; i++)
{
if (blocks[i] == null)
return false;
}
return true;
}
}
public bool WasAlreadyPushed(byte[] payload, byte sectionNumber, byte lastSectionNumber)
public int BlocksDone
{
get
{
int result = 0;
for (int i = 0; i < blocks.Length; i++)
{
if (blocks[i] != null)
result++;
}
return result;
}
}
public int BlocksTotal => blocks.Length;
public void WriteToStream(Stream fileStream)
{
for (int i = 0; i < blocks.Length; i++)
{
fileStream.Write(blocks[i], 4, blocks[i].Length - 4);
}
}
public void Dispose()
{
for (int i = 0; i < blocks.Length; i++)
{
blocks[i] = null;
}
}
}
public bool WasAlreadyPushed(byte[] payload, byte sectionNumber, byte lastSectionNumber)
{
if (superblocks == null)
return false;
byte maxNumSuperblocks = payload[3];
maxNumSuperblocks++;
if (superblocks.Length < maxNumSuperblocks)
return false;
if (superblocks[payload[3]] == null)
return false;
return superblocks[payload[3]].WasAlreadyPushed(sectionNumber);
}
public bool IsComplete
{
get
{
if (superblocks == null)
return false;
byte maxNumSuperblocks = payload[3];
maxNumSuperblocks++;
if (superblocks.Length < maxNumSuperblocks)
return false;
for (int i = 0; i < superblocks.Length; i++)
{
if (superblocks[i] == null)
return false;
if (!superblocks[i].IsComplete)
return false;
}
return superblocks[payload[3]].WasAlreadyPushed(sectionNumber);
return true;
}
}
public Tuple<int, int, bool> GetCompletionStatus()
{
int done = 0;
int total = 0;
bool theresMore = false;
for (int i = 0; i < this.superblocks.Length; i++)
{
if (superblocks[i] != null)
{
done += superblocks[i].BlocksDone;
total += superblocks[i].BlocksTotal;
}
else
{
theresMore = true;
}
}
return new Tuple<int, int, bool>(done, total, theresMore);
}
public bool WasProcessed { get; private set; }
public void SetSucessfullyProcessed()
{
WasProcessed = true;
}
public void WriteToStream(Stream fileStream)
{
for (int x = 0; x < superblocks.Length; x++)
{
superblocks[x].WriteToStream(fileStream);
}
}
public void Dispose()
{
for (int x = 0; x < superblocks.Length; x++)
{
superblocks[x].Dispose();
superblocks[x] = null;
}
}
}
}

View File

@ -120,6 +120,7 @@ namespace skyscraper8.Experimentals.OtvSsu
Score--;
}
public void OnOtvSsuFileAnnouncement(int pid, ushort tableIdExtension, uint fileId, uint unknown1, uint length)
{
Score--;

View File

@ -17,6 +17,12 @@ namespace skyscraper8.Experimentals.OtvSsu
_handler = handler;
}
private int errors;
protected override void HandleTable(byte tableId, int sourcePid, byte[] payload)
{
errors++;
}
private Dictionary<Coordinate, DataMap> _dataMaps;
protected override void HandleTable(byte tableId, int sourcePid, byte sectionNumber, byte lastSectionNumber, ushort tableIdExtension, byte[] payload)
{

View File

@ -2,7 +2,7 @@
"profiles": {
"skyscraper8": {
"commandName": "Project",
"commandLineArgs": "\"C:\\Temp\\bem-service-a01.ts\"",
"commandLineArgs": "\"C:\\Users\\Sascha Schiemann\\Downloads\\36E-12226L(1)\\36E-12226L.ts\"",
"remoteDebugEnabled": false
},
"Container (Dockerfile)": {

View File

@ -306,6 +306,12 @@ namespace skyscraper5.Skyscraper.Scraper
if (id == 0x09b5)
return "NDS Videoguard (?)";
if ((id >= 0x7700) && (id <= 0x7704))
return "Cifra";
if (id == 0x2710)
return "DRE-Crypt";
return "???";
}
}

View File

@ -587,7 +587,10 @@ namespace skyscraper5.Skyscraper.Scraper
//DvbContext.RegisterPacketProcessor(mappingStream.ElementaryPid, new PacketDumper(new FileInfo("subtitle.ts")));
break;
case StreamType.DvbMhp:
DvbContext.RegisterPacketProcessor(mappingStream.ElementaryPid,
//Test and make up component tags.
if (!mappingStream.ComponentTag.HasValue)
MakeUpComponentTags(result);
DvbContext.RegisterPacketProcessor(mappingStream.ElementaryPid,
new PsiDecoder(mappingStream.ElementaryPid,
new DataCarouselDecoder(mappingStream, result, DataCarouselIntention.NoIntention, this)));
break;
@ -2941,17 +2944,26 @@ namespace skyscraper5.Skyscraper.Scraper
public void OnNdsSsuError(int pid, NdsSsuError error)
{
throw new NotImplementedException();
}
public void OnNdsSsuProgress(int pid, ushort tableIdExtension, byte sectionNumber, byte lastSectionNumber, byte b)
{
throw new NotImplementedException();
}
public void OnNdsFileAccouncement(int pid, ushort tableIdExtension)
public void OnNdsSsuFileAnnouncement(int pid, ushort tableIdExtension)
{
LogEvent(SkyscraperContextEvent.NdsSsuFileAnnounced, String.Format("PID = 0x{1:X4}, Table ID Extension = {0}", tableIdExtension, pid));
}
public void OnNdsSsuFileComplete(int pid, ushort tableIdExtension, NdsSsuDataMap dataMap)
{
ObjectStorage.OnNdsSsuComplete(CurrentNetworkId, CurrentTransportStreamId, pid, tableIdExtension, dataMap);
}
public void OnNdsSsuProgress(int pid, ushort tableIdExtension, int blocksDone, int blocksTotal, bool theresMore)
{
LogEvent(SkyscraperContextEvent.NdsSsuProgress, String.Format("PID 0x{0:X4}, File ID {1}, Blocks: {2}/{3}{4}", pid, tableIdExtension, blocksDone, blocksTotal, theresMore ? "+" : ""));
}
public bool TestNdsSsuFileExists(int pid, ushort tableIdExtension)
{
return ObjectStorage.NdsSsuTestFile(CurrentNetworkId, CurrentTransportStreamId, pid, tableIdExtension);
}
}
}

View File

@ -84,6 +84,7 @@
FluteFileAnnouncement,
OtvSsuFileDetected,
OtvSsuComplete,
NdsSsuFileAnnounced
NdsSsuFileAnnounced,
NdsSsuProgress
}
}

View File

@ -35,6 +35,7 @@ using skyscraper5.src.Skyscraper.Scraper.Storage.InMemory;
using skyscraper5.Teletext;
using skyscraper8.DvbI;
using skyscraper8.DvbNip;
using skyscraper8.Experimentals.NdsSsu;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Ses;
using skyscraper8.Skyscraper.Drawing;
@ -1452,7 +1453,9 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem
public bool TestForSgtList(SgtList list)
{
throw new NotImplementedException();
string path = Path.Combine(rootDirectory.FullName, "Astra-SGT", list.ServiceListId.ToString() + ".json");
FileInfo fi = new FileInfo(path);
return fi.Exists;
}
public void InsertSgtList(SgtList list)
@ -1552,6 +1555,32 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.Filesystem
getStream.Dispose();
}
public void OnNdsSsuComplete(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension,
NdsSsuDataMap dataMap)
{
string cnid = currentNetworkId.HasValue ? currentNetworkId.Value.ToString() : "unknown";
string ctsid = currentTransportStreamId.HasValue ? currentTransportStreamId.Value.ToString() : "unknown";
string fname = tableIdExtension.ToString() + ".bin";
string path = Path.Combine(rootDirectory.FullName, "NDS-SSU", cnid, ctsid, pid.ToString(), fname);
FileInfo fi = new FileInfo(path);
fi.Directory.EnsureExists();
FileStream fileStream = fi.OpenWrite();
dataMap.WriteToStream(fileStream);
fileStream.Flush(true);
fileStream.Close();
dataMap.Dispose();
}
public bool NdsSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension)
{
string cnid = currentNetworkId.HasValue ? currentNetworkId.Value.ToString() : "unknown";
string ctsid = currentTransportStreamId.HasValue ? currentTransportStreamId.Value.ToString() : "unknown";
string fname = tableIdExtension.ToString() + ".bin";
string path = Path.Combine(rootDirectory.FullName, "NDS-SSU", cnid, ctsid, pid.ToString(), fname);
FileInfo fi = new FileInfo(path);
return fi.Exists;
}
class NipPds
{
public DateTime VersionUpdate;

View File

@ -669,7 +669,7 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
{
if (dsmCcBlacklist == null)
{
FileInfo fi = new FileInfo("dsmcc_blacklist.csv");
FileInfo fi = new FileInfo("dsmcc_fail_history.csv");
dsmCcBlacklist = new DsmCcModuleBlacklist(fi);
}
@ -1120,7 +1120,13 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory
public void FailDsmCcDownload(DatabaseKeyDsmCcModule key, double value)
{
throw new NotImplementedException();
if (dsmCcBlacklist == null)
{
FileInfo fi = new FileInfo("dsmcc_fail_history.csv");
dsmCcBlacklist = new DsmCcModuleBlacklist(fi);
}
dsmCcBlacklist.AddFailedModule(key.CurrentNetworkId, key.CurrentTransportStreamId, key.ElementaryPid, key.ModuleId, key.ModuleVersion, value);
}
public bool TestForTerminalBurstTimePlan(ushort interactiveNetworkId, uint groupId)

View File

@ -10,10 +10,10 @@ namespace skyscraper5.Skyscraper.Scraper.Storage.InMemory.Model
public DsmCcModuleBlacklist(FileInfo fi)
{
entries = new List<Tuple<int, int, int, ushort, byte>>();
if (!fi.Exists)
ListPath = fi;
if (!fi.Exists)
return;
ListPath = fi;
StreamReader streamReader = fi.OpenText();
while (!streamReader.EndOfStream)
{

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
using skyscraper5.Dvb.Descriptors;
using skyscraper8.DvbNip;
using skyscraper8.Experimentals.NdsSsu;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Skyscraper.Drawing;
@ -111,5 +112,16 @@ namespace skyscraper8.Skyscraper.Scraper.Storage
{
throw new NotImplementedException();
}
public void OnNdsSsuComplete(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension,
NdsSsuDataMap dataMap)
{
dataMap.Dispose();
}
public bool NdsSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension)
{
return true;
}
}
}

View File

@ -8,6 +8,7 @@ using skyscraper5.Dvb.DataBroadcasting.SkyscraperVfs;
using skyscraper5.Dvb.Descriptors;
using skyscraper5.Teletext;
using skyscraper8.DvbNip;
using skyscraper8.Experimentals.NdsSsu;
using skyscraper8.Ietf.FLUTE;
using skyscraper8.Skyscraper.Drawing;
@ -33,5 +34,7 @@ namespace skyscraper8.Skyscraper.Scraper.Storage
void DeleteRfSpectrum(Guid selectedGuid);
bool OtvSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int sourcePid, ushort tableIdExtension, uint fileId, uint unknown1, uint length);
void OnOtvSsuComplete(int? currentNetworkId, int? currentTransportStreamId, int sourcePid, Stream getStream, ushort tableIdExtension, uint fileId, uint unknown1, uint length);
void OnNdsSsuComplete(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension, NdsSsuDataMap dataMap);
bool NdsSsuTestFile(int? currentNetworkId, int? currentTransportStreamId, int pid, ushort tableIdExtension);
}
}