streamd: preview quality picker, dashboard polish, C4 wrap keys
- Preview player can select FHD/HD/SD (or ABR master) from publish links - Embed dashboard screenshots in README; Linux streamd+agent setup guide - C4 Widevine wrap license mode + require --wvd; prefer Widevine PSSH - Channel 4 and My5 modules; streamd auth, variants, schedules, HLS gate
This commit is contained in:
parent
b3955bd81e
commit
066e018749
113 changed files with 19002 additions and 1541 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package worker
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
|
@ -12,6 +13,7 @@ import (
|
|||
|
||||
"drmdecryption/apps/agent/internal/client"
|
||||
"drmdecryption/apps/agent/internal/device"
|
||||
"drmdecryption/apps/agent/internal/poller"
|
||||
"drmdecryption/apps/agent/internal/queue"
|
||||
)
|
||||
|
||||
|
|
@ -69,6 +71,8 @@ func (w *Worker) tick() {
|
|||
return
|
||||
}
|
||||
w.logf("job=%d failed: %v", job.ID, err)
|
||||
w.event(job, client.EventCaptureFailed, err.Error(),
|
||||
map[string]any{"attempts": job.Attempts + 1, "max_attempts": job.MaxAttempts})
|
||||
_ = w.Queue.MarkFailed(job.ID, err.Error(), false)
|
||||
return
|
||||
}
|
||||
|
|
@ -80,6 +84,11 @@ func isAuthErr(err error) bool {
|
|||
if err == nil {
|
||||
return false
|
||||
}
|
||||
// The client now returns a typed error with an actionable message; the
|
||||
// substring check stays as a fallback for errors raised elsewhere.
|
||||
if errors.Is(err, client.ErrUnauthorized) {
|
||||
return true
|
||||
}
|
||||
s := strings.ToLower(err.Error())
|
||||
return strings.Contains(s, "401") || strings.Contains(s, "unauthorized")
|
||||
}
|
||||
|
|
@ -98,6 +107,10 @@ func (w *Worker) runJob(job queue.Job) error {
|
|||
return err
|
||||
}
|
||||
label := fmt.Sprintf("job-%d:%s", job.ID, job.StreamName)
|
||||
// Tell streamd a capture is under way, so the stream's timeline in the
|
||||
// dashboard shows it rather than just an unexplained "down".
|
||||
w.event(job, client.EventCaptureStarted,
|
||||
fmt.Sprintf("capture started on %s (%s)", w.AgentID, job.Reason), nil)
|
||||
c, serial, err := w.Pool.Acquire(a.Package(), label)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -137,9 +150,31 @@ func (w *Worker) runJob(job queue.Job) error {
|
|||
if err := w.API.PostCredentials(job.StreamID, cred); err != nil {
|
||||
return fmt.Errorf("post credentials: %w", err)
|
||||
}
|
||||
// Report what was captured, never the key itself.
|
||||
w.event(job, client.EventCaptureOK, "credentials captured and posted", map[string]any{
|
||||
"device": serial,
|
||||
"has_key": strings.TrimSpace(res.Key) != "",
|
||||
"key_valid": poller.ValidKeyPair(res.Key),
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
// event posts a stream event to streamd. A timeline entry is never worth
|
||||
// failing a capture over, so errors are logged and dropped.
|
||||
func (w *Worker) event(job queue.Job, kind, message string, detail map[string]any) {
|
||||
if w.API == nil || job.StreamID == 0 {
|
||||
return
|
||||
}
|
||||
if detail == nil {
|
||||
detail = map[string]any{}
|
||||
}
|
||||
detail["agent_id"] = w.AgentID
|
||||
detail["job_id"] = job.ID
|
||||
if err := w.API.PostEvent(job.StreamID, kind, message, detail); err != nil {
|
||||
w.logf("job=%d: could not report %s to streamd: %v", job.ID, kind, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *Worker) logf(format string, args ...any) {
|
||||
prefix := fmt.Sprintf("worker/%d: ", w.ID)
|
||||
if w.Log != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue