mirror of
https://github.com/asticode/go-astiav.git
synced 2025-10-17 05:31:25 +08:00
Added missing audio setters to codec parameters
This commit is contained in:
@@ -32,10 +32,18 @@ func (cp *CodecParameters) ChannelLayout() ChannelLayout {
|
||||
return ChannelLayout(cp.c.channel_layout)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) SetChannelLayout(l ChannelLayout) {
|
||||
cp.c.channel_layout = C.uint64_t(l)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) Channels() int {
|
||||
return int(cp.c.channels)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) SetChannels(c int) {
|
||||
cp.c.channels = C.int(c)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) CodecID() CodecID {
|
||||
return CodecID(cp.c.codec_id)
|
||||
}
|
||||
@@ -124,10 +132,18 @@ func (cp *CodecParameters) SampleFormat() SampleFormat {
|
||||
return SampleFormat(cp.c.format)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) SetSampleFormat(f SampleFormat) {
|
||||
cp.c.format = C.int(f)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) SampleRate() int {
|
||||
return int(cp.c.sample_rate)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) SetSampleRate(r int) {
|
||||
cp.c.sample_rate = C.int(r)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) Width() int {
|
||||
return int(cp.c.width)
|
||||
}
|
||||
|
@@ -63,6 +63,11 @@ func TestCodecParameters(t *testing.T) {
|
||||
cp6 := astiav.AllocCodecParameters()
|
||||
require.NotNil(t, cp6)
|
||||
defer cp6.Free()
|
||||
cp6.SetChannelLayout(astiav.ChannelLayout21)
|
||||
require.Equal(t, astiav.ChannelLayout21, cp6.ChannelLayout())
|
||||
defer cp6.Free()
|
||||
cp6.SetChannels(3)
|
||||
require.Equal(t, 3, cp6.Channels())
|
||||
cp6.SetCodecID(astiav.CodecIDRawvideo)
|
||||
require.Equal(t, astiav.CodecIDRawvideo, cp6.CodecID())
|
||||
cp6.SetCodecTag(astiav.CodecTag(2))
|
||||
@@ -75,6 +80,10 @@ func TestCodecParameters(t *testing.T) {
|
||||
require.Equal(t, astiav.PixelFormat0Bgr, cp6.PixelFormat())
|
||||
cp6.SetSampleAspectRatio(astiav.NewRational(1, 2))
|
||||
require.Equal(t, astiav.NewRational(1, 2), cp6.SampleAspectRatio())
|
||||
cp6.SetSampleFormat(astiav.SampleFormatDbl)
|
||||
require.Equal(t, astiav.SampleFormatDbl, cp6.SampleFormat())
|
||||
cp6.SetSampleRate(4)
|
||||
require.Equal(t, 4, cp6.SampleRate())
|
||||
cp6.SetWidth(2)
|
||||
require.Equal(t, 2, cp6.Width())
|
||||
}
|
||||
|
Reference in New Issue
Block a user