diff options
| author | Bond-009 <bond.009@outlook.com> | 2026-07-02 19:29:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-02 19:29:06 +0200 |
| commit | 28b43838ddc633cae63e97c503d60625a3cfc77f (patch) | |
| tree | 5fef75f4c51f9c1608792b6640ee41fc7495d73d | |
| parent | 9cc25d133dc9f41b03da6bccbfd53e1a509a86c6 (diff) | |
| parent | 8ffb54603adf45975568702ca8a9d69bfe444d75 (diff) | |
Merge pull request #17206 from zachhide/fix/livetv-hls-null-mediasource
Fix NullReferenceException in GetStreamingState for closed live streams
| -rw-r--r-- | Jellyfin.Api/Helpers/StreamingHelpers.cs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Jellyfin.Api/Helpers/StreamingHelpers.cs b/Jellyfin.Api/Helpers/StreamingHelpers.cs index bae2756303..6a6aac1327 100644 --- a/Jellyfin.Api/Helpers/StreamingHelpers.cs +++ b/Jellyfin.Api/Helpers/StreamingHelpers.cs @@ -144,6 +144,15 @@ public static class StreamingHelpers mediaSource = liveStreamInfo.Item1; state.DirectStreamProvider = liveStreamInfo.Item2; + // The requested live stream is no longer open. This commonly happens when a client keeps + // polling the HLS playlist (e.g. live.m3u8) after the stream was disposed because its + // consumer count dropped to zero. GetLiveStreamWithDirectStreamProvider returns a null + // MediaSource in that case, so return 404 instead of dereferencing it below. + if (mediaSource is null) + { + throw new ResourceNotFoundException($"The live stream with id {streamingRequest.LiveStreamId} could not be found or is no longer available."); + } + // Cap the max bitrate when it is too high. This is usually due to ffmpeg is unable to probe the source liveTV streams' bitrate. if (mediaSource.FallbackMaxStreamingBitrate is not null && streamingRequest.VideoBitRate is not null) { |
