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
|
|
@ -44,7 +44,7 @@ func register(t *testing.T, f *fakeApp) {
|
|||
|
||||
func TestSettingsComeFromTheAppModule(t *testing.T) {
|
||||
register(t, &fakeApp{name: "fakedash", rewriter: "fakedash", liveWait: 3, tsBytes: 111})
|
||||
got := settingsFor(db.Stream{App: "fakedash", MPD: "https://origin.test/manifest.mpd"})
|
||||
got := settingsFor(db.Stream{App: "fakedash", MPD: "https://origin.test/manifest.mpd"}, db.PackagerSettings{})
|
||||
if got.Rewriter != "fakedash" {
|
||||
t.Errorf("rewriter = %q, want fakedash", got.Rewriter)
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ func TestStoredSettingsOverrideTheModule(t *testing.T) {
|
|||
MPD: "https://origin.test/manifest.mpd",
|
||||
VideoSelect: "res=1920x1080:for=best",
|
||||
Rewriter: "none",
|
||||
})
|
||||
}, db.PackagerSettings{})
|
||||
if got.VideoSelect != "res=1920x1080:for=best" {
|
||||
t.Errorf("video select = %q, want the stored value", got.VideoSelect)
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ func TestStoredSettingsOverrideTheModule(t *testing.T) {
|
|||
|
||||
// An unknown app must not inherit any provider's preferences.
|
||||
func TestUnknownAppGetsNeutralDefaults(t *testing.T) {
|
||||
got := settingsFor(db.Stream{App: "nosuchapp", MPD: "https://origin.test/manifest.mpd"})
|
||||
got := settingsFor(db.Stream{App: "nosuchapp", MPD: "https://origin.test/manifest.mpd"}, db.PackagerSettings{})
|
||||
if got.VideoSelect != "for=best" || got.AudioSelect != "for=best" {
|
||||
t.Errorf("selectors = %q / %q, want for=best", got.VideoSelect, got.AudioSelect)
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ func TestUnknownAppGetsNeutralDefaults(t *testing.T) {
|
|||
// HLS gets more buffering and a longer live wait, by manifest shape and not by
|
||||
// matching a stream name.
|
||||
func TestHLSDetectionByManifestShape(t *testing.T) {
|
||||
got := settingsFor(db.Stream{App: "", MPD: "https://cdn.test/x/playlist-hls-dvr.m3u8"})
|
||||
got := settingsFor(db.Stream{App: "", MPD: "https://cdn.test/x/playlist-hls-dvr.m3u8"}, db.PackagerSettings{})
|
||||
if !got.IsHLS {
|
||||
t.Fatal("an .m3u8 manifest should be detected as HLS")
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func TestHLSDetectionByManifestShape(t *testing.T) {
|
|||
t.Errorf("tsReadyBytes = %d, want %d", got.TSReadyBytes, hlsTSReadyBytes)
|
||||
}
|
||||
// The old code keyed this off stream names like "tg4"/"cula"/"plus".
|
||||
named := settingsFor(db.Stream{Name: "tg4-ioi", MPD: "https://origin.test/manifest.mpd"})
|
||||
named := settingsFor(db.Stream{Name: "tg4-ioi", MPD: "https://origin.test/manifest.mpd"}, db.PackagerSettings{})
|
||||
if named.TSReadyBytes != defaultTSReadyBytes {
|
||||
t.Error("buffering must not be chosen by stream name any more")
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ func TestHLSDetectionByManifestShape(t *testing.T) {
|
|||
// A module's rewriter is only used if it registered one under that name.
|
||||
func TestRewriterLookupGatesTheRewrite(t *testing.T) {
|
||||
register(t, &fakeApp{name: "fakeunregistered", rewriter: "fakeunregistered"})
|
||||
cfg := settingsFor(db.Stream{App: "fakeunregistered", MPD: "https://origin.test/manifest.mpd"})
|
||||
cfg := settingsFor(db.Stream{App: "fakeunregistered", MPD: "https://origin.test/manifest.mpd"}, db.PackagerSettings{})
|
||||
if _, needed := mpd.Lookup(cfg.Rewriter); needed {
|
||||
t.Error("an unregistered rewriter name must not trigger a rewrite")
|
||||
}
|
||||
|
|
@ -127,3 +127,63 @@ type stubRewriter struct{}
|
|||
|
||||
func (stubRewriter) Name() string { return "fakeunregistered" }
|
||||
func (stubRewriter) Rewrite(in []byte, _ string) ([]byte, error) { return in, nil }
|
||||
|
||||
// The resolution chain is: stream row, then app module, then the
|
||||
// installation-wide settings, then the compiled-in defaults.
|
||||
func TestGlobalSettingsSitBelowTheModule(t *testing.T) {
|
||||
globals := db.PackagerSettings{HLSTime: 6, HLSListSize: 30, LiveWait: 9, TSReadyBytes: 999}
|
||||
|
||||
// Nothing more specific: the global layer applies.
|
||||
got := settingsFor(db.Stream{MPD: "https://origin.test/manifest.mpd"}, globals)
|
||||
if got.HLSTime != 6 || got.HLSListSize != 30 {
|
||||
t.Errorf("hls_time=%d list_size=%d, want the global values", got.HLSTime, got.HLSListSize)
|
||||
}
|
||||
if got.LiveWait != 9 || got.TSReadyBytes != 999 {
|
||||
t.Errorf("liveWait=%d tsReady=%d, want the global values", got.LiveWait, got.TSReadyBytes)
|
||||
}
|
||||
|
||||
// A module declaration beats the global layer.
|
||||
register(t, &fakeApp{name: "fakeglobals", rewriter: "none", liveWait: 4, tsBytes: 222})
|
||||
got = settingsFor(db.Stream{App: "fakeglobals", MPD: "https://origin.test/manifest.mpd"}, globals)
|
||||
if got.LiveWait != 4 || got.TSReadyBytes != 222 {
|
||||
t.Errorf("liveWait=%d tsReady=%d, want the module values", got.LiveWait, got.TSReadyBytes)
|
||||
}
|
||||
// ...but the global packager knobs still apply, since no module declares them.
|
||||
if got.HLSTime != 6 {
|
||||
t.Errorf("hls_time = %d, want the global 6", got.HLSTime)
|
||||
}
|
||||
}
|
||||
|
||||
// A per-stream settings_json override beats everything else.
|
||||
func TestPerStreamSettingsWinOverAllLayers(t *testing.T) {
|
||||
register(t, &fakeApp{name: "fakeperstream", rewriter: "none", liveWait: 4, tsBytes: 222})
|
||||
globals := db.PackagerSettings{HLSTime: 6, HLSListSize: 30, LiveWait: 9}
|
||||
got := settingsFor(db.Stream{
|
||||
App: "fakeperstream",
|
||||
MPD: "https://origin.test/manifest.mpd",
|
||||
SettingsJSON: `{"hls_time":2,"hls_list_size":8,"live_wait":1}`,
|
||||
}, globals)
|
||||
if got.HLSTime != 2 || got.HLSListSize != 8 || got.LiveWait != 1 {
|
||||
t.Errorf("got hls_time=%d list_size=%d live_wait=%d, want the per-stream 2/8/1",
|
||||
got.HLSTime, got.HLSListSize, got.LiveWait)
|
||||
}
|
||||
}
|
||||
|
||||
// Nonsense in settings_json must be ignored rather than handed to ffmpeg,
|
||||
// where a zero segment duration would produce an unplayable stream.
|
||||
func TestInsaneSettingsAreIgnored(t *testing.T) {
|
||||
for _, raw := range []string{
|
||||
`{"hls_time":0}`, `{"hls_time":-5}`, `{"hls_time":9999}`,
|
||||
`{"hls_list_size":0}`, `not json at all`, ``,
|
||||
} {
|
||||
got := settingsFor(db.Stream{
|
||||
MPD: "https://origin.test/manifest.mpd", SettingsJSON: raw,
|
||||
}, db.PackagerSettings{})
|
||||
if got.HLSTime != defaultHLSTime {
|
||||
t.Errorf("settings_json %q gave hls_time=%d, want the default %d", raw, got.HLSTime, defaultHLSTime)
|
||||
}
|
||||
if got.HLSListSize != defaultHLSListSize {
|
||||
t.Errorf("settings_json %q gave list_size=%d, want the default %d", raw, got.HLSListSize, defaultHLSListSize)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue