Added FLAC in Ogg packetizer test
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
459a2b1852
commit
3d70bcc15c
|
@ -12,6 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestPacketizeADTS(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func TestPacketizeFLAC(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestPacketizeMP3(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
|
105
audio/packetizer/ogg_flac_test.go
Normal file
105
audio/packetizer/ogg_flac_test.go
Normal file
|
@ -0,0 +1,105 @@
|
|||
//go:build !disable_format_flac && !disable_codec_libflac && cgo
|
||||
|
||||
package packetizer
|
||||
|
||||
import (
|
||||
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/flac"
|
||||
"git.gammaspectra.live/S.O.N.G/Kirika/test"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPacketizeOggFLAC(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
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["ogg"] = true
|
||||
err = flac.NewFormat().Encode(source, writer, options)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
pipePacketizer := NewOggPacketizer(reader)
|
||||
packetCount := 0
|
||||
packetBytes := 0
|
||||
for {
|
||||
packet := pipePacketizer.GetPacket()
|
||||
if packet == nil {
|
||||
break
|
||||
}
|
||||
packetCount++
|
||||
packetBytes += len(packet.GetData())
|
||||
}
|
||||
if packetCount != 1059 {
|
||||
t.Errorf("Wrong Packet Count %d != %d", packetCount, 1059)
|
||||
}
|
||||
if packetBytes < 50000000 {
|
||||
t.Errorf("Wrong Packet Bytes %d < %d", packetBytes, 50000000)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPacketizeOggFLACOffset(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
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["ogg"] = true
|
||||
err = flac.NewFormat().Encode(source, writer, options)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
pipePacketizer := NewOggPacketizer(reader)
|
||||
packetCount := 0
|
||||
packetBytes := 0
|
||||
for {
|
||||
packet := pipePacketizer.GetPacket()
|
||||
if packet == nil {
|
||||
break
|
||||
}
|
||||
packetCount++
|
||||
if offsetablePacket, ok := packet.(OffsetablePacket); ok {
|
||||
packetBytes += len(offsetablePacket.GetDataOffset(1000))
|
||||
}
|
||||
}
|
||||
if packetCount != 1059 {
|
||||
t.Errorf("Wrong Packet Count %d != %d", packetCount, 1059)
|
||||
}
|
||||
if packetBytes < 50000000 {
|
||||
t.Errorf("Wrong Packet Bytes %d < %d", packetBytes, 50000000)
|
||||
}
|
||||
}
|
|
@ -11,7 +11,8 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestPacketizeOgg(t *testing.T) {
|
||||
func TestPacketizeOpusOgg(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -54,7 +55,8 @@ func TestPacketizeOgg(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPacketizeOggOffset(t *testing.T) {
|
||||
func TestPacketizeOggOpusOffset(t *testing.T) {
|
||||
t.Parallel()
|
||||
fp, err := os.Open(test.TestSingleSample24)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
@ -94,7 +96,7 @@ func TestPacketizeOggOffset(t *testing.T) {
|
|||
if packetCount != 395 {
|
||||
t.Errorf("Wrong Packet Count %d != %d", packetCount, 395)
|
||||
}
|
||||
if packetBytes != 5962688 {
|
||||
t.Errorf("Wrong Packet Bytes %d != %d", packetBytes, 5962688)
|
||||
if packetBytes < 5000000 {
|
||||
t.Errorf("Wrong Packet Bytes %d < %d", packetBytes, 5000000)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue