forked from asticode/go-astiav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codec_test.go
65 lines (58 loc) · 1.91 KB
/
codec_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package astiav_test
import (
"testing"
"github.com/asticode/go-astiav"
"github.com/stretchr/testify/require"
)
func TestCodec(t *testing.T) {
c := astiav.FindDecoder(astiav.CodecIDMp3)
require.NotNil(t, c)
require.Nil(t, c.ChannelLayouts())
require.True(t, c.IsDecoder())
require.False(t, c.IsEncoder())
require.Nil(t, c.PixelFormats())
require.Equal(t, []astiav.SampleFormat{astiav.SampleFormatFltp, astiav.SampleFormatFlt}, c.SampleFormats())
require.Equal(t, "mp3float", c.Name())
require.Equal(t, "mp3float", c.String())
c = astiav.FindDecoderByName("aac")
require.NotNil(t, c)
require.Equal(t, []astiav.ChannelLayout{
astiav.ChannelLayoutMono,
astiav.ChannelLayoutStereo,
astiav.ChannelLayoutSurround,
astiav.ChannelLayout4Point0,
astiav.ChannelLayout5Point0Back,
astiav.ChannelLayout5Point1Back,
astiav.ChannelLayout7Point1WideBack,
}, c.ChannelLayouts())
require.True(t, c.IsDecoder())
require.False(t, c.IsEncoder())
require.Equal(t, []astiav.SampleFormat{astiav.SampleFormatFltp}, c.SampleFormats())
require.Equal(t, "aac", c.Name())
require.Equal(t, "aac", c.String())
c = astiav.FindEncoder(astiav.CodecIDH264)
require.NotNil(t, c)
require.False(t, c.IsDecoder())
require.True(t, c.IsEncoder())
require.Equal(t, []astiav.PixelFormat{
astiav.PixelFormatVideotoolbox,
astiav.PixelFormatNv12,
astiav.PixelFormatYuv420P,
}, c.PixelFormats())
require.Nil(t, c.SampleFormats())
require.Equal(t, "h264_videotoolbox", c.Name())
require.Equal(t, "h264_videotoolbox", c.String())
c = astiav.FindEncoderByName("mjpeg")
require.NotNil(t, c)
require.False(t, c.IsDecoder())
require.True(t, c.IsEncoder())
require.Equal(t, []astiav.PixelFormat{
astiav.PixelFormatYuvj420P,
astiav.PixelFormatYuvj422P,
astiav.PixelFormatYuvj444P,
}, c.PixelFormats())
require.Equal(t, "mjpeg", c.Name())
require.Equal(t, "mjpeg", c.String())
c = astiav.FindDecoderByName("invalid")
require.Nil(t, c)
}