streamd: copyable m3u8 links + FHD/HD/SD output variants
Some checks failed
release / build-and-upload (push) Failing after 3m33s
Some checks failed
release / build-and-upload (push) Failing after 3m33s
- WebUI Copy button for absolute m3u8 URLs (no player) - Per-stream variants ladder; HD/SD live-transcoded as sibling HLS - variants_json in DB/API; supervisor spawns scaled ffmpeg packagers
This commit is contained in:
parent
ac8701b5a6
commit
3cb259c9b6
12 changed files with 913 additions and 62 deletions
54
apps/streamd/internal/api/variants.go
Normal file
54
apps/streamd/internal/api/variants.go
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"drmdecryption/apps/streamd/internal/db"
|
||||
)
|
||||
|
||||
// enrichVariantHealth updates each variant's health from on-disk HLS playlists.
|
||||
func (h *Handler) enrichVariantHealth(st *db.Stream) {
|
||||
if st == nil {
|
||||
return
|
||||
}
|
||||
if len(st.Variants) == 0 {
|
||||
st.Variants = db.AttachVariantStatuses(st.Name, st.VariantsJSON, st.Health, st.PlaylistAgeS)
|
||||
}
|
||||
www := strings.TrimSpace(h.WWWRoot)
|
||||
if www == "" {
|
||||
return
|
||||
}
|
||||
for i := range st.Variants {
|
||||
v := &st.Variants[i]
|
||||
if !v.Enabled {
|
||||
v.Health = "off"
|
||||
continue
|
||||
}
|
||||
if v.Height <= 0 {
|
||||
v.Health = st.Health
|
||||
v.PlaylistAgeS = st.PlaylistAgeS
|
||||
continue
|
||||
}
|
||||
dirName := st.Name + "-" + v.ID
|
||||
index := filepath.Join(www, dirName, "index.m3u8")
|
||||
fi, err := os.Stat(index)
|
||||
if err != nil {
|
||||
if st.Health == "ok" || st.Health == "starting" {
|
||||
v.Health = "starting"
|
||||
} else {
|
||||
v.Health = st.Health
|
||||
}
|
||||
continue
|
||||
}
|
||||
age := time.Since(fi.ModTime()).Seconds()
|
||||
v.PlaylistAgeS = age
|
||||
if age > 45 {
|
||||
v.Health = "down"
|
||||
} else {
|
||||
v.Health = "ok"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue