Just updating remote

This commit is contained in:
Jack Richardson 2018-01-31 16:43:04 +10:30
parent e1563ba7b5
commit c73afb65f3
1 changed files with 19 additions and 3 deletions

View File

@ -58,12 +58,13 @@ const (
clipDuration = 1 // s
mp2tPacketSize = 188 // MPEG-TS packet size
mp2tMaxPackets = 2016 * clipDuration // # first multiple of 7 and 8 greater than 2000
bufferSize = 100 / clipDuration
ringBufferSize = 100 / clipDuration
ringBufferElementSize = 500000
httpTimeOut = 5 // s
packetsPerFrame = 7
h264BufferSize = 500000
bitrateTime = 60
mjpegParserInChanLen = 10000
mjpegParserInChanLen = 100000
)
// Log Types
@ -149,7 +150,7 @@ type revidInst struct {
// successful.
func NewRevidInstance(config Config) (r *revidInst, err error) {
r = new(revidInst)
r.ringBuffer = ringbuffer.NewRingBuffer(bufferSize, mp2tPacketSize*mp2tMaxPackets)
r.ringBuffer = ringbuffer.NewRingBuffer(ringBufferSize, ringBufferElementSize)
err = r.ChangeState(config)
if err != nil {
return nil, err
@ -175,6 +176,7 @@ func NewRevidInstance(config Config) (r *revidInst, err error) {
case Mjpeg:
r.parser = parser.NewMJPEGParser(mjpegParserInChanLen)
}
r.mjpegOutputChan = make(chan []byte, 10000)
switch r.config.Packetization {
case None:
r.parser.SetOutputChan(r.mjpegOutputChan)
@ -231,6 +233,16 @@ func (r *revidInst) ChangeState(config Config) error {
return errors.New("Bad output type defined in config!")
}
switch config.Packetization {
case None:
case Mpegts:
case NothingDefined:
r.Log(Warning, "No packetization option defined, defaulting to none!")
config.Packetization = None
default:
return errors.New("Bad packetization option defined in config!")
}
if config.Width == "" {
r.Log(Warning, "No width defined, defaulting to 1280!")
config.Width = defaultWidth
@ -427,6 +439,10 @@ func (r *revidInst) packClips() {
case None:
frame := <-r.mjpegOutputChan
upperBound := clipSize + len(frame)
fmt.Printf("len(clip): %v\n", len(clip))
fmt.Printf("clipsize: %v\n", clipSize)
fmt.Printf("upperBound: %v\n", upperBound)
fmt.Printf("len(frame): %v\n", len(frame))
copy(clip[clipSize:upperBound], frame)
packetCount++
clipSize += len(frame)