revid: fixed issues after merge

This commit is contained in:
Trek H 2019-06-03 18:35:28 +09:30
parent 3d7539c6df
commit 90c34c4108
7 changed files with 11 additions and 21 deletions

View File

@ -48,7 +48,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 Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
func Lex(dst io.Writer, src io.Reader, delay time.Duration, n int) error {
var tick <-chan time.Time
if delay == 0 {
tick = noDelay

View File

@ -70,7 +70,7 @@ func NewLexer(donl bool) *Lexer {
// Lex continually reads RTP packets from the io.Reader src and lexes into
// access units which are written to the io.Writer dst. Lex expects that for
// each read from src, a single RTP packet is received.
func (l *Lexer) Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
func (l *Lexer) Lex(dst io.Writer, src io.Reader, delay time.Duration, n int) error {
buf := make([]byte, maxRTPSize)
for {
n, err := src.Read(buf)

View File

@ -45,7 +45,7 @@ func init() {
// Lex parses MJPEG frames read from src into separate writes to dst with
// successive writes being performed not earlier than the specified delay.
func Lex(dst io.Writer, src io.Reader, delay time.Duration) error {
func Lex(dst io.Writer, src io.Reader, delay time.Duration, n int) error {
var tick <-chan time.Time
if delay == 0 {
tick = noDelay

View File

@ -26,13 +26,9 @@ LICENSE
package pes
<<<<<<< HEAD
const MaxPesSize = 64 * 1 << 10 // 65536
=======
import "github.com/Comcast/gots"
const MaxPesSize = 64 * 1 << 10
>>>>>>> master
const MaxPesSize = 64 * 1 << 10 // 65536
/*
The below data struct encapsulates the fields of an PES packet. Below is

View File

@ -7,7 +7,7 @@ import (
"testing"
"time"
"bitbucket.org/ausocean/av/codec/lex"
"bitbucket.org/ausocean/av/codec/codecutil"
"github.com/yobert/alsa"
)
@ -114,7 +114,7 @@ func TestAudio(t *testing.T) {
t.Error(err)
}
num := 3 // How many 'ac.RecPeriod's to record.
go lex.ADPCM(dst, ai, time.Duration(ac.RecPeriod*float64(time.Second)), ai.ChunkSize())
go codecutil.LexBytes(dst, ai, time.Duration(ac.RecPeriod*float64(time.Second)), ai.ChunkSize())
time.Sleep(time.Millisecond * 1000 * time.Duration(num))
ai.Stop()
err = ioutil.WriteFile("./testout", dst.Bytes(), 0644)

View File

@ -173,7 +173,7 @@ func (r *Revid) reset(config Config) error {
r.config.Logger.SetLevel(config.LogLevel)
err = r.setupPipeline(
func(dst io.WriteCloser, fps int, medType int) (io.WriteCloser, error) {
func(dst io.WriteCloser, fps float64) (io.WriteCloser, error) {
var st int
switch r.config.Input {
case Raspivid, File, V4L:
@ -217,7 +217,7 @@ func (r *Revid) setConfig(config Config) error {
// mtsEnc and flvEnc will be called to obtain an mts encoder and flv encoder
// respectively. multiWriter will be used to create an ioext.multiWriteCloser
// so that encoders can write to multiple senders.
func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64, mediaType int) (io.WriteCloser, error), flvEnc func(dst io.WriteCloser, rate int) (io.WriteCloser, error), multiWriter func(...io.WriteCloser) io.WriteCloser) error {
func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.WriteCloser, error), flvEnc func(dst io.WriteCloser, rate int) (io.WriteCloser, error), multiWriter func(...io.WriteCloser) io.WriteCloser) error {
// encoders will hold the encoders that are required for revid's current
// configuration.
var encoders []io.WriteCloser
@ -261,13 +261,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64, medi
// as a destination.
if len(mtsSenders) != 0 {
mw := multiWriter(mtsSenders...)
var mediaType int
if r.config.Input == Audio {
mediaType = mts.Audio
} else {
mediaType = mts.Video
}
e, _ := mtsEnc(mw, r.config.WriteRate, mediaType)
e, _ := mtsEnc(mw, r.config.WriteRate)
encoders = append(encoders, e)
}
@ -725,7 +719,7 @@ func (r *Revid) startRTSPCamera() (func() error, error) {
// Start reading data from the RTP client.
r.wg.Add(1)
go r.processFrom(rtpClt, time.Second/time.Duration(r.config.FrameRate))
go r.processFrom(rtpClt, time.Second/time.Duration(r.config.FrameRate), 0)
return func() error {
rtspClt.Close()

View File

@ -232,7 +232,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
// This logic is what we want to check.
err = rv.setupPipeline(
func(dst io.WriteCloser, rate float64, mediaType int) (io.WriteCloser, error) {
func(dst io.WriteCloser, rate float64) (io.WriteCloser, error) {
return &tstMtsEncoder{dst: dst}, nil
},
func(dst io.WriteCloser, rate int) (io.WriteCloser, error) {