Skip to content

Commit

Permalink
FormatInfoProvider (Compression FileTypes)
Browse files Browse the repository at this point in the history
  • Loading branch information
DvdKhl committed Jun 9, 2020
1 parent ba43398 commit 6c79186
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
4 changes: 2 additions & 2 deletions AVDump3CL/AVDump3CL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon>AVD3Icon.ico</ApplicationIcon>
<StartupObject>AVDump3CL.Program</StartupObject>
<AssemblyVersion>3.0.8071.0</AssemblyVersion>
<AssemblyVersion>3.0.8072.0</AssemblyVersion>
<Version>3.0.0</Version>
<Company>extknot</Company>
<Authors>DvdKhl</Authors>
Expand All @@ -16,7 +16,7 @@
<NeutralLanguage>en</NeutralLanguage>
<Copyright>Copyright © 2020 extknot</Copyright>
<Platforms>AnyCPU;x64</Platforms>
<FileVersion>3.0.8071.0</FileVersion>
<FileVersion>3.0.8072.0</FileVersion>
<Configurations>Debug;Release;GithubWorkflow</Configurations>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions AVDump3Lib/AVDump3Lib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<NeutralLanguage>en</NeutralLanguage>
<ApplicationIcon></ApplicationIcon>
<Platforms>AnyCPU;x64</Platforms>
<AssemblyVersion>3.0.8071.0</AssemblyVersion>
<FileVersion>3.0.8071.0</FileVersion>
<AssemblyVersion>3.0.8072.0</AssemblyVersion>
<FileVersion>3.0.8072.0</FileVersion>
<Configurations>Debug;Release;GithubWorkflow</Configurations>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
33 changes: 28 additions & 5 deletions AVDump3Lib/Information/InfoProvider/FormatInfoProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public override void ElaborateCheck(Stream stream) {
}
}
public class SMILFileType : FileType {
public SMILFileType() : base("", identifier: "SMIL") { PossibleExtensions = new string[] { "smil" }; fileType = MediaProvider.MediaStreamType; }
public SMILFileType() : base("", identifier: "SMIL") { PossibleExtensions = new string[] { "smil" }; }

public override void ElaborateCheck(Stream stream) {
if(!IsCandidate) return;
Expand Down Expand Up @@ -612,13 +612,36 @@ public override void ElaborateCheck(Stream stream) {
if(str.IndexOf("% zerog") < 0) { IsCandidate = false; return; }
}
}
public class C7zFileType : FileType { public C7zFileType() : base(new byte[] { 0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C }, identifier: "compression/7z") => PossibleExtensions = new string[] { "7z" }; }
public class ZipFileType : FileType { public ZipFileType() : base(new byte[][] { new byte[] { 0x50, 0x4b, 0x03, 0x04 }, new byte[] { 0x50, 0x4b, 0x30, 0x30, 0x50, 0x4b } }, identifier: "compression/zip") => PossibleExtensions = new string[] { "zip" }; }
public class RarFileType : FileType { public RarFileType() : base(new byte[] { 0x52, 0x61, 0x72, 0x21 }, identifier: "compression/rar") => PossibleExtensions = new string[] { "rar" }; }
public class C7zFileType : FileType {
public C7zFileType() : base(new byte[] { 0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C }, identifier: "compression/7z") => PossibleExtensions = new string[] { "7z" };
public override void AddInfo(MetaDataProvider provider) {
if(!string.IsNullOrEmpty(identifier)) {
var container = new MetaInfoContainer(0, fileType);
provider.AddNode(container);
provider.Add(container, MediaProvider.FileTypeIdentifierType, identifier);
}
}
}
public class ZipFileType : FileType {
public ZipFileType() : base(new byte[][] { new byte[] { 0x50, 0x4b, 0x03, 0x04 }, new byte[] { 0x50, 0x4b, 0x30, 0x30, 0x50, 0x4b } }, identifier: "compression/zip") => PossibleExtensions = new string[] { "zip" };
public override void AddInfo(MetaDataProvider provider) {
if(!string.IsNullOrEmpty(identifier)) {
provider.Add(MediaProvider.FileTypeIdentifierType, identifier);
}
}
}
public class RarFileType : FileType {
public RarFileType() : base(new byte[] { 0x52, 0x61, 0x72, 0x21 }, identifier: "compression/rar") => PossibleExtensions = new string[] { "rar" };
public override void AddInfo(MetaDataProvider provider) {
if(!string.IsNullOrEmpty(identifier)) {
provider.Add(MediaProvider.FileTypeIdentifierType, identifier);
}
}
}
public class RaFileType : FileType { public RaFileType() : base(".ra" + (char)0xfd) { PossibleExtensions = new string[] { "ra" }; fileType = MediaProvider.AudioStreamType; } }
public class FlacFileType : FileType { public FlacFileType() : base("fLaC") { PossibleExtensions = new string[] { "flac" }; fileType = MediaProvider.AudioStreamType; } }
public class AviFileType : FileType { public AviFileType() : base("RIFF") { PossibleExtensions = new string[] { "avi" }; fileType = MediaProvider.VideoStreamType; } public override void ElaborateCheck(Stream stream) => IsCandidate &= Check(stream, 8, "AVI LIST"); }
public class WavFileType : FileType { public WavFileType() : base(new string[] { "RIFX", "RIFF" }) => PossibleExtensions = new string[] { "wav" }; public override void ElaborateCheck(Stream stream) => IsCandidate &= Check(stream, 8, "WAVE"); }
public class WavFileType : FileType { public WavFileType() : base(new string[] { "RIFX", "RIFF" }) { PossibleExtensions = new string[] { "wav" }; fileType = MediaProvider.AudioStreamType; } public override void ElaborateCheck(Stream stream) => IsCandidate &= Check(stream, 8, "WAVE"); }

public abstract class FileType : IFileType {
private byte[][] magicBytesLst;
Expand Down
2 changes: 2 additions & 0 deletions AVDump3Lib/Information/MetaInfo/MediaProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public abstract class MediaProvider : MetaDataProvider {
public MediaProvider(string name) : base(name, MediaProviderType) { }
public static readonly MetaInfoContainerType MediaProviderType = new MetaInfoContainerType("MediaProvider");

public static readonly MetaInfoItemType<string> FileTypeIdentifierType = new MetaInfoItemType<string>("FileTypeIdentifier"); //TODO

public static readonly MetaInfoItemType<long> FileSizeType = new MetaInfoItemType<long>("FileSize", "bytes");
public static readonly MetaInfoItemType<long> OverheadType = new MetaInfoItemType<long>("Overhead", "bytes");
public static readonly MetaInfoItemType<string> ContainerVersionType = new MetaInfoItemType<string>("ContainerVersion");
Expand Down

0 comments on commit 6c79186

Please sign in to comment.