fix(player): give every transcode its own play session, and stop the one it replaces
Switching bitrate mid-film stalled playback. The server served the new playlist and then rejected its segments: 400 on hls1/main/0.ts, six times over 25 seconds, never recovering, while the UI logged "Streaming quality changed" as if nothing were wrong. Jellyfin keys a transcode job by device and play session. Every stream URL this app built carried the same hardcoded DeviceId and no PlaySessionId at all, so the second stream for an item was indistinguishable from the first and nothing ever stopped the old ffmpeg. Re-opening a stream is not rare — a quality switch, a transcoded seek and an audio-track switch all do it. Replayed against the server, a second stream opened for a live job's item alternates per attempt between serving bytes and 400ing, which is why it read as flaky rather than broken. begin_video_play_session mints a session id per open and reports the one it supersedes; the URL builder stops that job (DELETE /Videos/ActiveEncodings, un-retried — a slow stop must not delay playback) before returning. Putting it in the builder rather than in each caller covers every re-open path by construction. adopt_video_play_session takes ownership of the job the server starts itself when PlaybackInfo answers with a TranscodingUrl: without it the first switch on a stream has nothing to stop and collides with what is playing. Two client faults made the same incident worse and go with it: - The fatal-HLS-error handler added the transcode seek offset to a position that already included it. Past roughly the halfway mark of a film the doubled value cleared the "near end" threshold, so any transient network error was reported as end-of-stream and autoplay skipped to the next item — precisely when a quality switch had just made the offset large. The decision now lives in hlsRecovery.ts, against the absolute position. - The HTML5 reload primitive resolved on its own canplay timeout, so a reload the server never served reported success. The picker showed a quality that was not playing and the caller had nothing to revert. TRACES: UR-074, UR-004 | DR-177 | UT-173, UT-174, UT-175
This commit is contained in:
@@ -555,18 +555,6 @@ impl OnlineRepository {
|
||||
("SegmentContainer", "ts".to_string()),
|
||||
("TranscodingContainer", "ts".to_string()),
|
||||
("TranscodingProtocol", "hls".to_string()),
|
||||
// Say "no subtitle" rather than leaving the choice open. An omitted
|
||||
// index is not neutral: the server then picks the source's own
|
||||
// default/forced track, and an image-based one can only be delivered
|
||||
// by burning it into the picture (DR-176). The negotiation already
|
||||
// sends this sentinel, but most streams are opened by rebuilding
|
||||
// *this* URL — a quality switch, a transcoded seek, an audio-track
|
||||
// switch — so it has to hold here too, independently of whatever
|
||||
// session state the server still holds.
|
||||
(
|
||||
"SubtitleStreamIndex",
|
||||
super::device_profile::playback_subtitle_stream_index().to_string(),
|
||||
),
|
||||
];
|
||||
|
||||
// Scale the picture down to what the budget can carry. Omitted for the
|
||||
@@ -1000,28 +988,15 @@ impl JellyfinItem {
|
||||
media_streams: self.media_streams.map(|streams| {
|
||||
streams
|
||||
.into_iter()
|
||||
.map(|s| {
|
||||
let kind = crate::domain::stream_kind_from_jellyfin(&s.stream_type);
|
||||
// Only a subtitle can be a sidecar; asked of anything
|
||||
// else the question has no answer. TRACES: UR-020 |
|
||||
// DR-176 | UT-168
|
||||
let supports_external_delivery =
|
||||
(kind == crate::domain::StreamKind::Subtitle).then(|| {
|
||||
super::device_profile::subtitle_supports_external_delivery(
|
||||
s.codec.as_deref(),
|
||||
)
|
||||
});
|
||||
crate::repository::types::MediaStream {
|
||||
kind,
|
||||
stream_type: s.stream_type,
|
||||
codec: s.codec,
|
||||
language: s.language,
|
||||
display_title: s.display_title,
|
||||
index: s.index,
|
||||
is_default: s.is_default,
|
||||
is_forced: s.is_forced,
|
||||
supports_external_delivery,
|
||||
}
|
||||
.map(|s| crate::repository::types::MediaStream {
|
||||
kind: crate::domain::stream_kind_from_jellyfin(&s.stream_type),
|
||||
stream_type: s.stream_type,
|
||||
codec: s.codec,
|
||||
language: s.language,
|
||||
display_title: s.display_title,
|
||||
index: s.index,
|
||||
is_default: s.is_default,
|
||||
is_forced: s.is_forced,
|
||||
})
|
||||
.collect()
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user