public BoxHeader(TagLib.File file, long position) { if (file == null) { throw new ArgumentNullException("file"); } this.box = null; this.from_disk = true; this.position = position; file.Seek(position); ByteVector vector = file.ReadBlock(0x20); int startIndex = 0; if (vector.Count < (8 + startIndex)) { throw new CorruptFileException("Not enough data in box header."); } this.header_size = 8; this.box_size = vector.Mid(startIndex, 4).ToUInt(); this.box_type = vector.Mid(startIndex + 4, 4); if (this.box_size == 1L) { if (vector.Count < (8 + startIndex)) { throw new CorruptFileException("Not enough data in box header."); } this.header_size += 8; this.box_size = vector.Mid(startIndex, 8).ToULong(); startIndex += 8; } if (this.box_type == TagLib.Mpeg4.BoxType.Uuid) { if (vector.Count < (0x10 + startIndex)) { throw new CorruptFileException("Not enough data in box header."); } this.header_size += 0x10; this.extended_type = vector.Mid(startIndex, 0x10); } else { this.extended_type = null; } }
public BoxHeader(ByteVector type, ByteVector extendedType) { this.position = -1L; this.box = null; this.from_disk = false; this.box_type = type; if (type == null) { throw new ArgumentNullException("type"); } if (type.Count != 4) { throw new ArgumentException("Box type must be 4 bytes in length.", "type"); } this.box_size = this.header_size = 8; if (type != "uuid") { if (extendedType != null) { throw new ArgumentException("Extended type only permitted for 'uuid'.", "extendedType"); } this.extended_type = extendedType; } else { if (extendedType == null) { throw new ArgumentNullException("extendedType"); } if (extendedType.Count != 0x10) { throw new ArgumentException("Extended type must be 16 bytes in length.", "extendedType"); } this.box_size = this.header_size = 0x18; this.extended_type = extendedType; } }