Project restructure (#18)
* First pass at restructuring the project; untested but it does compile * Restructure builds and runs 🎉 * Add the dist folder to the gitignore * Update core/playlist/monitor.go * golint and reorganize the monitor.go file Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
51
core/status.go
Normal file
51
core/status.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package core
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gabek/owncast/config"
|
||||
"github.com/gabek/owncast/core/ffmpeg"
|
||||
"github.com/gabek/owncast/models"
|
||||
)
|
||||
|
||||
//GetStatus gets the status of the system
|
||||
func GetStatus() models.Status {
|
||||
if _stats == nil {
|
||||
return models.Status{}
|
||||
}
|
||||
|
||||
return models.Status{
|
||||
Online: IsStreamConnected(),
|
||||
ViewerCount: len(_stats.Clients),
|
||||
OverallMaxViewerCount: _stats.OverallMaxViewerCount,
|
||||
SessionMaxViewerCount: _stats.SessionMaxViewerCount,
|
||||
}
|
||||
}
|
||||
|
||||
//SetStreamAsConnected sets the stream as connected
|
||||
func SetStreamAsConnected() {
|
||||
_stats.StreamConnected = true
|
||||
_stats.LastConnectTime = time.Now()
|
||||
|
||||
timeSinceDisconnect := time.Since(_stats.LastDisconnectTime).Minutes()
|
||||
if timeSinceDisconnect > 15 {
|
||||
_stats.SessionMaxViewerCount = 0
|
||||
}
|
||||
|
||||
chunkPath := config.Config.PublicHLSPath
|
||||
if usingExternalStorage {
|
||||
chunkPath = config.Config.PrivateHLSPath
|
||||
}
|
||||
|
||||
ffmpeg.StartThumbnailGenerator(chunkPath)
|
||||
}
|
||||
|
||||
//SetStreamAsDisconnected sets the stream as disconnected
|
||||
func SetStreamAsDisconnected() {
|
||||
_stats.StreamConnected = false
|
||||
_stats.LastDisconnectTime = time.Now()
|
||||
|
||||
if config.Config.EnableOfflineImage {
|
||||
ffmpeg.ShowStreamOfflineState()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user