Kirika/audio/packetizer/adts_hev2_test.go
DataHoarder bd069cdf05
Some checks failed
continuous-integration/drone/push Build is failing
General code inspection cleanup
2022-10-03 11:34:56 +02:00

66 lines
1.3 KiB
Go

//go:build !disable_format_aac && !disable_codec_libfdk_aac && cgo
package packetizer
import (
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/aac"
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/flac"
"git.gammaspectra.live/S.O.N.G/Kirika/test"
"git.gammaspectra.live/S.O.N.G/go-fdkaac/fdkaac"
"io"
"os"
"testing"
)
func TestPacketizeADTSHEv2(t *testing.T) {
t.Parallel()
if !fdkaac.EncoderCapabilities().PS {
return
}
fp, err := os.Open(test.SingleSample24)
if err != nil {
t.Error(err)
return
}
defer fp.Close()
source, err := flac.NewFormat().Open(fp)
if err != nil {
t.Error(err)
return
}
reader, writer := io.Pipe()
go func() {
defer writer.Close()
options := make(map[string]interface{})
options["mode"] = "hev2"
options["bitrate"] = 32
err = aac.NewFormat().Encode(source, writer, options)
if err != nil {
t.Error(err)
return
}
}()
pipePacketizer := NewAdtsPacketizer(reader)
packetCount := 0
packetBytes := 0
for {
packet := pipePacketizer.GetPacket()
if packet == nil {
break
}
packetCount++
packetBytes += len(packet.GetData())
}
if packetCount != 8463 {
t.Errorf("Wrong Packet Count %d != %d", packetCount, 8463)
}
if packetBytes < 1400000 {
t.Errorf("Wrong Packet Bytes %d < %d", packetBytes, 1400000)
}
}