同步上游 0921 版 zip(新增 emby 播放等 20 处变更)
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
func plannedFixture(t *testing.T, app *UIApp, episode, version int, mode string) playbackMediaPlan {
|
||||
t.Helper()
|
||||
app.mediaResources().settings.Enabled = true
|
||||
body, _ := json.Marshal(map[string]any{"session": "fixture", "episode": episode, "version": version, "start": 1.25, "mode": mode,
|
||||
"client": playbackClientCapabilities{MP4: true, NativeHLS: true, HlsJS: true, Video: []string{"h264"}, Audio: []string{"aac"}}})
|
||||
request := httptest.NewRequest(http.MethodPost, "http://localhost/api/ui/playback/plan", bytes.NewReader(body))
|
||||
@@ -165,6 +166,28 @@ func playbackDecodedFrames(t *testing.T, ffmpeg, address string) []string {
|
||||
return frames
|
||||
}
|
||||
|
||||
func TestPlaybackGeneratedInitializationPathMatchesPlaylist(t *testing.T) {
|
||||
directory := filepath.Join(t.TempDir(), "media cache")
|
||||
args := playbackGeneratedArgs(providerMedia{}, "input.mp4", directory, "remux")
|
||||
playlist := args[len(args)-1]
|
||||
var init, segment string
|
||||
for i := 0; i+1 < len(args); i++ {
|
||||
switch args[i] {
|
||||
case "-hls_fmp4_init_filename":
|
||||
init = args[i+1]
|
||||
case "-hls_segment_filename":
|
||||
segment = args[i+1]
|
||||
}
|
||||
}
|
||||
if init != "init.mp4" || strings.ContainsAny(playlist+segment, "\\") || !strings.HasSuffix(segment, "/%06d.m4s") {
|
||||
t.Fatalf("FFmpeg output paths are not portable: %q", args)
|
||||
}
|
||||
resolvedInit := playlist[:strings.LastIndex(playlist, "/")+1] + init
|
||||
if resolvedInit != filepath.ToSlash(filepath.Join(directory, "init.mp4")) {
|
||||
t.Fatalf("FFmpeg would write its initialization segment outside the media directory: %q", resolvedInit)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlaybackGeneratedPreservesLongGOPAndAudioOnlyVideo(t *testing.T) {
|
||||
app, fixture := nativePlaybackFixture(t, "10", "320x180")
|
||||
ffmpeg := app.downloader.cfg.FFmpeg
|
||||
@@ -296,14 +319,16 @@ func TestPlaybackOriginalHLSURIHeadersAndByteRanges(t *testing.T) {
|
||||
func TestPlaybackResourceBudgetsCancellationAndPersistence(t *testing.T) {
|
||||
app, admin := administratorFixture(t)
|
||||
settings := defaultPlaybackSettings()
|
||||
settings.Enabled = true
|
||||
settings.MaxVideoTranscodes, settings.MaxMediaRequests = 0, 1
|
||||
response := admin.request(t, http.MethodPost, "/api/ui/admin/playback", settings)
|
||||
if response.Code != 200 {
|
||||
t.Fatal(response.Code, response.Body.String())
|
||||
}
|
||||
restarted := &UIApp{cfg: app.cfg}
|
||||
if restarted.mediaResources().snapshot().MaxVideoTranscodes != 0 {
|
||||
t.Fatal("disabled video processing did not persist")
|
||||
saved := restarted.mediaResources().snapshot()
|
||||
if !saved.Enabled || saved.MaxVideoTranscodes != 0 {
|
||||
t.Fatal("explicit playback settings did not persist")
|
||||
}
|
||||
resources := app.mediaResources()
|
||||
if _, err := resources.acquire(context.Background(), "video", false); err == nil {
|
||||
@@ -338,6 +363,7 @@ func TestPlaybackResourceBudgetsCancellationAndPersistence(t *testing.T) {
|
||||
|
||||
func TestEmbyOriginalMP4SignedRangeWithoutCookies(t *testing.T) {
|
||||
app, fixture := nativePlaybackFixture(t, "4", "320x180")
|
||||
app.mediaResources().settings.Enabled = true
|
||||
key, err := app.embySigningKey(true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user