コード例 #1
0
        public ProgramMapTable(byte[] packetBuffer, int index)
        {
            var pointer = packetBuffer[index];

            if (pointer > 0)
            {
                index += pointer;
            }
            else
            {
                index++;
            }
            TableId              = packetBuffer[index];
            SectionLength        = (packetBuffer[index + 1] & Helper.B00000011) * 256 + packetBuffer[index + 2];
            ProgramNumber        = packetBuffer[index + 3] * 256 + packetBuffer[index + 4];
            VersionNumber        = (packetBuffer[index + 5] & Helper.B00111110) >> 1;
            CurrentNextIndicator = packetBuffer[index + 5] & 1;
            SectionNumber        = packetBuffer[index + 6];
            LastSectionNumber    = packetBuffer[index + 7];
            PcrId = (packetBuffer[index + 8] & Helper.B00011111) * 256 + packetBuffer[index + 9];
            var programInfoLength = (packetBuffer[index + 10] & Helper.B00001111) * 256 + packetBuffer[index + 11];

            Descriptors = ProgramMapTableDescriptor.ReadDescriptors(packetBuffer, programInfoLength, index + 12);
            var newIndex = index + 12 + Descriptors.Sum(p => p.Size);

            Streams = new List <ProgramMapTableStream>();
            while (newIndex - index < SectionLength - 4)
            {
                var stream = new ProgramMapTableStream(packetBuffer, newIndex);
                Streams.Add(stream);
                newIndex += stream.Size;
            }
        }
コード例 #2
0
        public static List <ProgramMapTableDescriptor> ReadDescriptors(byte[] data, int size, int index)
        {
            var total       = 0;
            var descriptors = new List <ProgramMapTableDescriptor>();

            while (total < size)
            {
                var descriptor = new ProgramMapTableDescriptor(data, total + index);
                descriptors.Add(descriptor);
                total += descriptor.Size;
            }
            return(descriptors);
        }
コード例 #3
0
        public ProgramMapTableStream(byte[] data, int index)
        {
            StreamType = data[index];

            // 13 bytes (skip first 3)
            ElementaryPid = (data[index + 1] & Helper.B00011111) * 256 +    // first 5 bytes
                            data[index + 2];                                // last 8 bytes

            var esInfoLength = (data[index + 3] & Helper.B00001111) * 256 + // first 5 bytes
                               data[index + 4];                             // last 8 bytes

            Descriptors = ProgramMapTableDescriptor.ReadDescriptors(data, esInfoLength, index + 5);
            Size        = 5 + Descriptors.Sum(p => p.Size);
        }