mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 20:24:21 -04:00
Apply suggestions from review
This commit is contained in:
parent
cff9772e14
commit
d39f481a5c
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
@ -40,6 +41,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly IDeviceManager _deviceManager;
|
private readonly IDeviceManager _deviceManager;
|
||||||
private readonly TranscodingJobHelper _transcodingJobHelper;
|
private readonly TranscodingJobHelper _transcodingJobHelper;
|
||||||
|
private readonly HttpClient _httpClient;
|
||||||
|
|
||||||
private readonly TranscodingJobType _transcodingJobType = TranscodingJobType.Progressive;
|
private readonly TranscodingJobType _transcodingJobType = TranscodingJobType.Progressive;
|
||||||
|
|
||||||
@ -59,6 +61,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// <param name="configuration">Instance of the <see cref="IConfiguration"/> interface.</param>
|
/// <param name="configuration">Instance of the <see cref="IConfiguration"/> interface.</param>
|
||||||
/// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
|
/// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
|
||||||
/// <param name="transcodingJobHelper">The <see cref="TranscodingJobHelper"/> singleton.</param>
|
/// <param name="transcodingJobHelper">The <see cref="TranscodingJobHelper"/> singleton.</param>
|
||||||
|
/// <param name="httpClient">Instance of the <see cref="HttpClient"/>.</param>
|
||||||
public AudioController(
|
public AudioController(
|
||||||
IDlnaManager dlnaManager,
|
IDlnaManager dlnaManager,
|
||||||
IUserManager userManger,
|
IUserManager userManger,
|
||||||
@ -72,7 +75,8 @@ namespace Jellyfin.Api.Controllers
|
|||||||
ISubtitleEncoder subtitleEncoder,
|
ISubtitleEncoder subtitleEncoder,
|
||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
IDeviceManager deviceManager,
|
IDeviceManager deviceManager,
|
||||||
TranscodingJobHelper transcodingJobHelper)
|
TranscodingJobHelper transcodingJobHelper,
|
||||||
|
HttpClient httpClient)
|
||||||
{
|
{
|
||||||
_dlnaManager = dlnaManager;
|
_dlnaManager = dlnaManager;
|
||||||
_authContext = authorizationContext;
|
_authContext = authorizationContext;
|
||||||
@ -87,6 +91,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_deviceManager = deviceManager;
|
_deviceManager = deviceManager;
|
||||||
_transcodingJobHelper = transcodingJobHelper;
|
_transcodingJobHelper = transcodingJobHelper;
|
||||||
|
_httpClient = httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -295,7 +300,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
|
|
||||||
using (state)
|
using (state)
|
||||||
{
|
{
|
||||||
return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, isHeadRequest, this).ConfigureAwait(false);
|
return await FileStreamResponseHelpers.GetStaticRemoteStreamResult(state, isHeadRequest, this, _httpClient).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,13 +332,6 @@ namespace Jellyfin.Api.Controllers
|
|||||||
return File(Response.Body, contentType);
|
return File(Response.Body, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeSpan? cacheDuration = null;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(tag))
|
|
||||||
{
|
|
||||||
cacheDuration = TimeSpan.FromDays(365);
|
|
||||||
}
|
|
||||||
|
|
||||||
return FileStreamResponseHelpers.GetStaticFileResult(
|
return FileStreamResponseHelpers.GetStaticFileResult(
|
||||||
state.MediaPath,
|
state.MediaPath,
|
||||||
contentType,
|
contentType,
|
||||||
|
@ -23,14 +23,14 @@ namespace Jellyfin.Api.Helpers
|
|||||||
/// <param name="state">The current <see cref="StreamState"/>.</param>
|
/// <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="isHeadRequest">Whether the current request is a HTTP HEAD request so only the headers get returned.</param>
|
||||||
/// <param name="controller">The <see cref="ControllerBase"/> managing the response.</param>
|
/// <param name="controller">The <see cref="ControllerBase"/> managing the response.</param>
|
||||||
|
/// <param name="httpClient">The <see cref="HttpClient"/> making the remote request.</param>
|
||||||
/// <returns>A <see cref="Task{ActionResult}"/> containing the API response.</returns>
|
/// <returns>A <see cref="Task{ActionResult}"/> containing the API response.</returns>
|
||||||
public static async Task<ActionResult> GetStaticRemoteStreamResult(
|
public static async Task<ActionResult> GetStaticRemoteStreamResult(
|
||||||
StreamState state,
|
StreamState state,
|
||||||
bool isHeadRequest,
|
bool isHeadRequest,
|
||||||
ControllerBase controller)
|
ControllerBase controller,
|
||||||
|
HttpClient httpClient)
|
||||||
{
|
{
|
||||||
HttpClient httpClient = new HttpClient();
|
|
||||||
|
|
||||||
if (state.RemoteHttpHeaders.TryGetValue(HeaderNames.UserAgent, out var useragent))
|
if (state.RemoteHttpHeaders.TryGetValue(HeaderNames.UserAgent, out var useragent))
|
||||||
{
|
{
|
||||||
httpClient.DefaultRequestHeaders.Add(HeaderNames.UserAgent, useragent);
|
httpClient.DefaultRequestHeaders.Add(HeaderNames.UserAgent, useragent);
|
||||||
|
@ -94,11 +94,6 @@ namespace Jellyfin.Api.Models.StreamingDtos
|
|||||||
userAgent.IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 ||
|
userAgent.IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||||
userAgent.IndexOf("ipod", StringComparison.OrdinalIgnoreCase) != -1)
|
userAgent.IndexOf("ipod", StringComparison.OrdinalIgnoreCase) != -1)
|
||||||
{
|
{
|
||||||
if (IsSegmentedLiveStream)
|
|
||||||
{
|
|
||||||
return 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user