streamd: optional keys, per-stream proxy, auto deps; agent module.yaml sync; RTE AutoPlay; Telegram release announces
- streamd: MPD-only start, proxy field, ffmpeg/NRE/mp4decrypt auto-install - GET/PUT /api/modules for module.yaml sync; agent sync_modules - RTE Live-tab AutoPlay fixes; modules zip named bbc/rte/tg4.zip - Telegram notify scripts wired into Forgejo release workflows
This commit is contained in:
parent
f9c28be3f1
commit
ac8701b5a6
36 changed files with 1460 additions and 143 deletions
|
|
@ -101,13 +101,13 @@ func (m *Media) Start(id int64) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(st.MPD) == "" || strings.TrimSpace(st.Key) == "" {
|
||||
if strings.TrimSpace(st.MPD) == "" {
|
||||
_ = m.Store.SetRuntime(id, db.RuntimePatch{
|
||||
Health: "down",
|
||||
PlayPath: "/hls/" + st.Name + "/index.m3u8",
|
||||
LastError: "missing mpd/key - capture required",
|
||||
LastError: "missing mpd — paste a manifest URL (keys optional for clear streams)",
|
||||
})
|
||||
return fmt.Errorf("missing mpd/key")
|
||||
return fmt.Errorf("missing mpd")
|
||||
}
|
||||
mpdURL := strings.TrimSpace(st.MPD)
|
||||
if !strings.HasPrefix(strings.ToLower(mpdURL), "http://") && !strings.HasPrefix(strings.ToLower(mpdURL), "https://") {
|
||||
|
|
@ -151,9 +151,12 @@ func (m *Media) Start(id int64) error {
|
|||
}
|
||||
|
||||
keysFile := filepath.Join(workDir, "keys.txt")
|
||||
keysBody := normalizeKeysFile(st.Key)
|
||||
if err := os.WriteFile(keysFile, []byte(keysBody), 0o644); err != nil {
|
||||
return err
|
||||
hasKeys := strings.TrimSpace(st.Key) != ""
|
||||
if hasKeys {
|
||||
keysBody := normalizeKeysFile(st.Key)
|
||||
if err := os.WriteFile(keysFile, []byte(keysBody), 0o644); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
saveName := st.Name
|
||||
|
|
@ -167,7 +170,7 @@ func (m *Media) Start(id int64) error {
|
|||
// The rewriter is named by the stream row or its app module and looked up in
|
||||
// the mpd registry, so streamd needs no knowledge of any provider.
|
||||
if rw, needed := mpd.Lookup(cfg.Rewriter); needed && strings.TrimSpace(st.MPD) != "" && !cfg.IsHLS {
|
||||
srv, err := mpd.StartLocal(st.MPD, st.Key, headers, rw)
|
||||
srv, err := mpd.StartLocal(st.MPD, st.Key, headers, rw, st.Proxy)
|
||||
if err != nil {
|
||||
_ = m.Store.SetRuntime(id, db.RuntimePatch{
|
||||
Health: "down", PlayPath: "/hls/" + st.Name + "/index.m3u8",
|
||||
|
|
@ -189,12 +192,8 @@ func (m *Media) Start(id int64) error {
|
|||
liveWait := strconv.Itoa(cfg.LiveWait)
|
||||
nreArgs := []string{
|
||||
manifestURL,
|
||||
// Multi-KID SAMPLE-AES streams rainbow-decrypt with a single --key, so
|
||||
// always feed every KID:KEY via --key-text-file.
|
||||
"--key-text-file", keysFile,
|
||||
"--live-real-time-merge",
|
||||
"--live-pipe-mux",
|
||||
"--mp4-real-time-decryption",
|
||||
"--live-wait-time", liveWait,
|
||||
"--ffmpeg-binary-path", m.FFmpeg,
|
||||
"--save-name", saveName,
|
||||
|
|
@ -204,6 +203,19 @@ func (m *Media) Start(id int64) error {
|
|||
"--log-level", "ERROR",
|
||||
"-ss", "0",
|
||||
}
|
||||
if hasKeys {
|
||||
// Multi-KID SAMPLE-AES streams rainbow-decrypt with a single --key, so
|
||||
// always feed every KID:KEY via --key-text-file.
|
||||
nreArgs = append(nreArgs,
|
||||
"--key-text-file", keysFile,
|
||||
"--mp4-real-time-decryption",
|
||||
)
|
||||
}
|
||||
if proxy := strings.TrimSpace(st.Proxy); proxy != "" {
|
||||
// NRE prefers --custom-proxy over the system proxy when both are set.
|
||||
nreArgs = append(nreArgs, "--custom-proxy", proxy)
|
||||
m.logf("stream %s: origin proxy %s", st.Name, proxy)
|
||||
}
|
||||
// A synthetic manifest publishes exactly one video + audio pair, and an HLS
|
||||
// master's variants rarely match a resolution/language filter, so in both
|
||||
// cases take the best rendition instead of the configured selectors.
|
||||
|
|
@ -212,7 +224,7 @@ func (m *Media) Start(id int64) error {
|
|||
} else {
|
||||
nreArgs = append(nreArgs, "-sv", cfg.VideoSelect, "-sa", cfg.AudioSelect)
|
||||
}
|
||||
if m.MP4Decrypt != "" {
|
||||
if hasKeys && m.MP4Decrypt != "" {
|
||||
nreArgs = append(nreArgs,
|
||||
"--decryption-engine", "MP4DECRYPT",
|
||||
"--decryption-binary-path", m.MP4Decrypt,
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ func (s *Stub) Start(id int64) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if st.MPD == "" || st.Key == "" {
|
||||
if st.MPD == "" {
|
||||
_, err = s.Store.DB.Exec(`
|
||||
INSERT INTO stream_runtime(stream_id,health,play_path,last_error,updated_at)
|
||||
VALUES(?,?,?,?,?)
|
||||
ON CONFLICT(stream_id) DO UPDATE SET health=excluded.health, last_error=excluded.last_error, updated_at=excluded.updated_at`,
|
||||
id, "down", "/hls/"+st.Name+"/index.m3u8", "missing mpd/key - capture required", time.Now().UTC().Format(time.RFC3339))
|
||||
return err
|
||||
id, "down", "/hls/"+st.Name+"/index.m3u8", "missing mpd", time.Now().UTC().Format(time.RFC3339))
|
||||
return fmt.Errorf("missing mpd")
|
||||
}
|
||||
pid := 10000 + int(id)
|
||||
s.pids[id] = pid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue