Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/jellycompat/handlers_playback.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,7 @@ func NewPlaybackHandler(
TranscodeDir: h.TranscodeDir,
FFmpegPath: h.FFmpegPath,
HWAccel: h.HWAccel,
HWDevice: h.localHWDevice(),
SegmentRetentionSeconds: h.segmentRetentionSeconds(),
}
}
Expand Down Expand Up @@ -1497,6 +1498,15 @@ func (h *PlaybackHandler) scheduleCompatAdminEndRetry(upstreamSessionID string,
})
}

// localHWDevice is the configured playback.hw_device for transcodes this API
// host runs itself. Remote dispatch resolves the executor's own device instead.
func (h *PlaybackHandler) localHWDevice() string {
if h.cfg == nil {
return ""
}
return h.cfg.Playback.HWDevice
}

func (h *PlaybackHandler) segmentRetentionSeconds() int {
if h.SegmentRetentionSeconds != nil {
return h.SegmentRetentionSeconds()
Expand Down
57 changes: 57 additions & 0 deletions internal/jellycompat/local_hw_device_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package jellycompat

import (
"os"
"path/filepath"
"testing"
"time"

"github.com/Silo-Server/silo-server/internal/config"
"github.com/Silo-Server/silo-server/internal/models"
"github.com/Silo-Server/silo-server/internal/playback"
)

// A Jellyfin client's transcode on the API host must run on the configured
// playback.hw_device, the same device the native path and jellycompat's own
// tone-map probe use, not on whichever render node sorts first.
func TestLocalCompatTranscodeUsesConfiguredHWDevice(t *testing.T) {
const device = "/dev/dri/renderD199"
// The fake ffmpeg never writes a manifest; don't wait the full startup budget.
previousTimeout := compatManifestStartupTimeout
compatManifestStartupTimeout = 100 * time.Millisecond
t.Cleanup(func() { compatManifestStartupTimeout = previousTimeout })
version := testCompatVersion()
version.AudioTracks[0].Channels = 2
source := testCompatSource(NewResourceIDCodec(), version)
inputPath := filepath.Join(t.TempDir(), "movie.mkv")
if err := os.WriteFile(inputPath, []byte("video"), 0o644); err != nil {
t.Fatal(err)
}
store := NewPlaybackSessionStore(time.Hour, nil)
store.Put(PlaybackSession{
ID: "play-1", CompatToken: "token-1", UpstreamSessionID: "upstream-1", UpstreamPlayMethod: "transcode",
MediaSources: []PlaybackMediaSource{source},
})
manager := &testCompatSessionManager{sessions: map[string]*playback.Session{
"upstream-1": {ID: "upstream-1", UserID: 7, ProfileID: "profile-1", MediaFileID: version.FileID, PlayMethod: playback.PlayTranscode, BasePlayMethod: playback.PlayTranscode},
}}
cfg := &config.Config{}
cfg.Playback.HWAccel = "vaapi"
cfg.Playback.HWDevice = device
cfg.Playback.TranscodeDir = t.TempDir()
cfg.Playback.FFmpegPath = writeCompatTestFFmpeg(t)
handler := NewPlaybackHandler(cfg, nil, nil, nil, store, manager,
testCompatFileResolver{file: &models.MediaFile{ID: version.FileID, FilePath: inputPath}}, nil)

if got := handler.tm.Config().HWDevice; got != device {
t.Fatalf("reconstruction runtime HWDevice = %q, want %q", got, device)
}
transcodeSession, err := handler.ensureTranscodeSession(t.Context(), "play-1", "upstream-1", source)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = transcodeSession.Close() })
if got := transcodeSession.Opts().HWDevice; got != device {
t.Fatalf("local transcode HWDevice = %q, want %q", got, device)
}
}
1 change: 1 addition & 0 deletions internal/jellycompat/streams.go
Original file line number Diff line number Diff line change
Expand Up @@ -3387,6 +3387,7 @@ func (h *PlaybackHandler) ensureTranscodeSessionWithToneMapMode(
VideoSampleEntry: compatSourceVideoSampleEntry(source),
FFmpegPath: h.FFmpegPath,
HWAccel: h.HWAccel,
HWDevice: h.localHWDevice(),
Comment thread
Quick104 marked this conversation as resolved.
Resolved
AudioTrackIndex: audioTrackIndex,
RequireAudioTrack: compatRequiresAudioTrack(source),
SourceAudioChannels: sourceAudioChannels,
Expand Down