feat: return unsafe pointer instead of raw C struct (#54)

This commit is contained in:
l0rem1psum
2024-03-18 15:43:35 +08:00
committed by GitHub
parent 7543fa0443
commit 91fcb0b829
2 changed files with 4 additions and 3 deletions

View File

@@ -214,6 +214,6 @@ func (f *Frame) MoveRef(src *Frame) {
C.av_frame_move_ref(f.c, src.c) C.av_frame_move_ref(f.c, src.c)
} }
func (f *Frame) UnsafeTypedPointer() *C.struct_AVFrame { func (f *Frame) UnsafePointer() unsafe.Pointer {
return f.c return unsafe.Pointer(f.c)
} }

View File

@@ -3,6 +3,7 @@ package astiav
import ( import (
"bytes" "bytes"
"testing" "testing"
"unsafe"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@@ -12,7 +13,7 @@ func TestFrame(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, [8]int{384, 192, 192, 0, 0, 0, 0, 0}, f1.Linesize()) require.Equal(t, [8]int{384, 192, 192, 0, 0, 0, 0, 0}, f1.Linesize())
require.Equal(t, int64(60928), f1.PktDts()) require.Equal(t, int64(60928), f1.PktDts())
require.Equal(t, f1.c, f1.UnsafeTypedPointer()) require.Equal(t, unsafe.Pointer(f1.c), f1.UnsafePointer())
f2 := AllocFrame() f2 := AllocFrame()
require.NotNil(t, f2) require.NotNil(t, f2)