mirror of https://bitbucket.org/ausocean/av.git
revid: fixed issues after merge
This commit is contained in:
parent
3d7539c6df
commit
90c34c4108
|
@ -48,7 +48,7 @@ var h264Prefix = [...]byte{0x00, 0x00, 0x01, 0x09, 0xf0}
|
||||||
// successive writes being performed not earlier than the specified delay.
|
// 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
|
// 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).
|
// (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
|
var tick <-chan time.Time
|
||||||
if delay == 0 {
|
if delay == 0 {
|
||||||
tick = noDelay
|
tick = noDelay
|
||||||
|
|
|
@ -70,7 +70,7 @@ func NewLexer(donl bool) *Lexer {
|
||||||
// Lex continually reads RTP packets from the io.Reader src and lexes into
|
// 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
|
// access units which are written to the io.Writer dst. Lex expects that for
|
||||||
// each read from src, a single RTP packet is received.
|
// 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)
|
buf := make([]byte, maxRTPSize)
|
||||||
for {
|
for {
|
||||||
n, err := src.Read(buf)
|
n, err := src.Read(buf)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func init() {
|
||||||
|
|
||||||
// Lex parses MJPEG frames read from src into separate writes to dst with
|
// Lex parses MJPEG frames read from src into separate writes to dst with
|
||||||
// successive writes being performed not earlier than the specified delay.
|
// 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
|
var tick <-chan time.Time
|
||||||
if delay == 0 {
|
if delay == 0 {
|
||||||
tick = noDelay
|
tick = noDelay
|
||||||
|
|
|
@ -26,13 +26,9 @@ LICENSE
|
||||||
|
|
||||||
package pes
|
package pes
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
const MaxPesSize = 64 * 1 << 10 // 65536
|
|
||||||
=======
|
|
||||||
import "github.com/Comcast/gots"
|
import "github.com/Comcast/gots"
|
||||||
|
|
||||||
const MaxPesSize = 64 * 1 << 10
|
const MaxPesSize = 64 * 1 << 10 // 65536
|
||||||
>>>>>>> master
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The below data struct encapsulates the fields of an PES packet. Below is
|
The below data struct encapsulates the fields of an PES packet. Below is
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"bitbucket.org/ausocean/av/codec/lex"
|
"bitbucket.org/ausocean/av/codec/codecutil"
|
||||||
"github.com/yobert/alsa"
|
"github.com/yobert/alsa"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func TestAudio(t *testing.T) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
num := 3 // How many 'ac.RecPeriod's to record.
|
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))
|
time.Sleep(time.Millisecond * 1000 * time.Duration(num))
|
||||||
ai.Stop()
|
ai.Stop()
|
||||||
err = ioutil.WriteFile("./testout", dst.Bytes(), 0644)
|
err = ioutil.WriteFile("./testout", dst.Bytes(), 0644)
|
||||||
|
|
|
@ -173,7 +173,7 @@ func (r *Revid) reset(config Config) error {
|
||||||
r.config.Logger.SetLevel(config.LogLevel)
|
r.config.Logger.SetLevel(config.LogLevel)
|
||||||
|
|
||||||
err = r.setupPipeline(
|
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
|
var st int
|
||||||
switch r.config.Input {
|
switch r.config.Input {
|
||||||
case Raspivid, File, V4L:
|
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
|
// mtsEnc and flvEnc will be called to obtain an mts encoder and flv encoder
|
||||||
// respectively. multiWriter will be used to create an ioext.multiWriteCloser
|
// respectively. multiWriter will be used to create an ioext.multiWriteCloser
|
||||||
// so that encoders can write to multiple senders.
|
// 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
|
// encoders will hold the encoders that are required for revid's current
|
||||||
// configuration.
|
// configuration.
|
||||||
var encoders []io.WriteCloser
|
var encoders []io.WriteCloser
|
||||||
|
@ -261,13 +261,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64, medi
|
||||||
// as a destination.
|
// as a destination.
|
||||||
if len(mtsSenders) != 0 {
|
if len(mtsSenders) != 0 {
|
||||||
mw := multiWriter(mtsSenders...)
|
mw := multiWriter(mtsSenders...)
|
||||||
var mediaType int
|
e, _ := mtsEnc(mw, r.config.WriteRate)
|
||||||
if r.config.Input == Audio {
|
|
||||||
mediaType = mts.Audio
|
|
||||||
} else {
|
|
||||||
mediaType = mts.Video
|
|
||||||
}
|
|
||||||
e, _ := mtsEnc(mw, r.config.WriteRate, mediaType)
|
|
||||||
encoders = append(encoders, e)
|
encoders = append(encoders, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -725,7 +719,7 @@ func (r *Revid) startRTSPCamera() (func() error, error) {
|
||||||
|
|
||||||
// Start reading data from the RTP client.
|
// Start reading data from the RTP client.
|
||||||
r.wg.Add(1)
|
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 {
|
return func() error {
|
||||||
rtspClt.Close()
|
rtspClt.Close()
|
||||||
|
|
|
@ -232,7 +232,7 @@ func TestResetEncoderSenderSetup(t *testing.T) {
|
||||||
|
|
||||||
// This logic is what we want to check.
|
// This logic is what we want to check.
|
||||||
err = rv.setupPipeline(
|
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
|
return &tstMtsEncoder{dst: dst}, nil
|
||||||
},
|
},
|
||||||
func(dst io.WriteCloser, rate int) (io.WriteCloser, error) {
|
func(dst io.WriteCloser, rate int) (io.WriteCloser, error) {
|
||||||
|
|
Loading…
Reference in New Issue