/// <summary> /// Create a new program instance. /// </summary> /// <param name="table">The related <see cref="Tables.PMT"/> table.</param> /// <param name="offset">The first byte of this program in the <see cref="EPG.Table.Section"/> /// for the related <see cref="Table"/>.</param> /// <param name="length">The maximum number of bytes available. If this number /// is greater than the <see cref="Length"/> of this program another event will /// follow in the same table.</param> internal ProgramEntry(Table table, int offset, int length) : base(table) { // Access section Section section = Section; // Load ElementaryPID = (ushort)(0x1fff & Tools.MergeBytesToWord(section[offset + 2], section[offset + 1])); StreamType = (StreamTypes)section[offset + 0]; // Read the length int descrLength = 0xfff & Tools.MergeBytesToWord(section[offset + 4], section[offset + 3]); // Caluclate the total length Length = 5 + descrLength; // Verify if (Length > length) { return; } // Try to load descriptors Descriptors = Descriptor.Load(this, offset + 5, descrLength); // Can use it IsValid = true; }
/// <summary> /// Create a new service instance. /// </summary> /// <param name="table">The related <see cref="Tables.SDT"/> table.</param> /// <param name="offset">The first byte of this service in the <see cref="EPG.Table.Section"/> /// for the related <see cref="Table"/>.</param> /// <param name="length">The maximum number of bytes available. If this number /// is greater than the <see cref="Length"/> of this service another event will /// follow in the same table.</param> internal ServiceEntry(Table table, int offset, int length) : base(table) { // Access section Section section = Section; // Read statics ServiceIdentifier = Tools.MergeBytesToWord(section[offset + 1], section[offset + 0]); Scrambled = (0 != (section[offset + 3] & 0x10)); // Decode int highLoop = section[offset + 3] & 0xf; int lowLoop = section[offset + 4]; // Number of descriptors int loop = lowLoop + 256 * highLoop; // Caluclate the total length Length = 5 + loop; // Verify if (Length > length) { return; } // Try to load descriptors Descriptors = Descriptor.Load(this, offset + 5, loop); // Can use it IsValid = true; }