fixing rtmp handshake error

This commit is contained in:
Saxon Milton 2018-05-01 05:40:41 +09:30
parent 4fdcaa6d0a
commit 6803554434
1 changed files with 12 additions and 5 deletions

View File

@ -73,6 +73,7 @@ const (
sendFailedDelay = 5 sendFailedDelay = 5
maxSendFailedErrorCount = 500 maxSendFailedErrorCount = 500
clipSizeThreshold = 11 clipSizeThreshold = 11
rtmpConnectionMaxTries = 5
) )
// Log Types // Log Types
@ -503,11 +504,17 @@ func (r *revid) setupOutputForFfmpegRtmp() error {
// setupOutputForLibRtmp sets up rtmp output using the wrapper for the c based // setupOutputForLibRtmp sets up rtmp output using the wrapper for the c based
// librtmp library - makes connection and starts comms etc. // librtmp library - makes connection and starts comms etc.
func (r *revid) setupOutputForLibRtmp() (err error) { func (r *revid) setupOutputForLibRtmp() error {
for r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout),
err = r.rtmpInst.StartSession(), noOfTries := 0;
err != nil && noOfTries < rtmpConnectionMaxTries; noOfTries++
{
r.Log(Error, err.Error())
r.Log(Info, "Trying to establish rtmp connection again!")
r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout) r.rtmpInst = rtmp.NewRTMPSession(r.config.RtmpUrl, rtmpConnectionTimout)
err = r.rtmpInst.StartSession() err = r.rtmpInst.StartSession()
// go r.testRtmp(5000) }
return return errors.New("Could not establish rtmp connection, check rtmp url!")
} }
// setupOutputForFile sets up an output file to output data to // setupOutputForFile sets up an output file to output data to