diff options
| author | ac79b0c6 <[email protected]> | 2022-06-06 10:13:46 +0800 |
|---|---|---|
| committer | ac79b0c6 <[email protected]> | 2022-06-06 10:13:46 +0800 |
| commit | 765e5e9bd2431b132cd3e6cfffa0df44eb531d05 (patch) | |
| tree | 9ef4be1915ada45108db59809c055ee325cfc9f7 /mkvlib/c | |
| parent | 225fedeef90ac207bbadebcd6444f6e6a0d4dd13 (diff) | |
update sdk
Diffstat (limited to 'mkvlib/c')
| -rw-r--r-- | mkvlib/c/README.md | 3 | ||||
| -rw-r--r-- | mkvlib/c/exports.go | 6 | ||||
| -rw-r--r-- | mkvlib/c/lcb.c | 4 | ||||
| -rw-r--r-- | mkvlib/c/lcb.h | 4 | ||||
| -rw-r--r-- | mkvlib/c/sdk.cs | 42 | ||||
| -rw-r--r-- | mkvlib/c/sdk.py | 6 | ||||
| -rw-r--r-- | mkvlib/c/sdk.rs | 3 |
7 files changed, 40 insertions, 28 deletions
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<string> lcb) + public static bool InitInstance(Action<LogLevel, string> 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<string> lcb) + public static bool DumpMKV(string file, string output, bool subset, Action<LogLevel, string> lcb) { return DumpMKV(cs(file), cs(output), subset, _lcb(lcb)); } - public static bool[] CheckSubset(string file, Action<string> lcb) + public static bool[] CheckSubset(string file, Action<LogLevel, string> lcb) { string json = css(CheckSubset(cs(file), _lcb(lcb))); return JsonSerializer.Deserialize<bool[]>(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<string> lcb) + public static bool ASSFontSubset(string[] files, string fonts, string output, bool dirSafe, Action<LogLevel, string> lcb) { string _files = JsonSerializer.Serialize(files); return ASSFontSubset(cs(_files), cs(fonts), cs(output), dirSafe, _lcb(lcb)); } - public static string[] QueryFolder(string dir, Action<string> lcb) + public static string[] QueryFolder(string dir, Action<LogLevel, string> lcb) { string result = css(QueryFolder(cs(dir), _lcb(lcb))); return JsonSerializer.Deserialize<string[]>(result); } - public static bool DumpMKVs(string dir, string output, bool subset, Action<string> lcb) + public static bool DumpMKVs(string dir, string output, bool subset, Action<LogLevel, string> 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<string> lcb) + public static bool CreateMKVs(string vDir, string sDir, string fDir, string tDir, string oDir, string slang, string stitle, bool clean, Action<LogLevel, string> 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<string> lcb) + public static bool MakeMKVs(string dir, string data, string output, string slang, string stitle, Action<LogLevel, string> 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<string> lcb) + public static bool CreateTestVideo(string[] asses, string s, string fontdir, string enc, bool burn, Action<LogLevel, string> 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<string> lcb) + public static string[][] GetFontsList(string[] files, string fonts, Action<LogLevel, string> 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<string> lcb) + public static string[] CreateFontsCache(string dir, string output, Action<LogLevel, 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) + public static bool CopyFontsFromCache(string[] asses, string dist, Action<LogLevel, 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) + delegate void logCallback(byte l, IntPtr ptr); + + public enum LogLevel + { + Info, + Warning, + SWarning, + Error, + Progress + } + + static logCallback _lcb(Action<LogLevel, string> 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<fn(c_char)>; +pub type c_uchar = raw::c_uchar; +pub type logCallback = Option<fn(c_uchar, c_char)>; extern { fn A2P(a2p: bool, apc: bool, pr: c_char, pf: c_char); |
