mirror of https://bitbucket.org/ausocean/av.git
av: fixed build errors
This commit is contained in:
parent
b42e7f9b13
commit
32621f0cfe
|
@ -43,7 +43,7 @@ var h264Prefix = [...]byte{0x00, 0x00, 0x01, 0x09, 0xf0}
|
|||
// successive writes being performed not earlier than the specified delay.
|
||||
// NAL units are split after type 1 (Coded slice of a non-IDR picture), 5
|
||||
// (Coded slice of a IDR picture) and 8 (Picture parameter set).
|
||||
func H264(dst io.Writer, src io.Reader, delay time.Duration) error {
|
||||
func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
|
||||
var tick <-chan time.Time
|
||||
if delay == 0 {
|
||||
tick = noDelay
|
||||
|
|
|
@ -28,6 +28,9 @@ LICENSE
|
|||
package h264
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -204,7 +207,7 @@ var h264Tests = []struct {
|
|||
func TestH264(t *testing.T) {
|
||||
for _, test := range h264Tests {
|
||||
var buf chunkEncoder
|
||||
err := H264(&buf, bytes.NewReader(test.input), test.delay)
|
||||
err := Lex(&buf, bytes.NewReader(test.input), test.delay)
|
||||
if fmt.Sprint(err) != fmt.Sprint(test.err) {
|
||||
t.Errorf("unexpected error for %q: got:%v want:%v", test.name, err, test.err)
|
||||
}
|
||||
|
@ -218,3 +221,50 @@ func TestH264(t *testing.T) {
|
|||
}
|
||||
}
|
||||
*/
|
||||
type chunkEncoder [][]byte
|
||||
|
||||
func (e *chunkEncoder) Encode(b []byte) error {
|
||||
*e = append(*e, b)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*chunkEncoder) Stream() <-chan []byte { panic("INVALID USE") }
|
||||
|
||||
func TestScannerReadByte(t *testing.T) {
|
||||
data := []byte("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
|
||||
|
||||
for _, size := range []int{1, 2, 8, 1 << 10} {
|
||||
r := newScanner(bytes.NewReader(data), make([]byte, size))
|
||||
var got []byte
|
||||
for {
|
||||
b, err := r.readByte()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
got = append(got, b)
|
||||
}
|
||||
if !bytes.Equal(got, data) {
|
||||
t.Errorf("unexpected result for buffer size %d:\ngot :%q\nwant:%q", size, got, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestScannerScanUntilZero(t *testing.T) {
|
||||
data := []byte("Lorem ipsum dolor sit amet, consectetur adipiscing elit,\x00 sed do eiusmod tempor incididunt ut \x00labore et dolore magna aliqua.")
|
||||
|
||||
for _, size := range []int{1, 2, 8, 1 << 10} {
|
||||
r := newScanner(bytes.NewReader(data), make([]byte, size))
|
||||
var got [][]byte
|
||||
for {
|
||||
buf, _, err := r.scanUntilZeroInto(nil)
|
||||
got = append(got, buf)
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
want := bytes.SplitAfter(data, []byte{0})
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("unexpected result for buffer zie %d:\ngot :%q\nwant:%q", size, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func init() {
|
|||
|
||||
// MJPEG parses MJPEG frames read from src into separate writes to dst with
|
||||
// successive writes being performed not earlier than the specified delay.
|
||||
func MJPEG(dst io.Writer, src io.Reader, delay time.Duration) error {
|
||||
func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
|
||||
var tick <-chan time.Time
|
||||
if delay == 0 {
|
||||
tick = noDelay
|
||||
|
|
|
@ -96,7 +96,7 @@ var mjpegTests = []struct {
|
|||
|
||||
// FIXME this needs to be adapted
|
||||
/*
|
||||
func TestMJEG(t *testing.T) {
|
||||
func Lex(t *testing.T) {
|
||||
for _, test := range mjpegTests {
|
||||
var buf chunkEncoder
|
||||
err := MJPEG(&buf, bytes.NewReader(test.input), test.delay)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -1,7 +1,5 @@
|
|||
bitbucket.org/ausocean/iot v1.2.4 h1:M/473iQ0d4q+76heerjAQuqXzQyc5dZ3F7Bfuq6X7q4=
|
||||
bitbucket.org/ausocean/iot v1.2.4/go.mod h1:5HVLgPHccW2PxS7WDUQO6sKWMgk3Vfze/7d5bHs8EWU=
|
||||
bitbucket.org/ausocean/utils v0.0.0-20190408050157-66d3b4d4041e h1:rn7Z1vE6m1NSH+mrPJPgquEfBDsqzBEH4Y6fxzyB6kA=
|
||||
bitbucket.org/ausocean/utils v0.0.0-20190408050157-66d3b4d4041e/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
||||
bitbucket.org/ausocean/utils v1.2.6 h1:JN66APCV+hu6GebIHSu2KSywhLym4vigjSz5+fB0zXc=
|
||||
bitbucket.org/ausocean/utils v1.2.6/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8=
|
||||
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||
|
|
|
@ -40,7 +40,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"bitbucket.org/ausocean/av/codec/lex"
|
||||
"bitbucket.org/ausocean/av/codec/h264"
|
||||
"bitbucket.org/ausocean/av/codec/mjpeg"
|
||||
"bitbucket.org/ausocean/av/container/flv"
|
||||
"bitbucket.org/ausocean/av/container/mts"
|
||||
"bitbucket.org/ausocean/iot/pi/netsender"
|
||||
|
@ -259,10 +260,10 @@ func (r *Revid) setupPipeline(mtsEnc, flvEnc func(dst io.Writer, rate int) (io.W
|
|||
switch r.config.InputCodec {
|
||||
case H264:
|
||||
r.config.Logger.Log(logger.Info, pkg+"using H264 lexer")
|
||||
r.lexTo = lex.H264
|
||||
r.lexTo = h264.Lex
|
||||
case Mjpeg:
|
||||
r.config.Logger.Log(logger.Info, pkg+"using MJPEG lexer")
|
||||
r.lexTo = lex.MJPEG
|
||||
r.lexTo = mjpeg.Lex
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue