summaryrefslogtreecommitdiff
path: root/mkvlib
diff options
context:
space:
mode:
authorb5f0d6c3 <[email protected]>2021-10-20 20:59:10 +0800
committerb5f0d6c3 <[email protected]>2021-10-20 20:59:10 +0800
commit30d889aeb31a085bce485560830bef5e49e3f948 (patch)
tree0c388011580a36438056694c389111b229a23280 /mkvlib
parent9c07e4193af9c8e121bc5bf242b63b0540f9e108 (diff)
update mkvlib:new c-exports and sdk.py
Diffstat (limited to 'mkvlib')
-rw-r--r--mkvlib/c/exports.go19
-rw-r--r--mkvlib/c/lcb.c6
-rw-r--r--mkvlib/c/sdk.py21
3 files changed, 32 insertions, 14 deletions
diff --git a/mkvlib/c/exports.go b/mkvlib/c/exports.go
index 38cde1a..6a04665 100644
--- a/mkvlib/c/exports.go
+++ b/mkvlib/c/exports.go
@@ -7,7 +7,7 @@ import (
"github.com/KurenaiRyu/MkvAutoSubset/mkvlib"
)
-var processor = mkvlib.GetProcessorGetterInstance()
+var getter = mkvlib.GetProcessorGetterInstance()
func _lcb(lcb C.logCallback) func(string) {
return func(str string) {
@@ -15,9 +15,14 @@ func _lcb(lcb C.logCallback) func(string) {
}
}
+//export InitInstance
+func InitInstance(lcb C.logCallback) bool {
+ return getter.InitProcessorInstance(_lcb(lcb))
+}
+
//export CheckInstance
func CheckInstance() bool {
- return processor.GetProcessorInstance() != nil
+ return getter.GetProcessorInstance() != nil
}
//export GetMKVInfo
@@ -25,7 +30,7 @@ func GetMKVInfo(file *C.char) *C.char {
if !CheckInstance() {
return cs("")
}
- obj := processor.GetProcessorInstance().GetMKVInfo(gs(file))
+ obj := getter.GetProcessorInstance().GetMKVInfo(gs(file))
data, _ := json.Marshal(obj)
return cs(string(data))
}
@@ -35,7 +40,7 @@ func DumpMKV(file, output *C.char, subset bool, lcb C.logCallback) bool {
if !CheckInstance() {
return false
}
- return processor.GetProcessorInstance().DumpMKV(gs(file), gs(output), subset, _lcb(lcb))
+ return getter.GetProcessorInstance().DumpMKV(gs(file), gs(output), subset, _lcb(lcb))
}
type checkSubset_R struct {
@@ -48,7 +53,7 @@ func CheckSubset(file *C.char, lcb C.logCallback) *C.char {
if !CheckInstance() {
return cs("")
}
- a, b := processor.GetProcessorInstance().CheckSubset(gs(file), _lcb(lcb))
+ a, b := getter.GetProcessorInstance().CheckSubset(gs(file), _lcb(lcb))
data, _ := json.Marshal(checkSubset_R{a, b})
return cs(string(data))
}
@@ -66,7 +71,7 @@ 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 processor.GetProcessorInstance().CreateMKV(gs(file), _tracks, _attachments, gs(output), gs(slang), gs(stitle), clean)
+ return getter.GetProcessorInstance().CreateMKV(gs(file), _tracks, _attachments, gs(output), gs(slang), gs(stitle), clean)
}
}
return false
@@ -80,7 +85,7 @@ func ASSFontSubset(files, fonts, output *C.char, dirSafe bool, lcb C.logCallback
obj := make([]string, 0)
if json.Unmarshal([]byte(gs(files)), &obj) == nil {
_files := obj
- return processor.GetProcessorInstance().ASSFontSubset(_files, gs(fonts), gs(output), dirSafe, _lcb(lcb))
+ return getter.GetProcessorInstance().ASSFontSubset(_files, gs(fonts), gs(output), dirSafe, _lcb(lcb))
}
return false
}
diff --git a/mkvlib/c/lcb.c b/mkvlib/c/lcb.c
index ffb8439..ab66c8c 100644
--- a/mkvlib/c/lcb.c
+++ b/mkvlib/c/lcb.c
@@ -1,3 +1,7 @@
#include "lcb.h"
-void makeLogCallback(char* s, logCallback lcb){ lcb(s); } \ No newline at end of file
+void makeLogCallback(char* s, logCallback lcb)
+{
+ if(lcb)
+ lcb(s);
+} \ No newline at end of file
diff --git a/mkvlib/c/sdk.py b/mkvlib/c/sdk.py
index a48a55e..45d2ba3 100644
--- a/mkvlib/c/sdk.py
+++ b/mkvlib/c/sdk.py
@@ -4,6 +4,14 @@ from json import *
libpath="./mkvlib.so"
lib=CDLL(libpath)
+@CFUNCTYPE(None, c_char_p)
+def _lcb(s):
+ print(s.decode())
+
+def initInstance(lcb):
+ call=lib.InitInstance
+ return call(lcb)
+
def checkInstance():
call=lib.CheckInstance
return call()
@@ -13,14 +21,14 @@ def getMKVInfo(file):
call.restype=c_char_p
return call(file.encode())
-def dumpMKV(file,output,subset,dirSafe):
+def dumpMKV(file,output,subset,dirSafe,lcb):
call=lib.DumpMKV
- return call(file.encode(),output.encode(),subset,dirSafe)
+ return call(file.encode(),output.encode(),subset,dirSafe,lcb)
-def checkSubset(file):
+def checkSubset(file,lcb):
call=lib.CheckSubset
call.restype=c_char_p
- return call(file.encode())
+ return call(file.encode(),lcb)
def createMKV(file,tracks,attachments,output,slang,stitle,clean):
call=lib.CreateMKV
@@ -28,8 +36,9 @@ def createMKV(file,tracks,attachments,output,slang,stitle,clean):
_attachments=dumps(attachments)
return call(file.encode(),_tracks.encode(),_attachments.encode(),output.encode(),slang.encode(),stitle.encode(),clean)
-def assFontSubset(files,fonts,output,dirSafe):
+def assFontSubset(files,fonts,output,dirSafe,lcb):
call=lib.ASSFontSubset
_files=dumps(files)
- return call(_files.encode(),fonts.encode(),output.encode(),dirSafe)
+ return call(_files.encode(),fonts.encode(),output.encode(),dirSafe,lcb)
+print(initInstance(None)) \ No newline at end of file