The Free Software Media System - Server Backend & API
Fix ArgumentNullException on playlist creation (#13837)
Bond-0091c2b48182a5f
diff --git a/Jellyfin.Api/Controllers/DynamicHlsController.cs b/Jellyfin.Api/Controllers/DynamicHlsController.csindex b501bae4ca..c828533621 100644--- a/Jellyfin.Api/Controllers/DynamicHlsController.cs+++ b/Jellyfin.Api/Controllers/DynamicHlsController.cs@@ -1419,9 +1419,9 @@ public class DynamicHlsController : BaseJellyfinApiControllerTranscodingJobType,cancellationTokenSource.Token).ConfigureAwait(false);-+ var mediaSourceId = state.BaseRequest.MediaSourceId;var request = new CreateMainPlaylistRequest(- Guid.Parse(state.BaseRequest.MediaSourceId),+ mediaSourceId is null ? null : Guid.Parse(mediaSourceId),state.MediaPath,state.SegmentLength * 1000,state.RunTimeTicks ?? 0,diff --git a/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs b/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.csindex ac9d30b33a..f5af500626 100644--- a/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs+++ b/src/Jellyfin.MediaEncoding.Hls/Playlist/CreateMainPlaylistRequest.cs@@ -18,7 +18,7 @@ public class CreateMainPlaylistRequest/// <param name="endpointPrefix">The URI prefix for the relative URL in the playlist.</param>/// <param name="queryString">The desired query string to append (must start with ?).</param>/// <param name="isRemuxingVideo">Whether the video is being remuxed.</param>- public CreateMainPlaylistRequest(Guid mediaSourceId, string filePath, int desiredSegmentLengthMs, long totalRuntimeTicks, string segmentContainer, string endpointPrefix, string queryString, bool isRemuxingVideo)+ public CreateMainPlaylistRequest(Guid? mediaSourceId, string filePath, int desiredSegmentLengthMs, long totalRuntimeTicks, string segmentContainer, string endpointPrefix, string queryString, bool isRemuxingVideo){MediaSourceId = mediaSourceId;FilePath = filePath;@@ -33,7 +33,7 @@ public class CreateMainPlaylistRequest/// <summary>/// Gets the media source id./// </summary>- public Guid MediaSourceId { get; }+ public Guid? MediaSourceId { get; }/// <summary>/// Gets the file path.diff --git a/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs b/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.csindex 343f3e562d..fb5027e5b5 100644--- a/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs+++ b/src/Jellyfin.MediaEncoding.Hls/Playlist/DynamicHlsPlaylistGenerator.cs@@ -35,7 +35,9 @@ public class DynamicHlsPlaylistGenerator : IDynamicHlsPlaylistGenerator{IReadOnlyList<double> segments;// For video transcodes it is sufficient with equal length segments as ffmpeg will create new keyframes- if (request.IsRemuxingVideo && TryExtractKeyframes(request.MediaSourceId, request.FilePath, out var keyframeData))+ if (request.IsRemuxingVideo+ && request.MediaSourceId is not null+ && TryExtractKeyframes(request.MediaSourceId.Value, request.FilePath, out var keyframeData)){segments = ComputeSegments(keyframeData, request.DesiredSegmentLengthMs);}