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
|
|
@ -82,6 +82,14 @@ func loadCfg(sub string, args []string) (config.Config, *flag.FlagSet) {
|
|||
return cfg, fs
|
||||
}
|
||||
|
||||
// newAPI builds the streamd client with this agent's identity attached, so
|
||||
// audit rows in streamd name the agent and not just its API key.
|
||||
func newAPI(cfg config.Config) *client.Client {
|
||||
c := client.New(cfg.StreamdURL, cfg.Token)
|
||||
c.AgentID = cfg.AgentID
|
||||
return c
|
||||
}
|
||||
|
||||
func openQueue(cfg config.Config) *queue.Store {
|
||||
q, err := queue.Open(cfg.DataDir)
|
||||
if err != nil {
|
||||
|
|
@ -92,10 +100,22 @@ func openQueue(cfg config.Config) *queue.Store {
|
|||
|
||||
func runCmd(sub string, args []string) {
|
||||
cfg, _ := loadCfg(sub, args)
|
||||
api := client.New(cfg.StreamdURL, cfg.Token)
|
||||
api := newAPI(cfg)
|
||||
if err := api.Health(); err != nil {
|
||||
log.Fatalf("streamd unreachable at %s: %v", cfg.StreamdURL, err)
|
||||
}
|
||||
// Health says the server is up; /api/me says our credential actually
|
||||
// works. Without this a missing or revoked key failed silently on every
|
||||
// poll instead of once, loudly, at startup.
|
||||
me, err := api.Me()
|
||||
if err != nil {
|
||||
log.Fatalf("streamd rejected this agent at %s: %v", cfg.StreamdURL, err)
|
||||
}
|
||||
if me.Role != "operator" && me.Role != "admin" {
|
||||
log.Fatalf("this agent's credential has role %q, but capturing needs at least `operator` — "+
|
||||
"create an operator API key in the streamd dashboard", me.Role)
|
||||
}
|
||||
log.Printf("authenticated to streamd as %q (role %s)", me.Name, me.Role)
|
||||
q := openQueue(cfg)
|
||||
defer q.Close()
|
||||
|
||||
|
|
@ -129,6 +149,28 @@ func runCmd(sub string, args []string) {
|
|||
}
|
||||
|
||||
ws := wsclient.New(cfg.StreamdURL, cfg.Token, cfg.AgentID, log.Default())
|
||||
// streamd pushes a capture request when a viewer wakes an on-demand
|
||||
// stream or a scheduled event is about to start. Reacting here is what
|
||||
// makes those responsive instead of up to one poll interval late.
|
||||
ws.OnCapture = func(streamID int64, name, app, channel, reason string) {
|
||||
if cfg.PushedCapturesArePriority() {
|
||||
p.EnqueueNow(streamID, name, app, channel, reason)
|
||||
return
|
||||
}
|
||||
if j, added, err := q.EnqueueIfIdle(streamID, name, app, channel, reason, cfg.MaxAttempts); err != nil {
|
||||
log.Printf("pushed capture for %s failed: %v", name, err)
|
||||
} else if added {
|
||||
log.Printf("enqueued job=%d stream=%s reason=%s (pushed by streamd)", j.ID, name, reason)
|
||||
}
|
||||
}
|
||||
// A stream was edited: re-poll now rather than waiting out the interval.
|
||||
ws.OnStreamChanged = func(name, reason string) {
|
||||
go func() {
|
||||
if err := p.Once(); err != nil {
|
||||
log.Printf("re-poll after change to %s: %v", name, err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
go ws.Loop()
|
||||
|
||||
for i := 0; i < cfg.Workers; i++ {
|
||||
|
|
@ -211,7 +253,7 @@ func enqueueCmd(args []string) {
|
|||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
api := client.New(cfg.StreamdURL, cfg.Token)
|
||||
api := newAPI(cfg)
|
||||
streams, err := api.ListStreams()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue