40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using log4net;
|
|
|
|
namespace skyscraper8.GSE;
|
|
|
|
public class BbframeDeencapsulator3 : IBbframeDeencapsulator
|
|
{
|
|
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.ChecksumValid)
|
|
return;
|
|
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();
|
|
}
|
|
|
|
mis[bbHeader.Matype2].PushFrame(bbHeader, new ReadOnlySpan<byte>(bbframe, 11, bbframe.Length - 11));
|
|
}
|
|
|
|
private IMisHandler[] mis;
|
|
} |