mirror of https://bitbucket.org/ausocean/av.git
revid: move initialisation of revids netsender up higher in New so that we don't get nil pointer deference
This commit is contained in:
parent
e6d0ee035e
commit
0c2ccf55fa
|
@ -99,7 +99,7 @@ const (
|
||||||
defaultFramesPerClip = 1
|
defaultFramesPerClip = 1
|
||||||
defaultVerticalFlip = No
|
defaultVerticalFlip = No
|
||||||
defaultHorizontalFlip = No
|
defaultHorizontalFlip = No
|
||||||
httpFramesPerClip = 25
|
httpFramesPerClip = 7
|
||||||
defaultInputCodec = H264
|
defaultInputCodec = H264
|
||||||
defaultVerbosity = No
|
defaultVerbosity = No
|
||||||
)
|
)
|
||||||
|
|
|
@ -31,7 +31,6 @@ package revid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -116,13 +115,13 @@ type Revid struct {
|
||||||
// an error if construction of the new instance was not successful.
|
// an error if construction of the new instance was not successful.
|
||||||
func New(c Config, ns *netsender.Sender) (*Revid, error) {
|
func New(c Config, ns *netsender.Sender) (*Revid, error) {
|
||||||
var r Revid
|
var r Revid
|
||||||
|
r.ns = ns
|
||||||
err := r.reset(c)
|
err := r.reset(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
r.ringBuffer = ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout)
|
r.ringBuffer = ring.NewBuffer(ringBufferSize, ringBufferElementSize, writeTimeout)
|
||||||
r.outputChan = make(chan []byte, outputChanSize)
|
r.outputChan = make(chan []byte, outputChanSize)
|
||||||
r.ns = ns
|
|
||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +296,6 @@ func (r *Revid) packClips() {
|
||||||
// TODO: This is temporary, need to work out how to make this work
|
// TODO: This is temporary, need to work out how to make this work
|
||||||
// for cases when there is not packetisation.
|
// for cases when there is not packetisation.
|
||||||
case frame := <-r.encoder.Stream():
|
case frame := <-r.encoder.Stream():
|
||||||
fmt.Println("got frame")
|
|
||||||
lenOfFrame := len(frame)
|
lenOfFrame := len(frame)
|
||||||
if lenOfFrame > ringBufferElementSize {
|
if lenOfFrame > ringBufferElementSize {
|
||||||
r.config.Logger.Log(smartlogger.Warning, pkg+"frame was too big", "frame size", lenOfFrame)
|
r.config.Logger.Log(smartlogger.Warning, pkg+"frame was too big", "frame size", lenOfFrame)
|
||||||
|
@ -316,7 +314,6 @@ func (r *Revid) packClips() {
|
||||||
packetCount++
|
packetCount++
|
||||||
clipSize += lenOfFrame
|
clipSize += lenOfFrame
|
||||||
if packetCount >= r.config.FramesPerClip {
|
if packetCount >= r.config.FramesPerClip {
|
||||||
fmt.Println("flushing buffer")
|
|
||||||
r.ringBuffer.Flush()
|
r.ringBuffer.Flush()
|
||||||
clipSize = 0
|
clipSize = 0
|
||||||
packetCount = 0
|
packetCount = 0
|
||||||
|
|
|
@ -29,7 +29,6 @@ LICENSE
|
||||||
package revid
|
package revid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -123,7 +122,6 @@ func (s *httpSender) load(c *ring.Chunk) error {
|
||||||
|
|
||||||
func (s *httpSender) send() error {
|
func (s *httpSender) send() error {
|
||||||
if s.chunk == nil {
|
if s.chunk == nil {
|
||||||
fmt.Println("chunk is nil")
|
|
||||||
// Do not retry with httpSender,
|
// Do not retry with httpSender,
|
||||||
// so just return without error
|
// so just return without error
|
||||||
// if the chunk has been cleared.
|
// if the chunk has been cleared.
|
||||||
|
@ -135,7 +133,6 @@ func (s *httpSender) send() error {
|
||||||
pins := netsender.MakePins(ip, "V")
|
pins := netsender.MakePins(ip, "V")
|
||||||
for i, pin := range pins {
|
for i, pin := range pins {
|
||||||
if pin.Name == "V0" {
|
if pin.Name == "V0" {
|
||||||
fmt.Println("pin is V0")
|
|
||||||
send = true
|
send = true
|
||||||
pins[i].Value = s.chunk.Len()
|
pins[i].Value = s.chunk.Len()
|
||||||
pins[i].Data = s.chunk.Bytes()
|
pins[i].Data = s.chunk.Bytes()
|
||||||
|
@ -145,7 +142,6 @@ func (s *httpSender) send() error {
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if send {
|
if send {
|
||||||
fmt.Println("sending")
|
|
||||||
_, _, err = s.client.Send(netsender.RequestPoll, pins)
|
_, _, err = s.client.Send(netsender.RequestPoll, pins)
|
||||||
}
|
}
|
||||||
// We will not retry, so release
|
// We will not retry, so release
|
||||||
|
|
Loading…
Reference in New Issue