aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/AudioController.cs
diff options
context:
space:
mode:
authorDavid <daullmer@gmail.com>2020-07-24 19:14:53 +0200
committerDavid <daullmer@gmail.com>2020-07-24 19:14:53 +0200
commitca3dcc3db03d531457b4b60cc3ecdebd57a0157e (patch)
tree8afe35ccdc8231345c0c6dd7bd046d43bdd8ec5b /Jellyfin.Api/Controllers/AudioController.cs
parentd39f481a5c723dcbd97a578dc8f390e7d0b4e984 (diff)
Fix suggestions from review
Diffstat (limited to 'Jellyfin.Api/Controllers/AudioController.cs')
-rw-r--r--Jellyfin.Api/Controllers/AudioController.cs107
1 files changed, 28 insertions, 79 deletions
diff --git a/Jellyfin.Api/Controllers/AudioController.cs b/Jellyfin.Api/Controllers/AudioController.cs
index d8c67cc24..7405c26fb 100644
--- a/Jellyfin.Api/Controllers/AudioController.cs
+++ b/Jellyfin.Api/Controllers/AudioController.cs
@@ -260,7 +260,7 @@ namespace Jellyfin.Api.Controllers
StreamOptions = streamOptions
};
- var state = await StreamingHelpers.GetStreamingState(
+ using var state = await StreamingHelpers.GetStreamingState(
streamingRequest,
Request,
_authContext,
@@ -283,14 +283,11 @@ namespace Jellyfin.Api.Controllers
{
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, startTimeTicks, Request, _dlnaManager);
- using (state)
- {
- // TODO AllowEndOfFile = false
- await new ProgressiveFileCopier(_streamHelper, state.DirectStreamProvider).WriteToAsync(Response.Body, CancellationToken.None).ConfigureAwait(false);
+ // TODO AllowEndOfFile = false
+ await new ProgressiveFileCopier(_streamHelper, state.DirectStreamProvider).WriteToAsync(Response.Body, CancellationToken.None).ConfigureAwait(false);
- // TODO (moved from MediaBrowser.Api): Don't hardcode contentType
- return File(Response.Body, MimeTypes.GetMimeType("file.ts")!);
- }
+ // TODO (moved from MediaBrowser.Api): Don't hardcode contentType
+ return File(Response.Body, MimeTypes.GetMimeType("file.ts")!);
}
// Static remote stream
@@ -298,10 +295,7 @@ namespace Jellyfin.Api.Controllers
{
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, startTimeTicks, Request, _dlnaManager);
- using (state)
- {
- return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, isHeadRequest, this, _httpClient).ConfigureAwait(false);
- }
+ return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, isHeadRequest, this, _httpClient).ConfigureAwait(false);
}
if (@static.HasValue && @static.Value && state.InputProtocol != MediaProtocol.File)
@@ -322,80 +316,35 @@ namespace Jellyfin.Api.Controllers
{
var contentType = state.GetMimeType("." + state.OutputContainer, false) ?? state.GetMimeType(state.MediaPath);
- using (state)
+ if (state.MediaSource.IsInfiniteStream)
{
- if (state.MediaSource.IsInfiniteStream)
- {
- // TODO AllowEndOfFile = false
- await new ProgressiveFileCopier(_streamHelper, state.MediaPath).WriteToAsync(Response.Body, CancellationToken.None).ConfigureAwait(false);
-
- return File(Response.Body, contentType);
- }
+ // TODO AllowEndOfFile = false
+ await new ProgressiveFileCopier(_streamHelper, state.MediaPath).WriteToAsync(Response.Body, CancellationToken.None).ConfigureAwait(false);
- return FileStreamResponseHelpers.GetStaticFileResult(
- state.MediaPath,
- contentType,
- isHeadRequest,
- this);
+ return File(Response.Body, contentType);
}
- }
- /*
- // Not static but transcode cache file exists
- if (isTranscodeCached && state.VideoRequest == null)
- {
- var contentType = state.GetMimeType(outputPath)
- try
- {
- if (transcodingJob != null)
- {
- ApiEntryPoint.Instance.OnTranscodeBeginRequest(transcodingJob);
- }
- return await ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
- {
- ResponseHeaders = responseHeaders,
- ContentType = contentType,
- IsHeadRequest = isHeadRequest,
- Path = outputPath,
- FileShare = FileShare.ReadWrite,
- OnComplete = () =>
- {
- if (transcodingJob != null)
- {
- ApiEntryPoint.Instance.OnTranscodeEndRequest(transcodingJob);
- }
- }).ConfigureAwait(false);
- }
- finally
- {
- state.Dispose();
- }
- }
- */
-
- // Need to start ffmpeg (because media can't be returned directly)
- try
- {
- var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
- var encodingHelper = new EncodingHelper(_mediaEncoder, _fileSystem, _subtitleEncoder, _configuration);
- var ffmpegCommandLineArguments = encodingHelper.GetProgressiveAudioFullCommandLine(state, encodingOptions, outputPath);
- return await FileStreamResponseHelpers.GetTranscodedFile(
- state,
+ return FileStreamResponseHelpers.GetStaticFileResult(
+ state.MediaPath,
+ contentType,
isHeadRequest,
- _streamHelper,
- this,
- _transcodingJobHelper,
- ffmpegCommandLineArguments,
- Request,
- _transcodingJobType,
- cancellationTokenSource).ConfigureAwait(false);
+ this);
}
- catch
- {
- state.Dispose();
- throw;
- }
+ // Need to start ffmpeg (because media can't be returned directly)
+ var encodingOptions = _serverConfigurationManager.GetEncodingOptions();
+ var encodingHelper = new EncodingHelper(_mediaEncoder, _fileSystem, _subtitleEncoder, _configuration);
+ var ffmpegCommandLineArguments = encodingHelper.GetProgressiveAudioFullCommandLine(state, encodingOptions, outputPath);
+ return await FileStreamResponseHelpers.GetTranscodedFile(
+ state,
+ isHeadRequest,
+ _streamHelper,
+ this,
+ _transcodingJobHelper,
+ ffmpegCommandLineArguments,
+ Request,
+ _transcodingJobType,
+ cancellationTokenSource).ConfigureAwait(false);
}
}
}