mirror of https://bitbucket.org/ausocean/av.git
Made logging a bit less verbose using Detail messages.
This commit is contained in:
parent
3f49f56ec5
commit
defe5c54a8
|
@ -48,12 +48,7 @@ import (
|
||||||
"bitbucket.org/ausocean/av/parser"
|
"bitbucket.org/ausocean/av/parser"
|
||||||
"bitbucket.org/ausocean/av/ringbuffer"
|
"bitbucket.org/ausocean/av/ringbuffer"
|
||||||
"bitbucket.org/ausocean/av/rtmp"
|
"bitbucket.org/ausocean/av/rtmp"
|
||||||
/*
|
)
|
||||||
"../generator"
|
|
||||||
"../parser"
|
|
||||||
"../ringbuffer"
|
|
||||||
"../rtmp"
|
|
||||||
*/)
|
|
||||||
|
|
||||||
// Misc constants
|
// Misc constants
|
||||||
const (
|
const (
|
||||||
|
@ -75,7 +70,7 @@ const (
|
||||||
clipSizeThreshold = 11
|
clipSizeThreshold = 11
|
||||||
rtmpConnectionMaxTries = 5
|
rtmpConnectionMaxTries = 5
|
||||||
raspividNoOfTries = 3
|
raspividNoOfTries = 3
|
||||||
sendingWaitTime = time.Duration(5)*time.Millisecond
|
sendingWaitTime = time.Duration(5) * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
// Log Types
|
// Log Types
|
||||||
|
@ -84,6 +79,7 @@ const (
|
||||||
Warning = "Warning"
|
Warning = "Warning"
|
||||||
Info = "Info"
|
Info = "Info"
|
||||||
Debug = "Debug"
|
Debug = "Debug"
|
||||||
|
Detail = "Detail"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Revid provides methods to control a revid session; providing methods
|
// Revid provides methods to control a revid session; providing methods
|
||||||
|
@ -104,7 +100,7 @@ type revid struct {
|
||||||
ringBuffer ringbuffer.RingBuffer
|
ringBuffer ringbuffer.RingBuffer
|
||||||
config Config
|
config Config
|
||||||
isRunning bool
|
isRunning bool
|
||||||
isSending bool
|
isSending bool
|
||||||
outputFile *os.File
|
outputFile *os.File
|
||||||
inputFile *os.File
|
inputFile *os.File
|
||||||
generator generator.Generator
|
generator generator.Generator
|
||||||
|
@ -413,9 +409,11 @@ func (r *revid) outputClips() {
|
||||||
// If the ringbuffer has something we can read and send off
|
// If the ringbuffer has something we can read and send off
|
||||||
if clip, err := r.ringBuffer.Read(); err == nil && r.isRunning {
|
if clip, err := r.ringBuffer.Read(); err == nil && r.isRunning {
|
||||||
bytes += len(clip)
|
bytes += len(clip)
|
||||||
r.Log(Debug, "About to send")
|
r.Log(Detail, "About to send")
|
||||||
err2 := r.sendClip(clip)
|
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 {
|
if r.isRunning && err2 != nil && len(clip) > 11 {
|
||||||
r.Log(Debug, "Send failed! Trying again")
|
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
|
// if there's still an error we try and reconnect, unless we're stopping
|
||||||
for r.isRunning && err2 != nil {
|
for r.isRunning && err2 != nil {
|
||||||
r.Log(Debug, "Send failed a again! Trying to reconnect...")
|
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())
|
r.Log(Error, err2.Error())
|
||||||
|
|
||||||
if r.config.Output == NativeRtmp {
|
if r.config.Output == NativeRtmp {
|
||||||
|
@ -438,7 +436,7 @@ func (r *revid) outputClips() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.config.Output == NativeRtmp {
|
if r.config.Output == NativeRtmp {
|
||||||
r.Log(Debug, "Restarting rtmp session...")
|
r.Log(Info, "Restarting rtmp session...")
|
||||||
r.rtmpInst.StartSession()
|
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
|
// let the ringbuffer know that we're done with the memory we grabbed when
|
||||||
// we call ringBuffer.Get()
|
// we call ringBuffer.Get()
|
||||||
if err := r.ringBuffer.DoneReading(); err != nil {
|
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
|
// sendClipToLibRtmp send the clip over the current rtmp connection using the
|
||||||
// c based librtmp library
|
// c based librtmp library
|
||||||
func (r *revid) sendClipToLibRtmp(clip []byte) (err error) {
|
func (r *revid) sendClipToLibRtmp(clip []byte) (err error) {
|
||||||
r.isSending = true;
|
r.isSending = true
|
||||||
err = r.rtmpInst.WriteFrame(clip, uint(len(clip)))
|
err = r.rtmpInst.WriteFrame(clip, uint(len(clip)))
|
||||||
r.isSending = false
|
r.isSending = false
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue