Dump packets from a SimminRadiomidun-styled stream.
Some checks failed
🚀 Pack skyscraper8 / make-zip (push) Failing after 1m19s
Some checks failed
🚀 Pack skyscraper8 / make-zip (push) Failing after 1m19s
This commit is contained in:
parent
90f807343b
commit
897c5e95ca
@ -1,15 +1,18 @@
|
|||||||
using log4net;
|
using log4net;
|
||||||
using skyscraper5.Dvb.DataBroadcasting;
|
using skyscraper5.Dvb.DataBroadcasting;
|
||||||
|
using skyscraper8.Skyscraper.Scraper;
|
||||||
|
|
||||||
namespace skyscraper8.GSE;
|
namespace skyscraper8.GSE;
|
||||||
|
|
||||||
public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
||||||
{
|
{
|
||||||
public BbframeDeencapsulator3(IMultiprotocolEncapsulationEventHandler mpeEventHandler)
|
public BbframeDeencapsulator3(IMultiprotocolEncapsulationEventHandler mpeEventHandler, ISubTsHandler subTsHandler)
|
||||||
{
|
{
|
||||||
_mpeEventHandler = mpeEventHandler;
|
_mpeEventHandler = mpeEventHandler;
|
||||||
|
_subTsHandler = subTsHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly ISubTsHandler _subTsHandler;
|
||||||
private readonly IMultiprotocolEncapsulationEventHandler _mpeEventHandler;
|
private readonly IMultiprotocolEncapsulationEventHandler _mpeEventHandler;
|
||||||
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
|
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
|
||||||
private long numPushed;
|
private long numPushed;
|
||||||
@ -37,8 +40,9 @@ public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
|||||||
logger.InfoFormat("Found a stream on MIS {0}",bbHeader.Matype2);
|
logger.InfoFormat("Found a stream on MIS {0}",bbHeader.Matype2);
|
||||||
mis[bbHeader.Matype2] = new GsTypeDetector(bbHeader.Matype2)
|
mis[bbHeader.Matype2] = new GsTypeDetector(bbHeader.Matype2)
|
||||||
{
|
{
|
||||||
mpeEventHandler = this._mpeEventHandler
|
mpeEventHandler = this._mpeEventHandler,
|
||||||
};
|
subTsHandler = this._subTsHandler
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
mis[bbHeader.Matype2].PushFrame(bbHeader, new ReadOnlySpan<byte>(bbframe, 11, bbframe.Length - 11));
|
mis[bbHeader.Matype2].PushFrame(bbHeader, new ReadOnlySpan<byte>(bbframe, 11, bbframe.Length - 11));
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using skyscraper5.Dvb.DataBroadcasting;
|
|||||||
using skyscraper8.GS.SiminnRadiomidun;
|
using skyscraper8.GS.SiminnRadiomidun;
|
||||||
using skyscraper8.GSE.GSE_HEM;
|
using skyscraper8.GSE.GSE_HEM;
|
||||||
using skyscraper8.GSE.GSE;
|
using skyscraper8.GSE.GSE;
|
||||||
|
using skyscraper8.Skyscraper.Scraper;
|
||||||
|
|
||||||
namespace skyscraper8.GSE;
|
namespace skyscraper8.GSE;
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ public class GsTypeDetector : IMisHandler
|
|||||||
private readonly byte _misId;
|
private readonly byte _misId;
|
||||||
private readonly ILog logger;
|
private readonly ILog logger;
|
||||||
private HashSet<Tuple<int, byte>> _postedStreamTypes;
|
private HashSet<Tuple<int, byte>> _postedStreamTypes;
|
||||||
|
public ISubTsHandler subTsHandler;
|
||||||
public GsTypeDetector(byte misId)
|
public GsTypeDetector(byte misId)
|
||||||
{
|
{
|
||||||
_misId = misId;
|
_misId = misId;
|
||||||
@ -21,6 +23,8 @@ public class GsTypeDetector : IMisHandler
|
|||||||
private GseReader gseReader;
|
private GseReader gseReader;
|
||||||
private GseHemReader gseHemReader;
|
private GseHemReader gseHemReader;
|
||||||
private SiminnRadiomidunReader siminnRadiomidunReader;
|
private SiminnRadiomidunReader siminnRadiomidunReader;
|
||||||
|
private int simminRadiomidunScore;
|
||||||
|
|
||||||
public void PushFrame(BBHeader bbHeader, ReadOnlySpan<byte> readOnlySpan)
|
public void PushFrame(BBHeader bbHeader, ReadOnlySpan<byte> readOnlySpan)
|
||||||
{
|
{
|
||||||
if (readOnlySpan.Length == 0)
|
if (readOnlySpan.Length == 0)
|
||||||
@ -54,19 +58,32 @@ public class GsTypeDetector : IMisHandler
|
|||||||
|
|
||||||
if (bbHeader.TsGs == 0 && bbHeader.SyncByte == 71 && bbHeader.UserPacketLength == 188)
|
if (bbHeader.TsGs == 0 && bbHeader.SyncByte == 71 && bbHeader.UserPacketLength == 188)
|
||||||
{
|
{
|
||||||
//Looks like a Simmin Radiomidun-like stream.
|
simminRadiomidunScore++;
|
||||||
if (siminnRadiomidunReader == null)
|
if (simminRadiomidunScore > 10)
|
||||||
{
|
{
|
||||||
//These behave similar to T2-MI. Interesting.
|
//Looks like a Simmin Radiomidun-like stream.
|
||||||
siminnRadiomidunReader = new SiminnRadiomidunReader();
|
if (siminnRadiomidunReader == null)
|
||||||
}
|
{
|
||||||
|
//These behave similar to T2-MI. Interesting.
|
||||||
|
siminnRadiomidunReader = new SiminnRadiomidunReader(_misId,subTsHandler);
|
||||||
|
}
|
||||||
|
|
||||||
siminnRadiomidunReader.PushFrame(bbHeader, readOnlySpan);
|
siminnRadiomidunReader.PushFrame(bbHeader, readOnlySpan);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
//We have no idea what this is.
|
{
|
||||||
Tuple<int, byte> streamTypeToPost = new Tuple<int, byte>(bbHeader.TsGs, bbHeader.SyncByte);
|
if (simminRadiomidunScore < 10)
|
||||||
|
{
|
||||||
|
simminRadiomidunScore = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//We have no idea what this is.
|
||||||
|
Tuple<int, byte> streamTypeToPost = new Tuple<int, byte>(bbHeader.TsGs, bbHeader.SyncByte);
|
||||||
if (_postedStreamTypes == null)
|
if (_postedStreamTypes == null)
|
||||||
_postedStreamTypes = new HashSet<Tuple<int, byte>>();
|
_postedStreamTypes = new HashSet<Tuple<int, byte>>();
|
||||||
if (!_postedStreamTypes.Contains(streamTypeToPost))
|
if (!_postedStreamTypes.Contains(streamTypeToPost))
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class Pts2Bbf
|
|||||||
FileStream fileStream = file.OpenRead();
|
FileStream fileStream = file.OpenRead();
|
||||||
|
|
||||||
TsContext mpeg2 = new TsContext();
|
TsContext mpeg2 = new TsContext();
|
||||||
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(null, dumper));
|
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(null, null, dumper));
|
||||||
DataStorage dataStorage = new InMemoryScraperStorage();
|
DataStorage dataStorage = new InMemoryScraperStorage();
|
||||||
ObjectStorage objectStorage = new NullObjectStorage();
|
ObjectStorage objectStorage = new NullObjectStorage();
|
||||||
SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);
|
SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class Stid135Test
|
|||||||
ObjectStorage objectStorage = new FilesystemStorage(new DirectoryInfo("nip"));
|
ObjectStorage objectStorage = new FilesystemStorage(new DirectoryInfo("nip"));
|
||||||
SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);
|
SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);
|
||||||
|
|
||||||
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(skyscraper));
|
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(skyscraper,skyscraper));
|
||||||
|
|
||||||
skyscraper.InitalizeFilterChain();
|
skyscraper.InitalizeFilterChain();
|
||||||
skyscraper.IngestFromStream(fileStream);
|
skyscraper.IngestFromStream(fileStream);
|
||||||
|
|||||||
@ -7,20 +7,25 @@ using skyscraper5.Mpeg2.Descriptors;
|
|||||||
using skyscraper5.Skyscraper.IO;
|
using skyscraper5.Skyscraper.IO;
|
||||||
using skyscraper5.T2MI;
|
using skyscraper5.T2MI;
|
||||||
using skyscraper8.GSE;
|
using skyscraper8.GSE;
|
||||||
|
using skyscraper8.Skyscraper.Scraper;
|
||||||
|
|
||||||
namespace skyscraper8.GS.SiminnRadiomidun
|
namespace skyscraper8.GS.SiminnRadiomidun
|
||||||
{
|
{
|
||||||
internal class SiminnRadiomidunReader : IMisHandler
|
internal class SiminnRadiomidunReader : IMisHandler
|
||||||
{
|
{
|
||||||
public SiminnRadiomidunReader()
|
public SiminnRadiomidunReader(byte mis, ISubTsHandler tsOutput)
|
||||||
{
|
{
|
||||||
packetQueue = new Queue<Tuple<BBHeader,MemoryStream>>();
|
this.packetQueue = new Queue<Tuple<BBHeader,MemoryStream>>();
|
||||||
isInSync = false;
|
this.isInSync = false;
|
||||||
|
this.subTsKey = new SiminnRadiomidunSubTsIdentifier(mis);
|
||||||
|
this.tsOutput = tsOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool isInSync;
|
private bool isInSync;
|
||||||
private Queue<Tuple<BBHeader, MemoryStream>> packetQueue;
|
private Queue<Tuple<BBHeader, MemoryStream>> packetQueue;
|
||||||
private MemoryStream currentItem;
|
private MemoryStream currentItem;
|
||||||
|
private SiminnRadiomidunSubTsIdentifier subTsKey;
|
||||||
|
private ISubTsHandler tsOutput;
|
||||||
|
|
||||||
public long PacketQueueSize
|
public long PacketQueueSize
|
||||||
{
|
{
|
||||||
@ -79,17 +84,10 @@ namespace skyscraper8.GS.SiminnRadiomidun
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ulong syncSucess, syncFail;
|
private ulong syncSucess, syncFail;
|
||||||
private FileStream dumpingFileStream;
|
|
||||||
private void OutputPacket(byte[] buffer)
|
private void OutputPacket(byte[] buffer)
|
||||||
{
|
{
|
||||||
buffer[0] = 0x47;
|
buffer[0] = 0x47;
|
||||||
if (dumpingFileStream == null)
|
tsOutput.OnSubTsPacket(subTsKey, buffer);
|
||||||
{
|
|
||||||
FileInfo fi = new FileInfo(string.Format("{0}.ts", DateTime.Now.Ticks));
|
|
||||||
dumpingFileStream = fi.OpenWrite();
|
|
||||||
}
|
|
||||||
|
|
||||||
dumpingFileStream.Write(buffer, 0, 188);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace skyscraper8.GS.SiminnRadiomidun
|
||||||
|
{
|
||||||
|
internal class SiminnRadiomidunSubTsIdentifier
|
||||||
|
{
|
||||||
|
public byte Mis { get; }
|
||||||
|
|
||||||
|
public SiminnRadiomidunSubTsIdentifier(byte misId)
|
||||||
|
{
|
||||||
|
Mis = misId;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected bool Equals(SiminnRadiomidunSubTsIdentifier other)
|
||||||
|
{
|
||||||
|
return Mis == other.Mis;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
if (ReferenceEquals(null, obj))
|
||||||
|
return false;
|
||||||
|
if (ReferenceEquals(this, obj))
|
||||||
|
return true;
|
||||||
|
if (obj.GetType() != this.GetType())
|
||||||
|
return false;
|
||||||
|
return Equals((SiminnRadiomidunSubTsIdentifier)obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Mis.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{nameof(Mis)}{Mis}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using skyscraper5.Dvb.DataBroadcasting;
|
using skyscraper5.Dvb.DataBroadcasting;
|
||||||
|
using skyscraper8.Skyscraper.Scraper;
|
||||||
|
|
||||||
namespace skyscraper8.GSE
|
namespace skyscraper8.GSE
|
||||||
{
|
{
|
||||||
@ -14,10 +15,10 @@ namespace skyscraper8.GSE
|
|||||||
{
|
{
|
||||||
private IBbframeDeencapsulator deencapsulator;
|
private IBbframeDeencapsulator deencapsulator;
|
||||||
|
|
||||||
public Stid135BbFrameReader(IMultiprotocolEncapsulationEventHandler mpeEventHandler, IBbframeDeencapsulator deencapsulator = null)
|
public Stid135BbFrameReader(IMultiprotocolEncapsulationEventHandler mpeEventHandler, ISubTsHandler subTsHandler, IBbframeDeencapsulator deencapsulator = null)
|
||||||
{
|
{
|
||||||
if (deencapsulator == null)
|
if (deencapsulator == null)
|
||||||
deencapsulator = new BbframeDeencapsulator3(mpeEventHandler);
|
deencapsulator = new BbframeDeencapsulator3(mpeEventHandler, subTsHandler);
|
||||||
|
|
||||||
this.deencapsulator = deencapsulator;
|
this.deencapsulator = deencapsulator;
|
||||||
}
|
}
|
||||||
|
|||||||
13
skyscraper8/Skyscraper/Scraper/ISubTsHandler.cs
Normal file
13
skyscraper8/Skyscraper/Scraper/ISubTsHandler.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace skyscraper8.Skyscraper.Scraper
|
||||||
|
{
|
||||||
|
public interface ISubTsHandler
|
||||||
|
{
|
||||||
|
public void OnSubTsPacket(object identifier, byte[] packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -97,7 +97,7 @@ namespace skyscraper5.Skyscraper.Scraper
|
|||||||
UpdateNotificationEventHandler, DataCarouselEventHandler, RdsEventHandler, IScte35EventHandler,
|
UpdateNotificationEventHandler, DataCarouselEventHandler, RdsEventHandler, IScte35EventHandler,
|
||||||
IAutodetectionEventHandler, IRstEventHandler, IRntEventHandler, IMultiprotocolEncapsulationEventHandler, ObjectCarouselEventHandler, T2MIEventHandler,
|
IAutodetectionEventHandler, IRstEventHandler, IRntEventHandler, IMultiprotocolEncapsulationEventHandler, ObjectCarouselEventHandler, T2MIEventHandler,
|
||||||
IDisposable, IFrameGrabberEventHandler, IntEventHandler, IRctEventHandler, ISkyscraperContext, IDocsisEventHandler, AbertisDecoderEventHandler, Id3Handler,
|
IDisposable, IFrameGrabberEventHandler, IntEventHandler, IRctEventHandler, ISkyscraperContext, IDocsisEventHandler, AbertisDecoderEventHandler, Id3Handler,
|
||||||
InteractionChannelHandler, SgtEventHandler, IDvbNipEventHandler, UleEventHandler, OtvSsuHandler, NdsSsuHandler
|
InteractionChannelHandler, SgtEventHandler, IDvbNipEventHandler, UleEventHandler, OtvSsuHandler, NdsSsuHandler, ISubTsHandler
|
||||||
{
|
{
|
||||||
public const bool ALLOW_STREAM_TYPE_AUTODETECTION = true;
|
public const bool ALLOW_STREAM_TYPE_AUTODETECTION = true;
|
||||||
public const bool ALLOW_FFMPEG_FRAMEGRABBER = true;
|
public const bool ALLOW_FFMPEG_FRAMEGRABBER = true;
|
||||||
@ -305,7 +305,7 @@ namespace skyscraper5.Skyscraper.Scraper
|
|||||||
{
|
{
|
||||||
if (!DvbContext.IsPidProcessorPresent(0x010e))
|
if (!DvbContext.IsPidProcessorPresent(0x010e))
|
||||||
{
|
{
|
||||||
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this));
|
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this, this));
|
||||||
UiJunction?.SetGseMode();
|
UiJunction?.SetGseMode();
|
||||||
LogEvent(SkyscraperContextEvent.SpecialTsMode, "STiD135 encapsulated GS detected.");
|
LogEvent(SkyscraperContextEvent.SpecialTsMode, "STiD135 encapsulated GS detected.");
|
||||||
SpecialTsType = 3;
|
SpecialTsType = 3;
|
||||||
@ -360,7 +360,7 @@ namespace skyscraper5.Skyscraper.Scraper
|
|||||||
{
|
{
|
||||||
if (!DvbContext.IsPidProcessorPresent(0x010e))
|
if (!DvbContext.IsPidProcessorPresent(0x010e))
|
||||||
{
|
{
|
||||||
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this));
|
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this, this));
|
||||||
UiJunction?.SetGseMode();
|
UiJunction?.SetGseMode();
|
||||||
LogEvent(SkyscraperContextEvent.SpecialTsMode, "STiD135 encapsulated GS detected.");
|
LogEvent(SkyscraperContextEvent.SpecialTsMode, "STiD135 encapsulated GS detected.");
|
||||||
SpecialTsType = 3;
|
SpecialTsType = 3;
|
||||||
@ -1934,12 +1934,13 @@ namespace skyscraper5.Skyscraper.Scraper
|
|||||||
string filename = String.Format("{0}_{1}.ts", child.ChildName.SanitizeFileName(), child.ChildTimestamp);
|
string filename = String.Format("{0}_{1}.ts", child.ChildName.SanitizeFileName(), child.ChildTimestamp);
|
||||||
FileInfo fi = new FileInfo(filename);
|
FileInfo fi = new FileInfo(filename);
|
||||||
TsRecorder packetDumper = new TsRecorder();
|
TsRecorder packetDumper = new TsRecorder();
|
||||||
|
packetDumper.RecordingOutputDirectory = new DirectoryInfo(".");
|
||||||
packetDumper.SetNextFilename(filename);
|
packetDumper.SetNextFilename(filename);
|
||||||
packetDumper.CreateBufferedStream();
|
packetDumper.CreateBufferedStream();
|
||||||
packetFilters.Add(packetDumper);
|
packetFilters.Add(packetDumper);
|
||||||
}
|
}
|
||||||
|
|
||||||
child.InitalizeFilterChain();
|
child.InitalizeFilterChain(packetFilters.ToArray());
|
||||||
subSkyscrapers.Add(identifier, child);
|
subSkyscrapers.Add(identifier, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user