You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
61 lines
1.7 KiB
package storageproviders |
|
|
|
import ( |
|
"time" |
|
|
|
log "github.com/sirupsen/logrus" |
|
|
|
"github.com/owncast/owncast/config" |
|
"github.com/owncast/owncast/core/transcoder" |
|
) |
|
|
|
// LocalStorage represents an instance of the local storage provider for HLS video. |
|
type LocalStorage struct { |
|
// Cleanup old public HLS content every N min from the webroot. |
|
onlineCleanupTicker *time.Ticker |
|
} |
|
|
|
// NewLocalStorage returns a new LocalStorage instance. |
|
func NewLocalStorage() *LocalStorage { |
|
return &LocalStorage{} |
|
} |
|
|
|
// Setup configures this storage provider. |
|
func (s *LocalStorage) Setup() error { |
|
// NOTE: This cleanup timer will have to be disabled to support recordings in the future |
|
// as all HLS segments have to be publicly available on disk to keep a recording of them. |
|
s.onlineCleanupTicker = time.NewTicker(1 * time.Minute) |
|
go func() { |
|
for range s.onlineCleanupTicker.C { |
|
transcoder.CleanupOldContent(config.HLSStoragePath) |
|
} |
|
}() |
|
return nil |
|
} |
|
|
|
// SegmentWritten is called when a single segment of video is written. |
|
func (s *LocalStorage) SegmentWritten(localFilePath string) { |
|
if _, err := s.Save(localFilePath, 0); err != nil { |
|
log.Warnln(err) |
|
} |
|
} |
|
|
|
// VariantPlaylistWritten is called when a variant hls playlist is written. |
|
func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) { |
|
if _, err := s.Save(localFilePath, 0); err != nil { |
|
log.Errorln(err) |
|
return |
|
} |
|
} |
|
|
|
// MasterPlaylistWritten is called when the master hls playlist is written. |
|
func (s *LocalStorage) MasterPlaylistWritten(localFilePath string) { |
|
if _, err := s.Save(localFilePath, 0); err != nil { |
|
log.Warnln(err) |
|
} |
|
} |
|
|
|
// Save will save a local filepath using the storage provider. |
|
func (s *LocalStorage) Save(filePath string, retryCount int) (string, error) { |
|
return filePath, nil |
|
}
|
|
|