Example #1
0
        public EITScanResult Scan(List <byte> bytes)
        {
            if (bytes == null || bytes.Count == 0)
            {
                return(new EITScanResult()
                {
                    OK = false
                });
            }

            var packets = MPEGTransportStreamPacket.Parse(bytes);

            return(Scan(packets));
        }
        public static List <MPEGTransportStreamPacket> Parse(List <byte> bytes, int PIDFilter = -1)
        {
            var pos = FindSyncBytePosition(bytes);

            var res = new List <MPEGTransportStreamPacket>();

            if (pos == -1)
            {
                return(res);
            }

            while (pos + 188 < bytes.Count)
            {
                var buff = new byte[188];
                for (var i = 0; i < 188; i++)
                {
                    buff[i] = bytes[pos + i];
                }

                var packet = new MPEGTransportStreamPacket();
                packet.Parse(buff);

                if (
                    (PIDFilter == -1)      // add all packets
                    ||
                    ((PIDFilter != -1) && (packet.PID == PIDFilter))
                    )
                {
                    res.Add(packet);
                }

                pos += 188;
            }

            return(res);
        }