aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs
diff options
context:
space:
mode:
authorPatrick Barron <barronpm@gmail.com>2023-10-31 13:26:37 -0400
committerPatrick Barron <barronpm@gmail.com>2023-12-21 12:53:50 -0500
commit9215a4d40ae24e5996a5e16dfa296b09a7befc40 (patch)
tree9412154b3cf4f7a654a8878d23d2f7a3a1d18b5f /Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs
parentc2081955c8b2a81eb214f321697d3462709164e0 (diff)
Add ITranscodeManager service
Diffstat (limited to 'Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs')
-rw-r--r--Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs21
1 files changed, 14 insertions, 7 deletions
diff --git a/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs b/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs
index fafa2c055..5385979d4 100644
--- a/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs
+++ b/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs
@@ -4,8 +4,9 @@ using System.Net.Http;
using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
-using Jellyfin.Api.Models.StreamingDtos;
+using Jellyfin.Api.Extensions;
using MediaBrowser.Controller.MediaEncoding;
+using MediaBrowser.Controller.Streaming;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;
@@ -64,7 +65,7 @@ public static class FileStreamResponseHelpers
/// <param name="state">The current <see cref="StreamState"/>.</param>
/// <param name="isHeadRequest">Whether the current request is a HTTP HEAD request so only the headers get returned.</param>
/// <param name="httpContext">The current http context.</param>
- /// <param name="transcodingJobHelper">The <see cref="TranscodingJobHelper"/> singleton.</param>
+ /// <param name="transcodeManager">The <see cref="ITranscodeManager"/> singleton.</param>
/// <param name="ffmpegCommandLineArguments">The command line arguments to start ffmpeg.</param>
/// <param name="transcodingJobType">The <see cref="TranscodingJobType"/>.</param>
/// <param name="cancellationTokenSource">The <see cref="CancellationTokenSource"/>.</param>
@@ -73,7 +74,7 @@ public static class FileStreamResponseHelpers
StreamState state,
bool isHeadRequest,
HttpContext httpContext,
- TranscodingJobHelper transcodingJobHelper,
+ ITranscodeManager transcodeManager,
string ffmpegCommandLineArguments,
TranscodingJobType transcodingJobType,
CancellationTokenSource cancellationTokenSource)
@@ -92,22 +93,28 @@ public static class FileStreamResponseHelpers
return new OkResult();
}
- var transcodingLock = transcodingJobHelper.GetTranscodingLock(outputPath);
+ var transcodingLock = transcodeManager.GetTranscodingLock(outputPath);
await transcodingLock.WaitAsync(cancellationTokenSource.Token).ConfigureAwait(false);
try
{
TranscodingJob? job;
if (!File.Exists(outputPath))
{
- job = await transcodingJobHelper.StartFfMpeg(state, outputPath, ffmpegCommandLineArguments, httpContext.Request, transcodingJobType, cancellationTokenSource).ConfigureAwait(false);
+ job = await transcodeManager.StartFfMpeg(
+ state,
+ outputPath,
+ ffmpegCommandLineArguments,
+ httpContext.User.GetUserId(),
+ transcodingJobType,
+ cancellationTokenSource).ConfigureAwait(false);
}
else
{
- job = transcodingJobHelper.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
+ job = transcodeManager.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
state.Dispose();
}
- var stream = new ProgressiveFileStream(outputPath, job, transcodingJobHelper);
+ var stream = new ProgressiveFileStream(outputPath, job, transcodeManager);
return new FileStreamResult(stream, contentType);
}
finally