From 765e5e9bd2431b132cd3e6cfffa0df44eb531d05 Mon Sep 17 00:00:00 2001 From: ac79b0c6 <105047743+ac79b0c6@users.noreply.github.com> Date: Mon, 6 Jun 2022 10:13:46 +0800 Subject: update sdk --- mkvlib/c/README.md | 3 ++- mkvlib/c/exports.go | 6 +++--- mkvlib/c/lcb.c | 4 ++-- mkvlib/c/lcb.h | 4 ++-- mkvlib/c/sdk.cs | 42 ++++++++++++++++++++++++++---------------- mkvlib/c/sdk.py | 6 +++--- mkvlib/c/sdk.rs | 3 ++- mkvlib/shared.go | 6 +++--- 8 files changed, 43 insertions(+), 31 deletions(-) (limited to 'mkvlib') diff --git a/mkvlib/c/README.md b/mkvlib/c/README.md index aed6984..2143bab 100644 --- a/mkvlib/c/README.md +++ b/mkvlib/c/README.md @@ -48,7 +48,8 @@ - 原型 ```c - void (*logCallback)(char* str); + void (*logCallback)(unsigned char l, char* str); + //l: 日志等级(0:Info, 1:Warning, 2:SWarning, 3:Error, 4:Progress) //str: UTF-8编码的指针,并约定所有"char*"数据类型的参数或返回值都为此. ``` - 一些说明 diff --git a/mkvlib/c/exports.go b/mkvlib/c/exports.go index b75d121..760491f 100644 --- a/mkvlib/c/exports.go +++ b/mkvlib/c/exports.go @@ -13,9 +13,9 @@ func checkInstance() bool { return getter.GetProcessorInstance() != nil } -func _lcb(lcb C.logCallback) func(string) { - return func(str string) { - C.makeLogCallback(cs(str), lcb) +func _lcb(lcb C.logCallback) func(byte, string) { + return func(l byte, str string) { + C.makeLogCallback(C.uchar(l), cs(str), lcb) } } diff --git a/mkvlib/c/lcb.c b/mkvlib/c/lcb.c index ab66c8c..07a3a8c 100644 --- a/mkvlib/c/lcb.c +++ b/mkvlib/c/lcb.c @@ -1,7 +1,7 @@ #include "lcb.h" -void makeLogCallback(char* s, logCallback lcb) +void makeLogCallback(unsigned char l, char* s, logCallback lcb) { if(lcb) - lcb(s); + lcb(l, s); } \ No newline at end of file diff --git a/mkvlib/c/lcb.h b/mkvlib/c/lcb.h index 8a2e2cc..310bcbf 100644 --- a/mkvlib/c/lcb.h +++ b/mkvlib/c/lcb.h @@ -1,2 +1,2 @@ -typedef void (*logCallback)(char*); -void makeLogCallback(char*, logCallback); \ No newline at end of file +typedef void (*logCallback)(unsigned char, char*); +void makeLogCallback(unsigned char, char*, logCallback); \ No newline at end of file diff --git a/mkvlib/c/sdk.cs b/mkvlib/c/sdk.cs index 9913a1a..87ce7f7 100644 --- a/mkvlib/c/sdk.cs +++ b/mkvlib/c/sdk.cs @@ -85,7 +85,7 @@ public static class mkvlib return css(_Version()); } - public static bool InitInstance(Action lcb) + public static bool InitInstance(Action lcb) { return InitInstance(_lcb(lcb)); } @@ -95,12 +95,12 @@ public static class mkvlib return css(GetMKVInfo(cs(file))); } - public static bool DumpMKV(string file, string output, bool subset, Action lcb) + public static bool DumpMKV(string file, string output, bool subset, Action lcb) { return DumpMKV(cs(file), cs(output), subset, _lcb(lcb)); } - public static bool[] CheckSubset(string file, Action lcb) + public static bool[] CheckSubset(string file, Action lcb) { string json = css(CheckSubset(cs(file), _lcb(lcb))); return JsonSerializer.Deserialize(json); @@ -113,29 +113,29 @@ public static class mkvlib 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 lcb) + public static bool ASSFontSubset(string[] files, string fonts, string output, bool dirSafe, Action lcb) { string _files = JsonSerializer.Serialize(files); return ASSFontSubset(cs(_files), cs(fonts), cs(output), dirSafe, _lcb(lcb)); } - public static string[] QueryFolder(string dir, Action lcb) + public static string[] QueryFolder(string dir, Action lcb) { string result = css(QueryFolder(cs(dir), _lcb(lcb))); return JsonSerializer.Deserialize(result); } - public static bool DumpMKVs(string dir, string output, bool subset, Action lcb) + public static bool DumpMKVs(string dir, string output, bool subset, Action lcb) { 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 lcb) + public static bool CreateMKVs(string vDir, string sDir, string fDir, string tDir, string oDir, string slang, string stitle, bool clean, Action lcb) { return CreateMKVs(cs(vDir), cs(sDir), cs(fDir), cs(tDir), cs(oDir), cs(slang), cs(stitle), clean, _lcb(lcb)); } - public static bool MakeMKVs(string dir, string data, string output, string slang, string stitle, Action lcb) + public static bool MakeMKVs(string dir, string data, string output, string slang, string stitle, Action lcb) { return MakeMKVs(cs(dir), cs(data), cs(output), cs(slang), cs(stitle), _lcb(lcb)); } @@ -145,7 +145,7 @@ public static class mkvlib return CreateBlankOrBurnVideo(t, cs(s), cs(enc), cs(ass), cs(fontdir), cs(output)); } - public static bool CreateTestVideo(string[] asses, string s, string fontdir, string enc, bool burn, Action lcb) + public static bool CreateTestVideo(string[] asses, string s, string fontdir, string enc, bool burn, Action lcb) { string _asses = JsonSerializer.Serialize(asses); return CreateTestVideo(cs(_asses), cs(s), cs(fontdir), cs(enc), burn, _lcb(lcb)); @@ -156,7 +156,7 @@ public static class mkvlib A2P(a2p, apc, cs(pr), cs(pf)); } - public static string[][] GetFontsList(string[] files, string fonts, Action lcb) + public static string[][] GetFontsList(string[] files, string fonts, Action lcb) { string _files = JsonSerializer.Serialize(files); string result = css(GetFontsList(cs(_files), cs(fonts), _lcb(lcb))); @@ -194,25 +194,35 @@ public static class mkvlib return css(GetFontInfo(cs(p))); } - public static string[] CreateFontsCache(string dir, string output, Action lcb) + public static string[] CreateFontsCache(string dir, string output, Action lcb) { string result = css(CreateFontsCache(cs(dir), cs(output), _lcb(lcb))); return JsonSerializer.Deserialize(result); } - public static bool CopyFontsFromCache(string[] asses, string dist, Action lcb) + public static bool CopyFontsFromCache(string[] asses, string dist, Action lcb) { string _files = JsonSerializer.Serialize(asses); return CopyFontsFromCache(cs(_files), cs(dist), _lcb(lcb)); } - delegate void logCallback(IntPtr ptr); - static logCallback _lcb(Action lcb) + delegate void logCallback(byte l, IntPtr ptr); + + public enum LogLevel + { + Info, + Warning, + SWarning, + Error, + Progress + } + + static logCallback _lcb(Action lcb) { - return (ptr) => + return (l, ptr) => { if (lcb != null) - lcb(css(ptr)); + lcb((LogLevel)l, css(ptr)); }; } diff --git a/mkvlib/c/sdk.py b/mkvlib/c/sdk.py index 5fde8d9..b515266 100644 --- a/mkvlib/c/sdk.py +++ b/mkvlib/c/sdk.py @@ -6,10 +6,10 @@ lib = CDLL(libpath) def _lcb(lcb): - @CFUNCTYPE(None, c_char_p) - def logcallback(s): + @CFUNCTYPE(None, c_byte, c_char_p) + def logcallback(l, s): if lcb: - lcb(s.decode()) + lcb(l, s.decode()) return logcallback diff --git a/mkvlib/c/sdk.rs b/mkvlib/c/sdk.rs index dbc4c77..17061b2 100644 --- a/mkvlib/c/sdk.rs +++ b/mkvlib/c/sdk.rs @@ -14,7 +14,8 @@ use { }; pub type c_char = *const raw::c_char; -pub type logCallback = Option; +pub type c_uchar = raw::c_uchar; +pub type logCallback = Option; extern { fn A2P(a2p: bool, apc: bool, pr: c_char, pf: c_char); diff --git a/mkvlib/shared.go b/mkvlib/shared.go index e8b2be4..613f9a9 100644 --- a/mkvlib/shared.go +++ b/mkvlib/shared.go @@ -16,14 +16,14 @@ const libVer = "v2.1.5" const LibFName = libName + " " + libVer const ( - LogInfo = iota + LogInfo byte = iota LogWarning LogSWarning LogError LogProgress ) -type logCallback func(int, string) +type logCallback func(byte, string) type processorGetter struct { checked bool @@ -98,7 +98,7 @@ func (self *processorGetter) GetProcessorInstance() *mkvProcessor { return nil } -func printLog(lcb logCallback, l int, f string, v ...interface{}) { +func printLog(lcb logCallback, l byte, f string, v ...interface{}) { if lcb != nil { lcb(l, fmt.Sprintf(f, v...)) } else { -- cgit v1.2.1