mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-28 19:54:48 +03:00
update task results
This commit is contained in:
@@ -113,11 +113,11 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
|
||||
/// <returns>Task.</returns>
|
||||
protected object ProcessRequest(StreamRequest request, bool isHeadRequest)
|
||||
protected async Task<object> ProcessRequest(StreamRequest request, bool isHeadRequest)
|
||||
{
|
||||
var cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
var state = GetState(request, cancellationTokenSource.Token).Result;
|
||||
var state = await GetState(request, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
|
||||
var responseHeaders = new Dictionary<string, string>();
|
||||
|
||||
@@ -128,7 +128,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
using (state)
|
||||
{
|
||||
return GetStaticRemoteStreamResult(state, responseHeaders, isHeadRequest, cancellationTokenSource).Result;
|
||||
return await GetStaticRemoteStreamResult(state, responseHeaders, isHeadRequest, cancellationTokenSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +139,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
}
|
||||
|
||||
var outputPath = state.OutputFilePath;
|
||||
var outputPathExists = FileSystem.FileExists(outputPath);
|
||||
var outputPathExists = FileSystem.FileExists(outputPath);
|
||||
|
||||
var isTranscodeCached = outputPathExists && !ApiEntryPoint.Instance.HasActiveTranscodingJob(outputPath, TranscodingJobType.Progressive);
|
||||
|
||||
@@ -151,13 +152,13 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
using (state)
|
||||
{
|
||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
{
|
||||
ResponseHeaders = responseHeaders,
|
||||
ContentType = contentType,
|
||||
IsHeadRequest = isHeadRequest,
|
||||
Path = state.MediaPath
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +169,13 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
try
|
||||
{
|
||||
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||
{
|
||||
ResponseHeaders = responseHeaders,
|
||||
ContentType = contentType,
|
||||
IsHeadRequest = isHeadRequest,
|
||||
Path = outputPath
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -185,7 +186,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
// Need to start ffmpeg
|
||||
try
|
||||
{
|
||||
return GetStreamResult(state, responseHeaders, isHeadRequest, cancellationTokenSource).Result;
|
||||
return await GetStreamResult(state, responseHeaders, isHeadRequest, cancellationTokenSource)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -229,7 +231,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
if (trySupportSeek)
|
||||
{
|
||||
foreach (var name in new[] {"Content-Range", "Accept-Ranges"})
|
||||
foreach (var name in new[] { "Content-Range", "Accept-Ranges" })
|
||||
{
|
||||
var val = response.Headers[name];
|
||||
if (!string.IsNullOrWhiteSpace(val))
|
||||
@@ -242,12 +244,12 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
responseHeaders["Accept-Ranges"] = "none";
|
||||
}
|
||||
|
||||
|
||||
if (response.ContentLength.HasValue)
|
||||
{
|
||||
responseHeaders["Content-Length"] = response.ContentLength.Value.ToString(UsCulture);
|
||||
}
|
||||
|
||||
|
||||
if (isHeadRequest)
|
||||
{
|
||||
using (response)
|
||||
@@ -324,7 +326,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
TranscodingJob job;
|
||||
|
||||
if (!FileSystem.FileExists(outputPath))
|
||||
if (!FileSystem.FileExists(outputPath))
|
||||
{
|
||||
job = await StartFfMpeg(state, outputPath, cancellationTokenSource).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user