public DataInformationBox(BoxLocation loc, SequentialReader sr) : base(loc) { Boxes = BoxReader.ReadBoxes(sr, loc); }
public ItemPropertyBox(BoxLocation loc, SequentialReader sr) : base(loc) { Boxes = BoxReader.ReadBoxes(sr, loc); }
private const int ExifTag = 0x45786966; // Exif public static DirectoryList ReadMetadata(Stream stream) { var directories = new List <Directory>(); // // Read all boxes from the file // var reader = new SequentialStreamReader(stream); var boxes = BoxReader.ReadBoxes(reader); // // Map those boxes to directories // ParseQuickTimeTest(); uint primaryItem = boxes.Descendant <PrimaryItemBox>()?.PrimaryItem ?? uint.MaxValue; var itemRefs = (boxes.Descendant <ItemReferenceBox>()?.Boxes ?? new SingleItemTypeReferenceBox[0]) .Where(i => i.Type == BoxTypes.ThmbTag || i.Type == BoxTypes.CdscTag).ToList(); ParseImageProperties(); if (stream.CanSeek) { ParseItemSegments(); } return(directories); void ParseQuickTimeTest() { if (boxes.Descendant <FileTypeBox>() is { } ftype) { var dir = new QuickTimeFileTypeDirectory(); if (ftype.MajorBrand > 0) { dir.Set(QuickTimeFileTypeDirectory.TagMajorBrand, ftype.MajorBrandString); } if (ftype.MinorBrand > 0) { dir.Set(QuickTimeFileTypeDirectory.TagMinorVersion, ftype.MinorBrandString); } if (ftype.CompatibleBrands.Count > 0) { dir.Set( QuickTimeFileTypeDirectory.TagCompatibleBrands, string.Join(", ", ftype.CompatibleBrandStrings.ToArray())); } directories.Add(dir); } } void ParseImageProperties() { uint[] allPrimaryTiles = (boxes.Descendant <ItemReferenceBox>()?.Boxes ?? new SingleItemTypeReferenceBox[0]) .SelectMany(i => i.FromItemId == primaryItem && i.Type == BoxTypes.DimgTag ? i.ToItemIds : new uint[0]) .ToArray(); var itemPropertyBox = boxes.Descendant <ItemPropertyBox>(); if (itemPropertyBox == null) { return; } var props = itemPropertyBox.Boxes.Descendant <ItemPropertyContainerBox>().Boxes; var associations = itemPropertyBox.Boxes.Descendant <ItemPropertyAssociationBox>(); ParsePropertyBoxes( "HEIC Primary Item Properties", ImageProperties(primaryItem, allPrimaryTiles, associations, props)); foreach (var itemRef in itemRefs) { ParsePropertyBoxes( "HEIC Thumbnail Properties", ImageProperties(itemRef.FromItemId, new uint[0], associations, props)); } return;
public DataReferenceBox(BoxLocation location, SequentialReader reader) : base(location, reader) { BoxCount = reader.GetUInt32(); Boxes = BoxReader.ReadBoxes(reader, location); }
public ItemInformationBox(BoxLocation location, SequentialReader reader) : base(location, reader) { Count = Version == 0 ? reader.GetUInt16() : reader.GetUInt32(); Boxes = BoxReader.ReadBoxes(reader, location); }
public MetaBox(BoxLocation location, SequentialReader reader) : base(location, reader) { Boxes = BoxReader.ReadBoxes(reader, location); }