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 skyscraper5.Dvb.DataBroadcasting;
|
||||
using skyscraper8.Skyscraper.Scraper;
|
||||
|
||||
namespace skyscraper8.GSE;
|
||||
|
||||
public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
||||
{
|
||||
public BbframeDeencapsulator3(IMultiprotocolEncapsulationEventHandler mpeEventHandler)
|
||||
public BbframeDeencapsulator3(IMultiprotocolEncapsulationEventHandler mpeEventHandler, ISubTsHandler subTsHandler)
|
||||
{
|
||||
_mpeEventHandler = mpeEventHandler;
|
||||
_subTsHandler = subTsHandler;
|
||||
}
|
||||
|
||||
private readonly ISubTsHandler _subTsHandler;
|
||||
private readonly IMultiprotocolEncapsulationEventHandler _mpeEventHandler;
|
||||
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
|
||||
private long numPushed;
|
||||
@ -37,7 +40,8 @@ public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
||||
logger.InfoFormat("Found a stream on MIS {0}",bbHeader.Matype2);
|
||||
mis[bbHeader.Matype2] = new GsTypeDetector(bbHeader.Matype2)
|
||||
{
|
||||
mpeEventHandler = this._mpeEventHandler
|
||||
mpeEventHandler = this._mpeEventHandler,
|
||||
subTsHandler = this._subTsHandler
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ using skyscraper5.Dvb.DataBroadcasting;
|
||||
using skyscraper8.GS.SiminnRadiomidun;
|
||||
using skyscraper8.GSE.GSE_HEM;
|
||||
using skyscraper8.GSE.GSE;
|
||||
using skyscraper8.Skyscraper.Scraper;
|
||||
|
||||
namespace skyscraper8.GSE;
|
||||
|
||||
@ -12,6 +13,7 @@ public class GsTypeDetector : IMisHandler
|
||||
private readonly byte _misId;
|
||||
private readonly ILog logger;
|
||||
private HashSet<Tuple<int, byte>> _postedStreamTypes;
|
||||
public ISubTsHandler subTsHandler;
|
||||
public GsTypeDetector(byte misId)
|
||||
{
|
||||
_misId = misId;
|
||||
@ -21,6 +23,8 @@ public class GsTypeDetector : IMisHandler
|
||||
private GseReader gseReader;
|
||||
private GseHemReader gseHemReader;
|
||||
private SiminnRadiomidunReader siminnRadiomidunReader;
|
||||
private int simminRadiomidunScore;
|
||||
|
||||
public void PushFrame(BBHeader bbHeader, ReadOnlySpan<byte> readOnlySpan)
|
||||
{
|
||||
if (readOnlySpan.Length == 0)
|
||||
@ -53,18 +57,31 @@ public class GsTypeDetector : IMisHandler
|
||||
}
|
||||
|
||||
if (bbHeader.TsGs == 0 && bbHeader.SyncByte == 71 && bbHeader.UserPacketLength == 188)
|
||||
{
|
||||
simminRadiomidunScore++;
|
||||
if (simminRadiomidunScore > 10)
|
||||
{
|
||||
//Looks like a Simmin Radiomidun-like stream.
|
||||
if (siminnRadiomidunReader == null)
|
||||
{
|
||||
//These behave similar to T2-MI. Interesting.
|
||||
siminnRadiomidunReader = new SiminnRadiomidunReader();
|
||||
siminnRadiomidunReader = new SiminnRadiomidunReader(_misId,subTsHandler);
|
||||
}
|
||||
|
||||
siminnRadiomidunReader.PushFrame(bbHeader, readOnlySpan);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
|
||||
@ -44,7 +44,7 @@ public class Pts2Bbf
|
||||
FileStream fileStream = file.OpenRead();
|
||||
|
||||
TsContext mpeg2 = new TsContext();
|
||||
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(null, dumper));
|
||||
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(null, null, dumper));
|
||||
DataStorage dataStorage = new InMemoryScraperStorage();
|
||||
ObjectStorage objectStorage = new NullObjectStorage();
|
||||
SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);
|
||||
|
||||
@ -19,7 +19,7 @@ public class Stid135Test
|
||||
ObjectStorage objectStorage = new FilesystemStorage(new DirectoryInfo("nip"));
|
||||
SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);
|
||||
|
||||
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(skyscraper));
|
||||
mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(skyscraper,skyscraper));
|
||||
|
||||
skyscraper.InitalizeFilterChain();
|
||||
skyscraper.IngestFromStream(fileStream);
|
||||
|
||||
@ -7,20 +7,25 @@ using skyscraper5.Mpeg2.Descriptors;
|
||||
using skyscraper5.Skyscraper.IO;
|
||||
using skyscraper5.T2MI;
|
||||
using skyscraper8.GSE;
|
||||
using skyscraper8.Skyscraper.Scraper;
|
||||
|
||||
namespace skyscraper8.GS.SiminnRadiomidun
|
||||
{
|
||||
internal class SiminnRadiomidunReader : IMisHandler
|
||||
{
|
||||
public SiminnRadiomidunReader()
|
||||
public SiminnRadiomidunReader(byte mis, ISubTsHandler tsOutput)
|
||||
{
|
||||
packetQueue = new Queue<Tuple<BBHeader,MemoryStream>>();
|
||||
isInSync = false;
|
||||
this.packetQueue = new Queue<Tuple<BBHeader,MemoryStream>>();
|
||||
this.isInSync = false;
|
||||
this.subTsKey = new SiminnRadiomidunSubTsIdentifier(mis);
|
||||
this.tsOutput = tsOutput;
|
||||
}
|
||||
|
||||
private bool isInSync;
|
||||
private Queue<Tuple<BBHeader, MemoryStream>> packetQueue;
|
||||
private MemoryStream currentItem;
|
||||
private SiminnRadiomidunSubTsIdentifier subTsKey;
|
||||
private ISubTsHandler tsOutput;
|
||||
|
||||
public long PacketQueueSize
|
||||
{
|
||||
@ -79,17 +84,10 @@ namespace skyscraper8.GS.SiminnRadiomidun
|
||||
}
|
||||
|
||||
private ulong syncSucess, syncFail;
|
||||
private FileStream dumpingFileStream;
|
||||
private void OutputPacket(byte[] buffer)
|
||||
{
|
||||
buffer[0] = 0x47;
|
||||
if (dumpingFileStream == null)
|
||||
{
|
||||
FileInfo fi = new FileInfo(string.Format("{0}.ts", DateTime.Now.Ticks));
|
||||
dumpingFileStream = fi.OpenWrite();
|
||||
}
|
||||
|
||||
dumpingFileStream.Write(buffer, 0, 188);
|
||||
tsOutput.OnSubTsPacket(subTsKey, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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.Threading.Tasks;
|
||||
using skyscraper5.Dvb.DataBroadcasting;
|
||||
using skyscraper8.Skyscraper.Scraper;
|
||||
|
||||
namespace skyscraper8.GSE
|
||||
{
|
||||
@ -14,10 +15,10 @@ namespace skyscraper8.GSE
|
||||
{
|
||||
private IBbframeDeencapsulator deencapsulator;
|
||||
|
||||
public Stid135BbFrameReader(IMultiprotocolEncapsulationEventHandler mpeEventHandler, IBbframeDeencapsulator deencapsulator = null)
|
||||
public Stid135BbFrameReader(IMultiprotocolEncapsulationEventHandler mpeEventHandler, ISubTsHandler subTsHandler, IBbframeDeencapsulator deencapsulator = null)
|
||||
{
|
||||
if (deencapsulator == null)
|
||||
deencapsulator = new BbframeDeencapsulator3(mpeEventHandler);
|
||||
deencapsulator = new BbframeDeencapsulator3(mpeEventHandler, subTsHandler);
|
||||
|
||||
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,
|
||||
IAutodetectionEventHandler, IRstEventHandler, IRntEventHandler, IMultiprotocolEncapsulationEventHandler, ObjectCarouselEventHandler, T2MIEventHandler,
|
||||
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_FFMPEG_FRAMEGRABBER = true;
|
||||
@ -305,7 +305,7 @@ namespace skyscraper5.Skyscraper.Scraper
|
||||
{
|
||||
if (!DvbContext.IsPidProcessorPresent(0x010e))
|
||||
{
|
||||
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this));
|
||||
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this, this));
|
||||
UiJunction?.SetGseMode();
|
||||
LogEvent(SkyscraperContextEvent.SpecialTsMode, "STiD135 encapsulated GS detected.");
|
||||
SpecialTsType = 3;
|
||||
@ -360,7 +360,7 @@ namespace skyscraper5.Skyscraper.Scraper
|
||||
{
|
||||
if (!DvbContext.IsPidProcessorPresent(0x010e))
|
||||
{
|
||||
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this));
|
||||
DvbContext.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(this, this));
|
||||
UiJunction?.SetGseMode();
|
||||
LogEvent(SkyscraperContextEvent.SpecialTsMode, "STiD135 encapsulated GS detected.");
|
||||
SpecialTsType = 3;
|
||||
@ -1934,12 +1934,13 @@ namespace skyscraper5.Skyscraper.Scraper
|
||||
string filename = String.Format("{0}_{1}.ts", child.ChildName.SanitizeFileName(), child.ChildTimestamp);
|
||||
FileInfo fi = new FileInfo(filename);
|
||||
TsRecorder packetDumper = new TsRecorder();
|
||||
packetDumper.RecordingOutputDirectory = new DirectoryInfo(".");
|
||||
packetDumper.SetNextFilename(filename);
|
||||
packetDumper.CreateBufferedStream();
|
||||
packetFilters.Add(packetDumper);
|
||||
}
|
||||
|
||||
child.InitalizeFilterChain();
|
||||
child.InitalizeFilterChain(packetFilters.ToArray());
|
||||
subSkyscrapers.Add(identifier, child);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user