Made logging a bit less verbose using Detail messages.

This commit is contained in:
Alan Noble 2018-05-07 21:16:40 +09:30
parent 3f49f56ec5
commit defe5c54a8
1 changed files with 12 additions and 14 deletions

View File

@ -48,12 +48,7 @@ import (
"bitbucket.org/ausocean/av/parser"
"bitbucket.org/ausocean/av/ringbuffer"
"bitbucket.org/ausocean/av/rtmp"
/*
"../generator"
"../parser"
"../ringbuffer"
"../rtmp"
*/)
)
// Misc constants
const (
@ -75,7 +70,7 @@ const (
clipSizeThreshold = 11
rtmpConnectionMaxTries = 5
raspividNoOfTries = 3
sendingWaitTime = time.Duration(5)*time.Millisecond
sendingWaitTime = time.Duration(5) * time.Millisecond
)
// Log Types
@ -84,6 +79,7 @@ const (
Warning = "Warning"
Info = "Info"
Debug = "Debug"
Detail = "Detail"
)
// Revid provides methods to control a revid session; providing methods
@ -104,7 +100,7 @@ type revid struct {
ringBuffer ringbuffer.RingBuffer
config Config
isRunning bool
isSending bool
isSending bool
outputFile *os.File
inputFile *os.File
generator generator.Generator
@ -413,9 +409,11 @@ func (r *revid) outputClips() {
// If the ringbuffer has something we can read and send off
if clip, err := r.ringBuffer.Read(); err == nil && r.isRunning {
bytes += len(clip)
r.Log(Debug, "About to send")
r.Log(Detail, "About to send")
err2 := r.sendClip(clip)
r.Log(Debug, "Finished send")
if err2 == nil {
r.Log(Debug, "Sent clip")
}
if r.isRunning && err2 != nil && len(clip) > 11 {
r.Log(Debug, "Send failed! Trying again")
@ -425,7 +423,7 @@ func (r *revid) outputClips() {
// if there's still an error we try and reconnect, unless we're stopping
for r.isRunning && err2 != nil {
r.Log(Debug, "Send failed a again! Trying to reconnect...")
time.Sleep(time.Duration(5) * time.Millisecond)
time.Sleep(time.Duration(sendFailedDelay) * time.Millisecond)
r.Log(Error, err2.Error())
if r.config.Output == NativeRtmp {
@ -438,7 +436,7 @@ func (r *revid) outputClips() {
}
if r.config.Output == NativeRtmp {
r.Log(Debug, "Restarting rtmp session...")
r.Log(Info, "Restarting rtmp session...")
r.rtmpInst.StartSession()
}
@ -448,7 +446,7 @@ func (r *revid) outputClips() {
}
}
r.Log(Debug, "Done reading that clip from ringbuffer...")
r.Log(Detail, "Done reading that clip from ringbuffer...")
// let the ringbuffer know that we're done with the memory we grabbed when
// we call ringBuffer.Get()
if err := r.ringBuffer.DoneReading(); err != nil {
@ -514,7 +512,7 @@ func (r *revid) sendClipToFfmpegRtmp(clip []byte) (err error) {
// sendClipToLibRtmp send the clip over the current rtmp connection using the
// c based librtmp library
func (r *revid) sendClipToLibRtmp(clip []byte) (err error) {
r.isSending = true;
r.isSending = true
err = r.rtmpInst.WriteFrame(clip, uint(len(clip)))
r.isSending = false
return