using System;
using System.IO;
using skyscraper5.Mpeg2;

namespace skyscraper5.Skyscraper.Scraper.Utils
{
    class SiDumper : IPsiProcessor
    {
        private ulong serial;

        public void GatherPsi(PsiSection section, int sourcePid)
        {
            byte[] buffer = section.GetDataCopy();

            DirectoryInfo outDir = new DirectoryInfo("dumped_si");
            if (!outDir.Exists)
                outDir.Create();
            FileInfo fi = new FileInfo(Path.Combine(outDir.FullName, String.Format("PID{0:X4}_{1:D8}.si", sourcePid, ++serial)));
            File.WriteAllBytes(fi.FullName, buffer);
        }
    }
}
