summaryrefslogtreecommitdiff
path: root/mkvlib
diff options
context:
space:
mode:
authorb5f0d6c3 <[email protected]>2021-10-21 11:46:20 +0800
committerb5f0d6c3 <[email protected]>2021-10-21 11:46:20 +0800
commit2ad3253d26bfadb8452c82e515eedc60b308cbe9 (patch)
tree960c460babef805e0f3476573f6daa81cbd9e580 /mkvlib
parent3f3a3cdaecbe6f212c1d405e38525752cc3132a4 (diff)
update mkvlib:new c-exports and sdk.py
Diffstat (limited to 'mkvlib')
-rw-r--r--mkvlib/c/exports.go53
-rw-r--r--mkvlib/c/sdk.py21
-rw-r--r--mkvlib/mkv.go6
-rw-r--r--mkvlib/shared.go2
4 files changed, 64 insertions, 18 deletions
diff --git a/mkvlib/c/exports.go b/mkvlib/c/exports.go
index 6a04665..bf277a4 100644
--- a/mkvlib/c/exports.go
+++ b/mkvlib/c/exports.go
@@ -9,6 +9,10 @@ import (
var getter = mkvlib.GetProcessorGetterInstance()
+func checkInstance() bool {
+ return getter.GetProcessorInstance() != nil
+}
+
func _lcb(lcb C.logCallback) func(string) {
return func(str string) {
C.makeLogCallback(cs(str), lcb)
@@ -20,14 +24,9 @@ func InitInstance(lcb C.logCallback) bool {
return getter.InitProcessorInstance(_lcb(lcb))
}
-//export CheckInstance
-func CheckInstance() bool {
- return getter.GetProcessorInstance() != nil
-}
-
//export GetMKVInfo
func GetMKVInfo(file *C.char) *C.char {
- if !CheckInstance() {
+ if !checkInstance() {
return cs("")
}
obj := getter.GetProcessorInstance().GetMKVInfo(gs(file))
@@ -37,7 +36,7 @@ func GetMKVInfo(file *C.char) *C.char {
//export DumpMKV
func DumpMKV(file, output *C.char, subset bool, lcb C.logCallback) bool {
- if !CheckInstance() {
+ if !checkInstance() {
return false
}
return getter.GetProcessorInstance().DumpMKV(gs(file), gs(output), subset, _lcb(lcb))
@@ -50,7 +49,7 @@ type checkSubset_R struct {
//export CheckSubset
func CheckSubset(file *C.char, lcb C.logCallback) *C.char {
- if !CheckInstance() {
+ if !checkInstance() {
return cs("")
}
a, b := getter.GetProcessorInstance().CheckSubset(gs(file), _lcb(lcb))
@@ -60,7 +59,7 @@ func CheckSubset(file *C.char, lcb C.logCallback) *C.char {
//export CreateMKV
func CreateMKV(file, tracks, attachments, output, slang, stitle *C.char, clean bool) bool {
- if !CheckInstance() {
+ if !checkInstance() {
return false
}
a := make([]string, 0)
@@ -79,7 +78,7 @@ func CreateMKV(file, tracks, attachments, output, slang, stitle *C.char, clean b
//export ASSFontSubset
func ASSFontSubset(files, fonts, output *C.char, dirSafe bool, lcb C.logCallback) bool {
- if !CheckInstance() {
+ if !checkInstance() {
return false
}
obj := make([]string, 0)
@@ -90,6 +89,40 @@ func ASSFontSubset(files, fonts, output *C.char, dirSafe bool, lcb C.logCallback
return false
}
+//export QueryFolder
+func QueryFolder(dir *C.char, lcb C.logCallback) *C.char {
+ if !checkInstance() {
+ return cs("")
+ }
+ list := getter.GetProcessorInstance().QueryFolder(gs(dir), _lcb(lcb))
+ data, _ := json.Marshal(list)
+ return cs(string(data))
+}
+
+//export DumpMKVs
+func DumpMKVs(dir, output *C.char, subset bool, lcb C.logCallback) bool {
+ if !checkInstance() {
+ return false
+ }
+ return getter.GetProcessorInstance().DumpMKVs(gs(dir), gs(output), subset, _lcb(lcb))
+}
+
+//export CreateMKVs
+func CreateMKVs(vDir, sDir, fDir, tDir, oDir, slang, stitle *C.char, clean bool, lcb C.logCallback) bool {
+ if !checkInstance() {
+ return false
+ }
+ return getter.GetProcessorInstance().CreateMKVs(gs(vDir), gs(sDir), gs(fDir), gs(tDir), gs(oDir), gs(slang), gs(stitle), clean, _lcb(lcb))
+}
+
+//export MakeMKVs
+func MakeMKVs(dir, data, output, slang, stitle *C.char, lcb C.logCallback) bool {
+ if !checkInstance() {
+ return false
+ }
+ return getter.GetProcessorInstance().MakeMKVs(gs(dir), gs(data), gs(output), gs(slang), gs(stitle), _lcb(lcb))
+}
+
func cs(gs string) *C.char {
return C.CString(gs)
}
diff --git a/mkvlib/c/sdk.py b/mkvlib/c/sdk.py
index 3493a26..cc8e6b2 100644
--- a/mkvlib/c/sdk.py
+++ b/mkvlib/c/sdk.py
@@ -12,10 +12,6 @@ def initInstance(lcb):
call=lib.InitInstance
return call(lcb)
-def checkInstance():
- call=lib.CheckInstance
- return call()
-
def getMKVInfo(file):
call=lib.GetMKVInfo
call.restype=c_char_p
@@ -40,3 +36,20 @@ def assFontSubset(files,fonts,output,dirSafe,lcb):
call=lib.ASSFontSubset
_files=dumps(files)
return call(_files.encode(),fonts.encode(),output.encode(),dirSafe,lcb)
+
+def queryFolder(dir,lcb):
+ call=lib.QueryFolder
+ call.restype=c_char_p
+ return call(dir.encode(),lcb)
+
+def dumpMKVs(dir,output,subset,lcb):
+ call=lib.DumpMKVs
+ return call(dir.encode(),output.encode(),subset,lcb)
+
+def createMKVs(vDir,sDir,fDir,tDir,oDir,slang,stitle, clean ,lcb):
+ call=lib.CreateMKVs
+ return call(vDir.encode(),sDir.encode(),fDir.encode(),tDir.encode(),oDir.encode(),slang.encode(),stitle.encode(),clean,lcb)
+
+def makeMKVs(dir,data,output,slang,stitle,lcb):
+ call=lib.MakeMKVs
+ return call(dir.encode(),data.encode(),output.encode(),slang.encode(),stitle.encode(),lcb)
diff --git a/mkvlib/mkv.go b/mkvlib/mkv.go
index d1aa2c3..32230d1 100644
--- a/mkvlib/mkv.go
+++ b/mkvlib/mkv.go
@@ -208,7 +208,7 @@ func (self *mkvProcessor) QueryFolder(dir string, lcb logCallback) []string {
return lines
}
-func (self *mkvProcessor) CreateMKVs(vDir, sDir, fDir, tDir, oDir string, slang, stitle string, clean bool, lcb logCallback) bool {
+func (self *mkvProcessor) CreateMKVs(vDir, sDir, fDir, tDir, oDir, slang, stitle string, clean bool, lcb logCallback) bool {
ec := 0
if tDir == "" {
tDir = os.TempDir()
@@ -258,7 +258,7 @@ func (self *mkvProcessor) CreateMKVs(vDir, sDir, fDir, tDir, oDir string, slang,
return ec == 0
}
-func (self *mkvProcessor) MakeMKVs(dir, data, output, slang, sttlte string, lcb logCallback) bool {
+func (self *mkvProcessor) MakeMKVs(dir, data, output, slang, stitle string, lcb logCallback) bool {
ec := 0
files := findMKVs(dir)
l := len(files)
@@ -272,7 +272,7 @@ func (self *mkvProcessor) MakeMKVs(dir, data, output, slang, sttlte string, lcb
attachments := findFonts(_p)
tracks := append(subs, asses...)
fn := path.Join(output, d, n)
- if !self.CreateMKV(item, tracks, attachments, fn, slang, sttlte, true) {
+ if !self.CreateMKV(item, tracks, attachments, fn, slang, stitle, true) {
ec++
printLog(lcb, `Faild to make the mkv file: "%s".`, item)
}
diff --git a/mkvlib/shared.go b/mkvlib/shared.go
index 397e667..3a8aa7c 100644
--- a/mkvlib/shared.go
+++ b/mkvlib/shared.go
@@ -11,7 +11,7 @@ import (
)
const libName = "mkvlib"
-const libVer = "v1.1.0"
+const libVer = "v1.1.1"
const LibFName = libName + " " + libVer