Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Renamed rewriteRemotePlaylist (#3313)

Tom Funkenc59bdc1060ae
diff --git a/core/storageproviders/local.go b/core/storageproviders/local.go
index f71306ca6a..966893b249 100644
--- a/core/storageproviders/local.go
+++ b/core/storageproviders/local.go
@@ -13,7 +13,9 @@ import (
)
// LocalStorage represents an instance of the local storage provider for HLS video.
-type LocalStorage struct{}
+type LocalStorage struct {
+ host string
+}
// NewLocalStorage returns a new LocalStorage instance.
func NewLocalStorage() *LocalStorage {
@@ -22,6 +24,7 @@ func NewLocalStorage() *LocalStorage {
// Setup configures this storage provider.
func (s *LocalStorage) Setup() error {
+ s.host = data.GetVideoServingEndpoint()
return nil
}
@@ -42,8 +45,16 @@ func (s *LocalStorage) VariantPlaylistWritten(localFilePath string) {
// 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)
+
+ // If we're using a remote serving endpoint, we need to rewrite the master playlist
+ if s.host != "" {
+ if err := rewritePlaylistLocations(localFilePath, s.host, ""); err != nil {
+ log.Warnln(err)
+ }
+ } else {
+ if _, err := s.Save(localFilePath, 0); err != nil {
+ log.Warnln(err)
+ }
}
}
diff --git a/core/storageproviders/rewriteLocalPlaylist.go b/core/storageproviders/rewriteLocalPlaylist.go
index 5ba433ee2a..51070d84ae 100644
--- a/core/storageproviders/rewriteLocalPlaylist.go
+++ b/core/storageproviders/rewriteLocalPlaylist.go
@@ -12,8 +12,8 @@ import (
log "github.com/sirupsen/logrus"
)
-// rewriteRemotePlaylist will take a local playlist and rewrite it to have absolute URLs to remote locations.
-func rewriteRemotePlaylist(localFilePath, remoteServingEndpoint, pathPrefix string) error {
+// rewritePlaylistLocations will take a local playlist and rewrite it to have absolute URLs to a specified location.
+func rewritePlaylistLocations(localFilePath, remoteServingEndpoint, pathPrefix string) error {
f, err := os.Open(localFilePath) // nolint
if err != nil {
log.Fatalln(err)
diff --git a/core/storageproviders/s3Storage.go b/core/storageproviders/s3Storage.go
index e732333058..dbe0ce5760 100644
--- a/core/storageproviders/s3Storage.go
+++ b/core/storageproviders/s3Storage.go
@@ -136,7 +136,7 @@ func (s *S3Storage) VariantPlaylistWritten(localFilePath string) {
// MasterPlaylistWritten is called when the master hls playlist is written.
func (s *S3Storage) MasterPlaylistWritten(localFilePath string) {
// Rewrite the playlist to use absolute remote S3 URLs
- if err := rewriteRemotePlaylist(localFilePath, s.host, s.s3PathPrefix); err != nil {
+ if err := rewritePlaylistLocations(localFilePath, s.host, s.s3PathPrefix); err != nil {
log.Warnln(err)
}
}