Added version information
This commit is contained in:
parent
ab93196cf1
commit
ffb0aafe2a
89
fdkaac/version.go
Normal file
89
fdkaac/version.go
Normal file
|
@ -0,0 +1,89 @@
|
|||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 winlin
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
package fdkaac
|
||||
|
||||
/*
|
||||
#cgo pkg-config: fdk-aac
|
||||
#include <fdk-aac/aacenc_lib.h>
|
||||
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
ModuleNone = C.FDK_NONE
|
||||
ModuleFdkTools = C.FDK_TOOLS
|
||||
ModuleFdkAACENC = C.FDK_AACENC
|
||||
)
|
||||
|
||||
func GetInfoModules() []C.LIB_INFO {
|
||||
info := make([]C.LIB_INFO, C.FDK_MODULE_LAST)
|
||||
C.FDKinitLibInfo(&info[0])
|
||||
C.aacEncGetLibInfo(&info[0])
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
func GetInfoModule(module C.FDK_MODULE_ID) *C.LIB_INFO {
|
||||
info := GetInfoModules()
|
||||
for i := range info {
|
||||
if info[i].module_id == module {
|
||||
return &info[i]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func EncoderVersion() string {
|
||||
return C.GoString(&GetInfoModule(ModuleFdkAACENC).versionStr[0])
|
||||
}
|
||||
|
||||
func ToolsVersion() string {
|
||||
|
||||
return C.GoString(&GetInfoModule(ModuleFdkTools).versionStr[0])
|
||||
}
|
||||
|
||||
type moduleInformation struct {
|
||||
ModuleId C.FDK_MODULE_ID
|
||||
Title string
|
||||
VersionString string
|
||||
BuildTime string
|
||||
Flags int
|
||||
}
|
||||
|
||||
func GetModules() (result []moduleInformation) {
|
||||
|
||||
for _, info := range GetInfoModules() {
|
||||
if info.module_id == ModuleNone {
|
||||
continue
|
||||
}
|
||||
result = append(result, moduleInformation{
|
||||
ModuleId: info.module_id,
|
||||
Title: C.GoString(info.title),
|
||||
VersionString: C.GoString(&info.versionStr[0]),
|
||||
BuildTime: fmt.Sprintf("%s %s", C.GoString(info.build_date), C.GoString(info.build_time)),
|
||||
Flags: int(info.flags),
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
45
fdkaac/version_test.go
Normal file
45
fdkaac/version_test.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2016 winlin
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
package fdkaac_test
|
||||
|
||||
import (
|
||||
"git.gammaspectra.live/S.O.N.G/go-fdkaac/fdkaac"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVersion(t *testing.T) {
|
||||
if version := fdkaac.EncoderVersion(); version != "" {
|
||||
t.Logf("encoder version: %s", version)
|
||||
} else {
|
||||
t.Fail()
|
||||
}
|
||||
if version := fdkaac.ToolsVersion(); version != "" {
|
||||
t.Logf("tools version: %s", version)
|
||||
} else {
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
for _, info := range fdkaac.GetModules() {
|
||||
t.Logf("%s version: %s", info.Title, info.VersionString)
|
||||
t.Logf("%s build time: %s", info.Title, info.BuildTime)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue