Upgrade github.com/edgeware/mp4ff to github.com/Eyevinn/mp4ff
This commit is contained in:
parent
d0b3bfe57e
commit
7bab2d4f93
|
@ -1,6 +1,7 @@
|
|||
package go_alac
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -29,13 +30,30 @@ func TestEncode(t *testing.T) {
|
|||
}
|
||||
defer o.Close()
|
||||
|
||||
writeTestCase := func(n int, cookie []byte, data []byte) {
|
||||
out, err := os.Create(fmt.Sprintf("/home/shoghicp/radio/alac_afl/test/packets_%d.alac", n))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer out.Close()
|
||||
out.Write(cookie)
|
||||
out.Write(data)
|
||||
}
|
||||
|
||||
encoder := NewFrameEncoder(44100, 2, 16, false)
|
||||
o.Write(encoder.GetMagicCookie())
|
||||
packetSize := encoder.GetInputSize()
|
||||
packets := 0
|
||||
for len(data) > packetSize {
|
||||
resultPacket := encoder.WritePacket(data[:packetSize])
|
||||
o.Write(resultPacket)
|
||||
data = data[packetSize:]
|
||||
|
||||
writeTestCase(packets, encoder.GetMagicCookie(), resultPacket)
|
||||
packets++
|
||||
}
|
||||
return
|
||||
|
||||
if len(data) > 0 {
|
||||
resultPacket := encoder.WritePacket(data)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -2,4 +2,4 @@ module git.gammaspectra.live/S.O.N.G/go-alac
|
|||
|
||||
go 1.18
|
||||
|
||||
require github.com/edgeware/mp4ff v0.27.0
|
||||
require github.com/Eyevinn/mp4ff v0.33.2
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1,4 +1,4 @@
|
|||
github.com/edgeware/mp4ff v0.27.0 h1:Lv773H6c4pUt3Zj9z44TOICv6fjd6gKzi1sVl8GbcYE=
|
||||
github.com/edgeware/mp4ff v0.27.0/go.mod h1:6VHE5CTkpDseIg775+rh8BfnTvqjMnVbz5EDU4QwSdc=
|
||||
github.com/go-test/deep v1.0.6 h1:UHSEyLZUwX9Qoi99vVwvewiMC8mM2bf7XEM2nqvzEn8=
|
||||
github.com/go-test/deep v1.0.6/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
|
||||
github.com/Eyevinn/mp4ff v0.33.2 h1:6b4OCWyBQim+VrL3bNYkqxumnqGdJEGnls2JBMWvKLs=
|
||||
github.com/Eyevinn/mp4ff v0.33.2/go.mod h1:w/6GSa5ghZ1VavzJK6McQ2/flx8mKtcrKDr11SsEweA=
|
||||
github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM=
|
||||
github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=
|
||||
|
|
26
mp4.go
26
mp4.go
|
@ -2,8 +2,8 @@ package go_alac
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/edgeware/mp4ff/bits"
|
||||
"github.com/edgeware/mp4ff/mp4"
|
||||
"github.com/Eyevinn/mp4ff/bits"
|
||||
"github.com/Eyevinn/mp4ff/mp4"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
@ -21,21 +21,21 @@ type FormatEncoder struct {
|
|||
seqNumber uint32
|
||||
}
|
||||
|
||||
type alacBox struct {
|
||||
cookie []byte
|
||||
type AlacBox struct {
|
||||
Cookie []byte
|
||||
}
|
||||
|
||||
func (b *alacBox) Type() string {
|
||||
func (b *AlacBox) Type() string {
|
||||
return "alac"
|
||||
}
|
||||
|
||||
// Size - calculated size of box
|
||||
func (b *alacBox) Size() uint64 {
|
||||
return uint64(12 + len(b.cookie))
|
||||
func (b *AlacBox) Size() uint64 {
|
||||
return uint64(12 + len(b.Cookie))
|
||||
}
|
||||
|
||||
// Encode - write box to w
|
||||
func (b *alacBox) Encode(w io.Writer) error {
|
||||
func (b *AlacBox) Encode(w io.Writer) error {
|
||||
sw := bits.NewFixedSliceWriter(int(b.Size()))
|
||||
err := b.EncodeSW(sw)
|
||||
if err != nil {
|
||||
|
@ -45,17 +45,17 @@ func (b *alacBox) Encode(w io.Writer) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (b *alacBox) EncodeSW(sw bits.SliceWriter) error {
|
||||
func (b *AlacBox) EncodeSW(sw bits.SliceWriter) error {
|
||||
err := mp4.EncodeHeaderSW(b, sw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sw.WriteUint32(0) //version
|
||||
sw.WriteBytes(b.cookie)
|
||||
sw.WriteBytes(b.Cookie)
|
||||
return sw.AccError()
|
||||
}
|
||||
|
||||
func (b *alacBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error {
|
||||
func (b *AlacBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -81,8 +81,8 @@ func NewFormatEncoder(writer io.Writer, sampleRate, channels, bitDepth int, fast
|
|||
stsd := trak.Mdia.Minf.Stbl.Stsd
|
||||
|
||||
//TODO: this does not work with 96kHz freq etc.
|
||||
mp4a := mp4.CreateAudioSampleEntryBox("alac", uint16(channels), uint16(bitDepth), uint16(sampleRate), &alacBox{
|
||||
cookie: e.encoder.GetMagicCookie(),
|
||||
mp4a := mp4.CreateAudioSampleEntryBox("alac", uint16(channels), uint16(bitDepth), uint16(sampleRate), &AlacBox{
|
||||
Cookie: e.encoder.GetMagicCookie(),
|
||||
})
|
||||
stsd.AddChild(mp4a)
|
||||
|
||||
|
|
Loading…
Reference in New Issue