Files
gortsplib/pkg/codecaac/mpeg4audioconfig_test.go
2021-03-26 18:40:39 +01:00

62 lines
1.1 KiB
Go

package codecaac
import (
"testing"
"github.com/stretchr/testify/require"
)
var configCases = []struct {
name string
enc []byte
dec MPEG4AudioConfig
}{
{
name: "aac-lc 44.1khz mono",
enc: []byte{0x12, 0x08, 0x56, 0xe5, 0x00},
dec: MPEG4AudioConfig{
Type: MPEG4AudioTypeAACLC,
SampleRate: 44100,
ChannelCount: 1,
},
},
{
name: "aac-lc 48khz stereo",
enc: []byte{17, 144},
dec: MPEG4AudioConfig{
Type: MPEG4AudioTypeAACLC,
SampleRate: 48000,
ChannelCount: 2,
},
},
{
name: "aac-lc 96khz stereo",
enc: []byte{0x10, 0x10, 0x56, 0xE5, 0x00},
dec: MPEG4AudioConfig{
Type: MPEG4AudioTypeAACLC,
SampleRate: 96000,
ChannelCount: 2,
},
},
{
name: "aac-lc 44.1khz 5.1",
enc: []byte{0x12, 0x30},
dec: MPEG4AudioConfig{
Type: MPEG4AudioTypeAACLC,
SampleRate: 44100,
ChannelCount: 6,
},
},
}
func TestConfigDecode(t *testing.T) {
for _, ca := range configCases {
t.Run(ca.name, func(t *testing.T) {
var dec MPEG4AudioConfig
err := dec.Decode(ca.enc)
require.NoError(t, err)
require.Equal(t, ca.dec, dec)
})
}
}