48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using log4net;
|
|
using skyscraper5.Dvb.DataBroadcasting;
|
|
|
|
namespace skyscraper8.GSE;
|
|
|
|
public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
|
{
|
|
public BbframeDeencapsulator3(IMultiprotocolEncapsulationEventHandler mpeEventHandler)
|
|
{
|
|
_mpeEventHandler = mpeEventHandler;
|
|
}
|
|
|
|
private readonly IMultiprotocolEncapsulationEventHandler _mpeEventHandler;
|
|
private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
|
|
private long numPushed;
|
|
public void PushPacket(byte[] bbframe)
|
|
{
|
|
//byte 0, sync byte
|
|
if (bbframe[0] != 0xb8)
|
|
{
|
|
if (numPushed == 0)
|
|
{
|
|
logger.InfoFormat("The stream started in the middle of a BBFrame, let's skip to the start of the next one.");
|
|
}
|
|
return;
|
|
}
|
|
numPushed++;
|
|
|
|
BBHeader bbHeader = new BBHeader(bbframe, 1);
|
|
if (!bbHeader.Valid)
|
|
return;
|
|
|
|
if (mis == null)
|
|
mis = new IMisHandler[256];
|
|
if (mis[bbHeader.Matype2] == null)
|
|
{
|
|
logger.InfoFormat("Found a stream on MIS {0}",bbHeader.Matype2);
|
|
mis[bbHeader.Matype2] = new GsTypeDetector(bbHeader.Matype2)
|
|
{
|
|
mpeEventHandler = this._mpeEventHandler
|
|
};
|
|
}
|
|
|
|
mis[bbHeader.Matype2].PushFrame(bbHeader, new ReadOnlySpan<byte>(bbframe, 11, bbframe.Length - 11));
|
|
}
|
|
|
|
private IMisHandler[] mis;
|
|
} |