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
|
|
@ -25,6 +25,7 @@ type Handler struct {
|
|||
Supervisor Supervisor
|
||||
StartedAt time.Time
|
||||
Deps deps.Status
|
||||
WWWRoot string // data/www — used to report variant playlist health
|
||||
}
|
||||
|
||||
func (h *Handler) Mount(mux *http.ServeMux) {
|
||||
|
|
@ -83,6 +84,9 @@ func (h *Handler) streams(w http.ResponseWriter, r *http.Request) {
|
|||
if list == nil {
|
||||
list = []db.Stream{}
|
||||
}
|
||||
for i := range list {
|
||||
h.enrichVariantHealth(&list[i])
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{"streams": list})
|
||||
case http.MethodPost:
|
||||
if !h.auth(w, r) {
|
||||
|
|
@ -98,6 +102,7 @@ func (h *Handler) streams(w http.ResponseWriter, r *http.Request) {
|
|||
writeErr(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
h.enrichVariantHealth(&st)
|
||||
writeJSON(w, http.StatusCreated, st)
|
||||
default:
|
||||
writeErr(w, http.StatusMethodNotAllowed, "method not allowed")
|
||||
|
|
@ -133,6 +138,7 @@ func (h *Handler) streamAction(w http.ResponseWriter, r *http.Request) {
|
|||
writeErr(w, http.StatusNotFound, "not found")
|
||||
return
|
||||
}
|
||||
h.enrichVariantHealth(&st)
|
||||
writeJSON(w, http.StatusOK, st)
|
||||
|
||||
case action == "" && (r.Method == http.MethodPatch || r.Method == http.MethodPut):
|
||||
|
|
@ -150,8 +156,8 @@ func (h *Handler) streamAction(w http.ResponseWriter, r *http.Request) {
|
|||
writeErr(w, http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
// Editing mpd/key/headers must tear down the live media worker and
|
||||
// bring up a fresh instance with the new credentials.
|
||||
// Editing mpd/key/headers/variants must tear down the live media worker
|
||||
// and bring up a fresh instance with the new credentials.
|
||||
if h.Supervisor != nil && credentialsChanged(before, st, in) {
|
||||
if st.Enabled {
|
||||
_ = h.Supervisor.Restart(id)
|
||||
|
|
@ -160,6 +166,7 @@ func (h *Handler) streamAction(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
st, _ = h.Store.GetStream(id)
|
||||
}
|
||||
h.enrichVariantHealth(&st)
|
||||
writeJSON(w, http.StatusOK, st)
|
||||
|
||||
case action == "" && r.Method == http.MethodDelete:
|
||||
|
|
@ -315,8 +322,8 @@ func writeErr(w http.ResponseWriter, code int, msg string) {
|
|||
writeJSON(w, code, map[string]any{"error": msg})
|
||||
}
|
||||
|
||||
// credentialsChanged is true when the patch touched mpd, key, headers, or proxy
|
||||
// that the live NRE/ffmpeg worker is already using.
|
||||
// credentialsChanged is true when the patch touched mpd, key, headers, proxy,
|
||||
// or variants that the live NRE/ffmpeg worker is already using.
|
||||
func credentialsChanged(before, after db.Stream, in db.PatchStream) bool {
|
||||
if in.MPD != nil && strings.TrimSpace(before.MPD) != strings.TrimSpace(after.MPD) {
|
||||
return true
|
||||
|
|
@ -330,5 +337,10 @@ func credentialsChanged(before, after db.Stream, in db.PatchStream) bool {
|
|||
if in.Proxy != nil && strings.TrimSpace(before.Proxy) != strings.TrimSpace(after.Proxy) {
|
||||
return true
|
||||
}
|
||||
if in.VariantsJSON != nil || len(in.Variants) > 0 {
|
||||
if strings.TrimSpace(before.VariantsJSON) != strings.TrimSpace(after.VariantsJSON) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue