using log4net;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage.Filesystem;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper8.GS;
using skyscraper8.Skyscraper.Scraper.Storage;

namespace skyscraper8.GSE;

public class Stid135Test
{
    private static readonly ILog logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name);
    public static void Run(FileInfo file)
    {
        FileStream fileStream = file.OpenRead();

        TsContext mpeg2 = new TsContext();
        DataStorage dataStorage = new InMemoryScraperStorage();
        ObjectStorage objectStorage = new FilesystemStorage(new DirectoryInfo("nip"));
        SkyscraperContext skyscraper = new SkyscraperContext(mpeg2, dataStorage, objectStorage);

        GsContextDto context = new GsContextDto();
        mpeg2.RegisterPacketProcessor(0x010e, new Stid135BbFrameReader(context));
        
        skyscraper.InitalizeFilterChain();
        skyscraper.IngestFromStream(fileStream);
        
        fileStream.Close();
        logger.Info("STiD135 Tester exiting");
    }
}