Пример #1
0
        public override void Parse(byte[] data)
        {
            base.Parse(data);

            this.reserved3         = (byte)(data[8] >> 5);
            this.pcrPid            = (ushort)((data[8] & 0x1F) << 8 | data[9]);
            this.reserved4         = (byte)(data[10] >> 4);
            this.programInfoLength = (byte)((data[10] & 0x0F) << 8 | data[11]);
            int offset = 12;

            if (this.programInfoLength > 0)
            {
                // Parse program descriptors
                this.descriptors = PSIDescriptor.ParseDescriptors(data, offset, this.programInfoLength);
            }
            offset += this.programInfoLength;
            int streamLen = data.Length - this.programInfoLength - 16;

            while (streamLen >= 5)
            {
                Data pmtData = new Data();
                pmtData.StreamType  = (STREAM_TYPES)data[offset];
                pmtData.Pid         = (ushort)(((data[offset + 1] & 0x1F) << 8) + data[offset + 2]);
                pmtData.EsInfoLen   = (ushort)(((data[offset + 3] & 0x0F) << 8) + data[offset + 4]);
                pmtData.Descriptors = PSIDescriptor.ParseDescriptors(data, offset + 5, pmtData.EsInfoLen);

                this.streams.Add(pmtData);
                this.streamsByType[pmtData.StreamType] = pmtData;
                offset    += pmtData.EsInfoLen + 5;
                streamLen -= pmtData.EsInfoLen + 5;
            }
        }
Пример #2
0
        public override void Parse(byte[] data)
        {
            base.Parse(data);

            this.originalNetworkId = (ushort)(data[8] << 8 | data[9]);
            this.reserved3         = data[10];

            int offset = 11;

            while (offset < SectionLength - 1)
            {
                Data sdtData = new Data();
                sdtData.ServiceId               = (ushort)((data[offset] << 8) + data[offset + 1]);
                sdtData.Reserved                = (byte)(data[offset + 2] >> 2);
                sdtData.EitScheduleFlag         = ((data[offset + 2] & 0x02) != 0);
                sdtData.EitPresentFollowingFlag = ((data[offset + 2] & 0x01) != 0);
                sdtData.RunningStatus           = (Data.RUNNING_STATUS)((data[offset + 3] >> 5) & 0x07);
                sdtData.FreeCaMode              = (((data[offset + 3] >> 4) & 0x01) != 0);
                sdtData.DescriptorsLoopLength   = (ushort)(((data[offset + 3] & 0x0F) << 8) | data[offset + 4]);
                sdtData.Descriptors             = PSIDescriptor.ParseDescriptors(data, offset + 5, sdtData.DescriptorsLoopLength);

                this.services.Add(sdtData);
                offset += sdtData.DescriptorsLoopLength + 5;
            }
        }
Пример #3
0
        public static PSIDescriptor ParseDescriptor(byte[] data, int offset, byte length)
        {
            DESCRIPTOR_TAGS descriptorTag = (DESCRIPTOR_TAGS)data[offset];
            PSIDescriptor   descriptor;

            switch (descriptorTag)
            {
            case DESCRIPTOR_TAGS.DESCR_SERVICE:
                descriptor = new PSIDescriptorService(); break;

            case DESCRIPTOR_TAGS.DESCR_STD:
                descriptor = new PSIDescriptorSTD(); break;

            case DESCRIPTOR_TAGS.DESCR_ISO_639_LANGUAGE:
                descriptor = new PSIDescriptorISO639Language(); break;

            case DESCRIPTOR_TAGS.DESCR_SUBTITLING:
                descriptor = new PSIDescriptorSubtitling(); break;

            case DESCRIPTOR_TAGS.DESCR_TELETEXT:
                descriptor = new PSIDescriptorTeletext(); break;

            case DESCRIPTOR_TAGS.DESCR_AC3:
                descriptor = new PSIDescriptorAC3(); break;

            case DESCRIPTOR_TAGS.DESCR_CA_IDENT:
                descriptor = new PSIDescriptorCAIdentifier(); break;

            case DESCRIPTOR_TAGS.DESCR_CA_SYSTEM:
                descriptor = new PSIDescriptorCASystem(); break;

            case DESCRIPTOR_TAGS.DESCR_CA:
                descriptor = new PSIDescriptorCA(); break;

            case DESCRIPTOR_TAGS.DESCR_DATA_BROADCAST_ID:
                descriptor = new PSIDescriptorDataBroadcastId(); break;

            default:
                descriptor             = new PSIDescriptor();
                descriptor.unparseData = new byte[length];
                Array.Copy(data, offset + 2, descriptor.unparseData, 0, length);
                break;
            }
            descriptor.Parse(data, offset);
            return(descriptor);
        }