From a3a029b758a4366687733a3739d5d009ea7697a5 Mon Sep 17 00:00:00 2001 From: l0rem1psum Date: Tue, 12 Mar 2024 01:39:13 +0000 Subject: [PATCH] feat: add setter and getter for extra_hw_frames --- codec_context.go | 8 ++++++++ codec_context_test.go | 2 ++ 2 files changed, 10 insertions(+) diff --git a/codec_context.go b/codec_context.go index 556e82e..d58dc20 100644 --- a/codec_context.go +++ b/codec_context.go @@ -314,6 +314,14 @@ func (cc *CodecContext) SetHardwareDeviceContext(hdc *HardwareDeviceContext) { } } +func (cc *CodecContext) ExtraHwFrames() int { + return int(cc.c.extra_hw_frames) +} + +func (cc *CodecContext) SetExtraHardwareFrames(n int) { + cc.c.extra_hw_frames = C.int(n) +} + type CodecContextPixelFormatCallback func(pfs []PixelFormat) PixelFormat var ( diff --git a/codec_context_test.go b/codec_context_test.go index b9badb0..e639dd0 100644 --- a/codec_context_test.go +++ b/codec_context_test.go @@ -97,6 +97,7 @@ func TestCodecContext(t *testing.T) { cc4.SetThreadType(ThreadTypeSlice) cc4.SetTimeBase(NewRational(15, 1)) cc4.SetWidth(16) + cc4.SetExtraHardwareFrames(4) require.Equal(t, int64(1), cc4.BitRate()) require.True(t, cc4.ChannelLayout().Equal(ChannelLayout21)) require.Equal(t, 3, cc4.Channels()) @@ -115,6 +116,7 @@ func TestCodecContext(t *testing.T) { require.Equal(t, ThreadTypeSlice, cc4.ThreadType()) require.Equal(t, NewRational(15, 1), cc4.TimeBase()) require.Equal(t, 16, cc4.Width()) + require.Equal(t, 4, cc4.ExtraHwFrames()) // TODO Test ReceivePacket // TODO Test SendPacket