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; } }
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; } }
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; case DESCRIPTOR_TAGS.DESCR_LOGICAL_CHANNEL: descriptor = new PSIDescriptorLogicalChannel(); break; case DESCRIPTOR_TAGS.DESCR_HD_SIMULCAST_LOGICAL_CHANNEL: descriptor = new PSIDescriptorHDSimulcastLogicalChannel(); 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); }
public override void Parse(byte[] data) { base.Parse(data); this.reserved3 = (byte)(data[8] >> 4); this.networkDescriptorLength = (byte)(((data[8] & 0x0F) << 8) | (data[9])); int offset = 10; //taille de l'entete de la table if (this.NetworkDescriptorLength > 0) { // Parse program descriptors this.descriptors = PSIDescriptor.ParseDescriptors(data, offset, this.NetworkDescriptorLength); } offset += this.NetworkDescriptorLength; // rajout la taille du tableau de descriptors this.reserved4 = (byte)(data[offset] >> 4); this.transportStreamLoopLength = (ushort)(((data[offset] & 0x0F) << 8) | (data[offset + 1])); offset += 2; //rajout de la taille de reserved4 et de transportStreamLoopLength int streamLen = data.Length - this.NetworkDescriptorLength - 14; //int streamLen = this.transportStreamLoopLength; while (streamLen >= 6) { Data nitData = new Data(); nitData.TransportStreamId = (ushort)(((data[offset]) << 8) | (data[offset + 1])); nitData.OriginalNetworkId = (ushort)(((data[offset + 2]) << 8) | (data[offset + 3]));; nitData.Reserved1 = (byte)(data[offset + 4] >> 4); nitData.TransportDescriptorLenght = (ushort)((((data[offset + 4]) & 0x0F) << 8) | (data[offset + 5])); nitData.Descriptors = PSIDescriptor.ParseDescriptors(data, offset + 6, nitData.TransportDescriptorLenght); this.streams.Add(nitData); offset += nitData.TransportDescriptorLenght + 6; //offset increnté de la taille de la loop streamLen -= nitData.TransportDescriptorLenght + 6; // taille de la loop restante décrémenté } }
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; case DESCRIPTOR_TAGS.DESCR_LOGICAL_CHANNEL: descriptor = new PSIDescriptorLogicalChannel();break; case DESCRIPTOR_TAGS.DESCR_HD_SIMULCAST_LOGICAL_CHANNEL: descriptor = new PSIDescriptorHDSimulcastLogicalChannel();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; }