33 lines
766 B
Go
33 lines
766 B
Go
package riff
|
|
|
|
import (
|
|
"errors"
|
|
"io"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
var (
|
|
RiffID = [4]byte{'R', 'I', 'F', 'F'}
|
|
FmtID = [4]byte{'f', 'm', 't', ' '}
|
|
junkID = [4]byte{'J', 'U', 'N', 'K'}
|
|
WavFormatID = [4]byte{'W', 'A', 'V', 'E'}
|
|
DataFormatID = [4]byte{'d', 'a', 't', 'a'}
|
|
rmiFormatID = [4]byte{'R', 'M', 'I', 'D'}
|
|
aviFormatID = [4]byte{'A', 'V', 'I', ' '}
|
|
ErrFmtNotSupported = errors.New("format not supported")
|
|
ErrUnexpectedData = errors.New("unexpected data content")
|
|
)
|
|
|
|
func New(r io.Reader) *Parser {
|
|
return &Parser{r: r, Wg: &sync.WaitGroup{}}
|
|
}
|
|
|
|
func Duration(r io.Reader) (time.Duration, error) {
|
|
c := New(r)
|
|
if err := c.ParseHeaders(); err != nil {
|
|
return 0, err
|
|
}
|
|
return c.Duration()
|
|
}
|