2020-06-23 03:11:56 +02:00
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2020-10-05 19:07:09 +02:00
|
|
|
"github.com/owncast/owncast/config"
|
|
|
|
"github.com/owncast/owncast/core/ffmpeg"
|
|
|
|
"github.com/owncast/owncast/models"
|
|
|
|
"github.com/owncast/owncast/utils"
|
2020-06-23 03:11:56 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
//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,
|
2020-06-25 07:52:05 +02:00
|
|
|
LastDisconnectTime: _stats.LastDisconnectTime,
|
|
|
|
LastConnectTime: _stats.LastConnectTime,
|
2020-06-23 03:11:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//SetStreamAsConnected sets the stream as connected
|
|
|
|
func SetStreamAsConnected() {
|
2020-09-16 22:31:21 +02:00
|
|
|
stopCleanupTimer()
|
|
|
|
|
2020-06-23 03:11:56 +02:00
|
|
|
_stats.StreamConnected = true
|
2020-07-19 00:06:54 +02:00
|
|
|
_stats.LastConnectTime = utils.NullTime{time.Now(), true}
|
2020-07-23 08:54:36 +02:00
|
|
|
_stats.LastDisconnectTime = utils.NullTime{time.Now(), false}
|
2020-06-23 03:11:56 +02:00
|
|
|
|
2020-10-03 23:35:03 +02:00
|
|
|
chunkPath := config.PublicHLSStoragePath
|
2020-06-23 03:11:56 +02:00
|
|
|
if usingExternalStorage {
|
2020-10-03 23:35:03 +02:00
|
|
|
chunkPath = config.PrivateHLSStoragePath
|
2020-06-23 03:11:56 +02:00
|
|
|
}
|
|
|
|
|
2020-10-02 08:55:38 +02:00
|
|
|
if _yp != nil {
|
|
|
|
_yp.Start()
|
|
|
|
}
|
|
|
|
|
2020-07-07 04:45:58 +02:00
|
|
|
ffmpeg.StartThumbnailGenerator(chunkPath, config.Config.VideoSettings.HighestQualityStreamIndex)
|
2020-06-23 03:11:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//SetStreamAsDisconnected sets the stream as disconnected
|
|
|
|
func SetStreamAsDisconnected() {
|
|
|
|
_stats.StreamConnected = false
|
2020-07-19 00:06:54 +02:00
|
|
|
_stats.LastDisconnectTime = utils.NullTime{time.Now(), true}
|
2020-10-02 09:12:47 +02:00
|
|
|
_broadcaster = nil
|
2020-06-23 03:11:56 +02:00
|
|
|
|
2020-10-02 08:55:38 +02:00
|
|
|
if _yp != nil {
|
|
|
|
_yp.Stop()
|
|
|
|
}
|
|
|
|
|
2020-06-26 02:44:47 +02:00
|
|
|
ffmpeg.ShowStreamOfflineState()
|
2020-09-16 22:31:21 +02:00
|
|
|
startCleanupTimer()
|
2020-06-23 03:11:56 +02:00
|
|
|
}
|
2020-10-02 09:12:47 +02:00
|
|
|
|
|
|
|
// SetBroadcaster will store the current inbound broadcasting details
|
|
|
|
func SetBroadcaster(broadcaster models.Broadcaster) {
|
|
|
|
_broadcaster = &broadcaster
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetBroadcaster() *models.Broadcaster {
|
|
|
|
return _broadcaster
|
|
|
|
}
|