diff options
| author | b5f0d6c3 <[email protected]> | 2021-10-20 19:58:44 +0800 |
|---|---|---|
| committer | b5f0d6c3 <[email protected]> | 2021-10-20 19:58:44 +0800 |
| commit | 9d9068cf4a6eb8d8b8f48005a9c6db0dea135c80 (patch) | |
| tree | 0b5359438ae8745cf04e5c36a4f98174fa76e33e /mkvlib/c/exports.go | |
| parent | 4c4bb91ece9ceb8841e45910c9ffa49cd64c9c22 (diff) | |
update mkvlib:add logcallback
Diffstat (limited to 'mkvlib/c/exports.go')
| -rw-r--r-- | mkvlib/c/exports.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/mkvlib/c/exports.go b/mkvlib/c/exports.go index 1f22703..38cde1a 100644 --- a/mkvlib/c/exports.go +++ b/mkvlib/c/exports.go @@ -1,16 +1,23 @@ package main +// #include "lcb.h" +import "C" import ( - "C" "encoding/json" "github.com/KurenaiRyu/MkvAutoSubset/mkvlib" ) -var _instance = mkvlib.GetInstance() +var processor = mkvlib.GetProcessorGetterInstance() + +func _lcb(lcb C.logCallback) func(string) { + return func(str string) { + C.makeLogCallback(cs(str), lcb) + } +} //export CheckInstance func CheckInstance() bool { - return _instance != nil + return processor.GetProcessorInstance() != nil } //export GetMKVInfo @@ -18,17 +25,17 @@ func GetMKVInfo(file *C.char) *C.char { if !CheckInstance() { return cs("") } - obj := _instance.GetMKVInfo(gs(file)) + obj := processor.GetProcessorInstance().GetMKVInfo(gs(file)) data, _ := json.Marshal(obj) return cs(string(data)) } //export DumpMKV -func DumpMKV(file, output *C.char, subset bool) bool { +func DumpMKV(file, output *C.char, subset bool, lcb C.logCallback) bool { if !CheckInstance() { return false } - return _instance.DumpMKV(gs(file), gs(output), subset) + return processor.GetProcessorInstance().DumpMKV(gs(file), gs(output), subset, _lcb(lcb)) } type checkSubset_R struct { @@ -37,11 +44,11 @@ type checkSubset_R struct { } //export CheckSubset -func CheckSubset(file *C.char) *C.char { +func CheckSubset(file *C.char, lcb C.logCallback) *C.char { if !CheckInstance() { return cs("") } - a, b := _instance.CheckSubset(gs(file)) + a, b := processor.GetProcessorInstance().CheckSubset(gs(file), _lcb(lcb)) data, _ := json.Marshal(checkSubset_R{a, b}) return cs(string(data)) } @@ -59,21 +66,21 @@ func CreateMKV(file, tracks, attachments, output, slang, stitle *C.char, clean b err = json.Unmarshal([]byte(gs(attachments)), &b) if err == nil { _attachments := b - return _instance.CreateMKV(gs(file), _tracks, _attachments, gs(output), gs(slang), gs(stitle), clean) + return processor.GetProcessorInstance().CreateMKV(gs(file), _tracks, _attachments, gs(output), gs(slang), gs(stitle), clean) } } return false } //export ASSFontSubset -func ASSFontSubset(files, fonts, output *C.char, dirSafe bool) bool { +func ASSFontSubset(files, fonts, output *C.char, dirSafe bool, lcb C.logCallback) bool { if !CheckInstance() { return false } obj := make([]string, 0) if json.Unmarshal([]byte(gs(files)), &obj) == nil { _files := obj - return _instance.ASSFontSubset(_files, gs(fonts), gs(output), dirSafe) + return processor.GetProcessorInstance().ASSFontSubset(_files, gs(fonts), gs(output), dirSafe, _lcb(lcb)) } return false } |
