Show in the UI how long the user has been streaming for. Closes #59

This commit is contained in:
Gabe Kangas
2020-07-18 15:06:54 -07:00
parent addfce2ec9
commit 8ba0b6d7ce
6 changed files with 49 additions and 14 deletions

View File

@@ -68,7 +68,7 @@ func IsStreamConnected() bool {
// Kind of a hack. It takes a handful of seconds between a RTMP connection and when HLS data is available.
// So account for that with an artificial buffer of four segments.
timeSinceLastConnected := time.Since(_stats.LastConnectTime).Seconds()
timeSinceLastConnected := time.Since(_stats.LastConnectTime.Time).Seconds()
if timeSinceLastConnected < float64(config.Config.GetVideoSegmentSecondsLength()*4.0) {
return false
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/gabek/owncast/config"
"github.com/gabek/owncast/core/ffmpeg"
"github.com/gabek/owncast/models"
"github.com/gabek/owncast/utils"
)
//GetStatus gets the status of the system
@@ -27,9 +28,9 @@ func GetStatus() models.Status {
//SetStreamAsConnected sets the stream as connected
func SetStreamAsConnected() {
_stats.StreamConnected = true
_stats.LastConnectTime = time.Now()
_stats.LastConnectTime = utils.NullTime{time.Now(), true}
timeSinceDisconnect := time.Since(_stats.LastDisconnectTime).Minutes()
timeSinceDisconnect := time.Since(_stats.LastDisconnectTime.Time).Minutes()
if timeSinceDisconnect > 15 {
_stats.SessionMaxViewerCount = 0
}
@@ -45,7 +46,7 @@ func SetStreamAsConnected() {
//SetStreamAsDisconnected sets the stream as disconnected
func SetStreamAsDisconnected() {
_stats.StreamConnected = false
_stats.LastDisconnectTime = time.Now()
_stats.LastDisconnectTime = utils.NullTime{time.Now(), true}
ffmpeg.ShowStreamOfflineState()
}