feat: create hardware device context with flags (#94)

This commit is contained in:
l0rem1psum
2024-11-05 16:00:41 +08:00
committed by GitHub
parent 0d3622405a
commit cfdc7f196f
3 changed files with 4 additions and 4 deletions

View File

@@ -133,7 +133,7 @@ func main() {
// Create hardware device context // Create hardware device context
var err error var err error
if s.hardwareDeviceContext, err = astiav.CreateHardwareDeviceContext(hardwareDeviceType, *hardwareDeviceName, nil); err != nil { if s.hardwareDeviceContext, err = astiav.CreateHardwareDeviceContext(hardwareDeviceType, *hardwareDeviceName, nil, 0); err != nil {
log.Fatal(fmt.Errorf("main: creating hardware device context failed: %w", err)) log.Fatal(fmt.Errorf("main: creating hardware device context failed: %w", err))
} }

View File

@@ -49,7 +49,7 @@ func main() {
} }
// Create hardware device context // Create hardware device context
hardwareDeviceContext, err := astiav.CreateHardwareDeviceContext(hardwareDeviceType, *hardwareDeviceName, nil) hardwareDeviceContext, err := astiav.CreateHardwareDeviceContext(hardwareDeviceType, *hardwareDeviceName, nil, 0)
if err != nil { if err != nil {
log.Fatal(fmt.Errorf("main: creating hardware device context failed: %w", err)) log.Fatal(fmt.Errorf("main: creating hardware device context failed: %w", err))
} }

View File

@@ -12,7 +12,7 @@ type HardwareDeviceContext struct {
c *C.AVBufferRef c *C.AVBufferRef
} }
func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *Dictionary) (*HardwareDeviceContext, error) { func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *Dictionary, flags int) (*HardwareDeviceContext, error) {
hdc := HardwareDeviceContext{} hdc := HardwareDeviceContext{}
deviceC := (*C.char)(nil) deviceC := (*C.char)(nil)
if device != "" { if device != "" {
@@ -23,7 +23,7 @@ func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *D
if options != nil { if options != nil {
optionsC = options.c optionsC = options.c
} }
if err := newError(C.av_hwdevice_ctx_create(&hdc.c, (C.enum_AVHWDeviceType)(t), deviceC, optionsC, 0)); err != nil { if err := newError(C.av_hwdevice_ctx_create(&hdc.c, (C.enum_AVHWDeviceType)(t), deviceC, optionsC, C.int(flags))); err != nil {
return nil, err return nil, err
} }
return &hdc, nil return &hdc, nil