Skip to content

Commit

Permalink
Expose pointer to underlying AVCodecContext (#95)
Browse files Browse the repository at this point in the history
* feat: expose pointer to underlying C object

* feat: add ut
  • Loading branch information
l0rem1psum authored Nov 5, 2024
1 parent bc14852 commit 0d36224
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions codec_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ func (cc *CodecContext) SetExtraHardwareFrames(n int) {
cc.c.extra_hw_frames = C.int(n)
}

func (cc *CodecContext) UnsafePointer() unsafe.Pointer {
return unsafe.Pointer(cc.c)
}

type CodecContextPixelFormatCallback func(pfs []PixelFormat) PixelFormat

var (
Expand Down
2 changes: 2 additions & 0 deletions codec_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package astiav

import (
"testing"
"unsafe"

"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -40,6 +41,7 @@ func TestCodecContext(t *testing.T) {
require.Equal(t, 1, cc1.ThreadCount())
require.Equal(t, ThreadType(3), cc1.ThreadType())
require.Equal(t, 320, cc1.Width())
require.Equal(t, unsafe.Pointer(cc1.c), cc1.UnsafePointer())
cl := cc1.Class()
require.NotNil(t, cl)
require.Equal(t, "AVCodecContext", cl.Name())
Expand Down

0 comments on commit 0d36224

Please sign in to comment.