From 3476989256c937d5e88ca12ccb8bec41b5effaef Mon Sep 17 00:00:00 2001 From: l0rem1psum Date: Mon, 5 Feb 2024 09:40:44 +0000 Subject: [PATCH 1/2] feat: add method to expose underlying Frame C struct --- frame.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frame.go b/frame.go index ddd04e7..b0908b9 100644 --- a/frame.go +++ b/frame.go @@ -213,3 +213,7 @@ func (f *Frame) Unref() { func (f *Frame) MoveRef(src *Frame) { C.av_frame_move_ref(f.c, src.c) } + +func (f *Frame) Inner() unsafe.Pointer { + return unsafe.Pointer(f.c) +} From 1b30d4f76362ebf10b248e9ea3ac28664251b982 Mon Sep 17 00:00:00 2001 From: l0rem1psum Date: Wed, 7 Feb 2024 16:06:35 +0000 Subject: [PATCH 2/2] feat(frame): rename method name and add unit test for C struct exposure function --- frame.go | 4 ++-- frame_test.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frame.go b/frame.go index b0908b9..289041c 100644 --- a/frame.go +++ b/frame.go @@ -214,6 +214,6 @@ func (f *Frame) MoveRef(src *Frame) { C.av_frame_move_ref(f.c, src.c) } -func (f *Frame) Inner() unsafe.Pointer { - return unsafe.Pointer(f.c) +func (f *Frame) UnsafePointer() *C.struct_AVFrame { + return f.c } diff --git a/frame_test.go b/frame_test.go index c6eaed7..a4f2fe9 100644 --- a/frame_test.go +++ b/frame_test.go @@ -13,6 +13,7 @@ func TestFrame(t *testing.T) { require.NoError(t, err) require.Equal(t, [8]int{384, 192, 192, 0, 0, 0, 0, 0}, f1.Linesize()) require.Equal(t, int64(60928), f1.PktDts()) + require.NotNil(t, f1.UnsafePointer()) f2 := astiav.AllocFrame() require.NotNil(t, f2)