using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.IO;

namespace skyscraper5.Scte35
{
    static class SpliceTime
    {
        public static ulong? ReadSpliceTime(this Stream s)
        {
            byte readUInt8 = s.ReadUInt8();
            bool timeSpecifiedFlag = (readUInt8 & 0x80) != 0;
            if (timeSpecifiedFlag)
            {
                ulong result = (ulong)(readUInt8 & 0x01);
                result <<= 32;
                result += s.ReadUInt32BE();
                return result;
            }
            return null;
        }
    }
}
