summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorac79b0c6 <[email protected]>2022-05-08 10:21:04 +0800
committerac79b0c6 <[email protected]>2022-05-08 10:21:04 +0800
commit9a7dd2ee81c0ee3ca5ba049d85188f66c30a81ef (patch)
tree439deb2dce945b1d00dcaa61a6da3c50c3232dfb
parent091dfc6c66fde06638399d5e4c93bf64dc6dbdf3 (diff)
update sdk
-rw-r--r--.gitignore7
-rw-r--r--mkvtool-gui/mkvtool.csproj14
-rw-r--r--mkvtool-gui/sdk.cs150
3 files changed, 129 insertions, 42 deletions
diff --git a/.gitignore b/.gitignore
index 599e12e..8f73b4b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,15 @@
### Example user template template
### Example user template
+go.sum
+
# IntelliJ project files
.idea
*.iml
out
gen
-
+# VS project files
+bin
+obj
+.vs \ No newline at end of file
diff --git a/mkvtool-gui/mkvtool.csproj b/mkvtool-gui/mkvtool.csproj
index bf95164..e0f7638 100644
--- a/mkvtool-gui/mkvtool.csproj
+++ b/mkvtool-gui/mkvtool.csproj
@@ -1,20 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
- <TargetFramework>net5.0</TargetFramework>
+ <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
- <IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
- <IsOSX Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsOSX>
- <IsLinux Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinux>
</PropertyGroup>
- <PropertyGroup Condition="'$(IsWindows)'=='true'">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>Windows</DefineConstants>
</PropertyGroup>
- <PropertyGroup Condition="'$(IsOSX)'=='true'">
- <DefineConstants>OSX</DefineConstants>
- </PropertyGroup>
- <PropertyGroup Condition="'$(IsLinux)'=='true'">
- <DefineConstants>Linux</DefineConstants>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+ <DefineConstants>Windows</DefineConstants>
</PropertyGroup>
<ItemGroup>
<None Remove=".gitignore" />
diff --git a/mkvtool-gui/sdk.cs b/mkvtool-gui/sdk.cs
index 2be1922..10bd42f 100644
--- a/mkvtool-gui/sdk.cs
+++ b/mkvtool-gui/sdk.cs
@@ -4,52 +4,82 @@ using System.Text.Json;
public static class mkvlib
{
-#if OSX
- const string so = "mkvlib_osx.so";
-#endif
-#if Linux
- const string so = "mkvlib_linux.so";
-#endif
-#if Windows
- const string so = "mkvlib_windows.so";
-#endif
#region imports
- [DllImport(so)]
+ [DllImport("mkvlib.so", EntryPoint = "Version")]
+ static extern IntPtr _Version();
+
+ [DllImport("mkvlib.so")]
static extern bool InitInstance(logCallback lcb);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern IntPtr GetMKVInfo(IntPtr ptr);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern bool DumpMKV(IntPtr file, IntPtr output, bool subset, logCallback lcb);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern IntPtr CheckSubset(IntPtr file, logCallback lcb);
- [DllImport(so)]
- static extern bool CreateMKV(IntPtr file, IntPtr tracks, IntPtr attachments, IntPtr output, IntPtr slang,
- IntPtr stitle, bool clean);
+ [DllImport("mkvlib.so")]
+ static extern bool CreateMKV(IntPtr file, IntPtr tracks, IntPtr attachments, IntPtr output, IntPtr slang, IntPtr stitle, bool clean);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern bool ASSFontSubset(IntPtr files, IntPtr fonts, IntPtr output, bool dirSafe, logCallback lcb);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern IntPtr QueryFolder(IntPtr dir, logCallback lcb);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern bool DumpMKVs(IntPtr dir, IntPtr output, bool subset, logCallback lcb);
- [DllImport(so)]
- static extern bool CreateMKVs(IntPtr vDir, IntPtr sDir, IntPtr fDir, IntPtr tDir, IntPtr oDir, IntPtr slang,
- IntPtr stitle, bool clean, logCallback lcb);
+ [DllImport("mkvlib.so")]
+ static extern bool CreateMKVs(IntPtr vDir, IntPtr sDir, IntPtr fDir, IntPtr tDir, IntPtr oDir, IntPtr slang, IntPtr stitle, bool clean, logCallback lcb);
- [DllImport(so)]
+ [DllImport("mkvlib.so")]
static extern bool MakeMKVs(IntPtr dir, IntPtr data, IntPtr output, IntPtr slang, IntPtr stitle, logCallback lcb);
+ [DllImport("mkvlib.so")]
+ static extern bool CreateBlankOrBurnVideo(long t, IntPtr s, IntPtr enc, IntPtr ass, IntPtr fontdir, IntPtr output);
+
+ [DllImport("mkvlib.so")]
+ static extern bool CreateTestVideo(IntPtr asses, IntPtr s, IntPtr fontdir, IntPtr enc, bool burn, logCallback lcb);
+
+ [DllImport("mkvlib.so")]
+ static extern void A2P(bool a2p, bool apc, IntPtr pr, IntPtr pf);
+
+ [DllImport("mkvlib.so")]
+ static extern IntPtr GetFontsList(IntPtr files, logCallback lcb);
+
+ [DllImport("mkvlib.so")]
+ static extern void Cache(IntPtr ccs);
+
+ [DllImport("mkvlib.so", EntryPoint = "MKS")]
+ static extern void _MKS(bool mks);
+
+ [DllImport("mkvlib.so", EntryPoint = "NRename")]
+ static extern void _NRename(bool n);
+
+ [DllImport("mkvlib.so", EntryPoint = "Check")]
+ static extern void _Check(bool check, bool strict);
+
+ [DllImport("mkvlib.so")]
+ static extern IntPtr CreateFontsCache(IntPtr dir, IntPtr output, logCallback lcb);
+
+ [DllImport("mkvlib.so")]
+ static extern bool CopyFontsFromCache(IntPtr asses, IntPtr dist, logCallback lcb);
+
+ [DllImport("mkvlib.so")]
+ static extern IntPtr GetFontInfo(IntPtr p);
+
#endregion
+ public static string Version()
+ {
+ return css(_Version());
+ }
+
public static bool InitInstance(Action<string> lcb)
{
return InitInstance(_lcb(lcb));
@@ -75,17 +105,16 @@ public static class mkvlib
return result;
}
- public static bool CreateMKV(string file, string[] tracks, string[] attachments, string output, string slang,
- string stitle, bool clean)
+ public static bool CreateMKV(string file, string[] tracks, string[] attachments, string output, string slang, string stitle, bool clean)
{
- string _tracks = JsonSerializer.Serialize<string[]>(tracks);
- string _attachments = JsonSerializer.Serialize<string[]>(attachments);
+ string _tracks = JsonSerializer.Serialize(tracks);
+ string _attachments = JsonSerializer.Serialize(attachments);
return CreateMKV(cs(file), cs(_tracks), cs(_attachments), cs(output), cs(slang), cs(stitle), clean);
}
public static bool ASSFontSubset(string[] files, string fonts, string output, bool dirSafe, Action<string> lcb)
{
- string _files = JsonSerializer.Serialize<string[]>(files);
+ string _files = JsonSerializer.Serialize(files);
return ASSFontSubset(cs(_files), cs(fonts), cs(output), dirSafe, _lcb(lcb));
}
@@ -100,8 +129,7 @@ public static class mkvlib
return DumpMKVs(cs(dir), cs(output), subset, _lcb(lcb));
}
- public static bool CreateMKVs(string vDir, string sDir, string fDir, string tDir, string oDir, string slang,
- string stitle, bool clean, Action<string> lcb)
+ public static bool CreateMKVs(string vDir, string sDir, string fDir, string tDir, string oDir, string slang, string stitle, bool clean, Action<string> lcb)
{
return CreateMKVs(cs(vDir), cs(sDir), cs(fDir), cs(tDir), cs(oDir), cs(slang), cs(stitle), clean, _lcb(lcb));
}
@@ -111,9 +139,68 @@ public static class mkvlib
return MakeMKVs(cs(dir), cs(data), cs(output), cs(slang), cs(stitle), _lcb(lcb));
}
+ public static bool CreateBlankOrBurnVideo(long t, string s, string enc, string ass, string fontdir, string output)
+ {
+ return CreateBlankOrBurnVideo(t, cs(s), cs(enc), cs(ass), cs(fontdir), cs(output));
+ }
- delegate void logCallback(IntPtr ptr);
+ public static bool CreateTestVideo(string[] asses, string s, string fontdir, string enc, bool burn, Action<string> lcb)
+ {
+ string _asses = JsonSerializer.Serialize(asses);
+ return CreateTestVideo(cs(_asses), cs(s), cs(fontdir), cs(enc), burn, _lcb(lcb));
+ }
+ public static void A2P(bool a2p, bool apc, string pr, string pf)
+ {
+ A2P(a2p, apc, cs(pr), cs(pf));
+ }
+
+ public static string[] GetFontsList(string[] files, Action<string> lcb)
+ {
+ string _files = JsonSerializer.Serialize(files);
+ string result = css(GetFontsList(cs(_files), _lcb(lcb)));
+ return JsonSerializer.Deserialize<string[]>(result);
+ }
+
+ public static void Cache(string[] ccs)
+ {
+ string _ccs = JsonSerializer.Serialize(ccs);
+ Cache(cs(_ccs));
+ }
+
+ public static void MKS(bool mks)
+ {
+ _MKS(mks);
+ }
+
+ public static void NRename(bool n)
+ {
+ _NRename(n);
+ }
+
+ public static void Check(bool check, bool strict)
+ {
+ _Check(check, strict);
+ }
+
+ public static string GetFontInfo(string p)
+ {
+ return css(GetFontInfo(cs(p)));
+ }
+
+ public static string[] CreateFontsCache(string dir, string output, Action<string> lcb)
+ {
+ string result = css(CreateFontsCache(cs(dir), cs(output), _lcb(lcb)));
+ return JsonSerializer.Deserialize<string[]>(result);
+ }
+
+ public static bool CopyFontsFromCache(string[] asses, string dist, Action<string> lcb)
+ {
+ string _files = JsonSerializer.Serialize(asses);
+ return CopyFontsFromCache(cs(_files), cs(dist), _lcb(lcb));
+ }
+
+ delegate void logCallback(IntPtr ptr);
static logCallback _lcb(Action<string> lcb)
{
return (ptr) =>
@@ -132,4 +219,5 @@ public static class mkvlib
{
return Marshal.PtrToStringUTF8(ptr);
}
+
} \ No newline at end of file