revid: start and stop now return errors

This commit is contained in:
saxon 2019-01-13 22:01:04 +10:30
parent bd91f8dc8b
commit 5ae1e41e38
1 changed files with 7 additions and 7 deletions

View File

@ -296,10 +296,9 @@ func (r *Revid) IsRunning() bool {
// Start invokes a Revid to start processing video from a defined input
// and packetising (if theres packetization) to a defined output.
func (r *Revid) Start() {
func (r *Revid) Start() error {
if r.isRunning {
r.config.Logger.Log(logger.Warning, pkg+"revid.Start() called but revid already running")
return
return errors.New(pkg + "start called but revid is already running")
}
r.config.Logger.Log(logger.Info, pkg+"starting Revid")
r.config.Logger.Log(logger.Debug, pkg+"setting up output")
@ -307,14 +306,14 @@ func (r *Revid) Start() {
r.config.Logger.Log(logger.Info, pkg+"starting output routine")
go r.outputClips()
r.config.Logger.Log(logger.Info, pkg+"setting up input and receiving content")
go r.setupInput()
err := r.setupInput()
return err
}
// Stop halts any processing of video data from a camera or file
func (r *Revid) Stop() {
func (r *Revid) Stop() error {
if !r.isRunning {
r.config.Logger.Log(logger.Warning, pkg+"revid.Stop() called but revid not running")
return
return errors.New(pkg + "stop called but revid is already stopped")
}
r.config.Logger.Log(logger.Info, pkg+"stopping revid")
@ -325,6 +324,7 @@ func (r *Revid) Stop() {
if r.cmd != nil && r.cmd.Process != nil {
r.cmd.Process.Kill()
}
return nil
}
// outputClips takes the clips produced in the packClips method and outputs them