go-fdkaac/fdkaac/version.go

90 lines
2.4 KiB
Go

// 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
}