Enhance Codec Iteration and Checking of HardwareConfigMethodFlags (#40)

* Add IterateCodecs, Add codec.HasHardwareConfigMethodFlag

* Remove HasHardwareConfigMethodFlag test because git worklow does not support hw

HasHardwareConfigMethodFlag is tested on my local device but does not work in git

* Review Changes

Remove unused arg in HardwareConfigs
Add mehtod to get all codecs
Update test

* Remove codecporcessor type
This commit is contained in:
Cacsjep
2024-01-30 11:06:22 +01:00
committed by GitHub
parent ec3fe01e4d
commit 063a68b631
3 changed files with 30 additions and 2 deletions

View File

@@ -28,6 +28,10 @@ func (c *Codec) String() string {
return c.Name()
}
func (c *Codec) ID() CodecID {
return CodecID(c.c.id)
}
func (c *Codec) ChannelLayouts() (o []ChannelLayout) {
if c.c.ch_layouts == nil {
return nil
@@ -101,7 +105,7 @@ func FindEncoderByName(n string) *Codec {
return newCodecFromC(C.avcodec_find_encoder_by_name(cn))
}
func (c *Codec) HardwareConfigs(dt HardwareDeviceType) (configs []CodecHardwareConfig) {
func (c *Codec) HardwareConfigs() (configs []CodecHardwareConfig) {
var i int
for {
config := C.avcodec_get_hw_config(c.c, C.int(i))
@@ -113,3 +117,18 @@ func (c *Codec) HardwareConfigs(dt HardwareDeviceType) (configs []CodecHardwareC
}
return
}
func Codecs() []*Codec {
var opq *C.void = nil
var codecs []*Codec
for {
c := C.av_codec_iterate((*unsafe.Pointer)(unsafe.Pointer(&opq)))
if c == nil {
break
}
codec := newCodecFromC(c)
codecs = append(codecs, codec)
}
return codecs
}