diff --git a/Jellyfin.Api/Controllers/AudioController.cs b/Jellyfin.Api/Controllers/AudioController.cs index 81492ed4aa..d8c67cc24a 100644 --- a/Jellyfin.Api/Controllers/AudioController.cs +++ b/Jellyfin.Api/Controllers/AudioController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Jellyfin.Api.Helpers; @@ -40,6 +41,7 @@ namespace Jellyfin.Api.Controllers private readonly IConfiguration _configuration; private readonly IDeviceManager _deviceManager; private readonly TranscodingJobHelper _transcodingJobHelper; + private readonly HttpClient _httpClient; private readonly TranscodingJobType _transcodingJobType = TranscodingJobType.Progressive; @@ -59,6 +61,7 @@ namespace Jellyfin.Api.Controllers /// Instance of the interface. /// Instance of the interface. /// The singleton. + /// Instance of the . public AudioController( IDlnaManager dlnaManager, IUserManager userManger, @@ -72,7 +75,8 @@ namespace Jellyfin.Api.Controllers ISubtitleEncoder subtitleEncoder, IConfiguration configuration, IDeviceManager deviceManager, - TranscodingJobHelper transcodingJobHelper) + TranscodingJobHelper transcodingJobHelper, + HttpClient httpClient) { _dlnaManager = dlnaManager; _authContext = authorizationContext; @@ -87,6 +91,7 @@ namespace Jellyfin.Api.Controllers _configuration = configuration; _deviceManager = deviceManager; _transcodingJobHelper = transcodingJobHelper; + _httpClient = httpClient; } /// @@ -295,7 +300,7 @@ namespace Jellyfin.Api.Controllers 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); } - TimeSpan? cacheDuration = null; - - if (!string.IsNullOrEmpty(tag)) - { - cacheDuration = TimeSpan.FromDays(365); - } - return FileStreamResponseHelpers.GetStaticFileResult( state.MediaPath, contentType, diff --git a/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs b/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs index 9f16b53236..ddca2f1ae6 100644 --- a/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs +++ b/Jellyfin.Api/Helpers/FileStreamResponseHelpers.cs @@ -23,14 +23,14 @@ namespace Jellyfin.Api.Helpers /// The current . /// Whether the current request is a HTTP HEAD request so only the headers get returned. /// The managing the response. + /// The making the remote request. /// A containing the API response. public static async Task GetStaticRemoteStreamResult( StreamState state, bool isHeadRequest, - ControllerBase controller) + ControllerBase controller, + HttpClient httpClient) { - HttpClient httpClient = new HttpClient(); - if (state.RemoteHttpHeaders.TryGetValue(HeaderNames.UserAgent, out var useragent)) { httpClient.DefaultRequestHeaders.Add(HeaderNames.UserAgent, useragent); diff --git a/Jellyfin.Api/Models/StreamingDtos/StreamState.cs b/Jellyfin.Api/Models/StreamingDtos/StreamState.cs index 70a13d745f..df5e21dac0 100644 --- a/Jellyfin.Api/Models/StreamingDtos/StreamState.cs +++ b/Jellyfin.Api/Models/StreamingDtos/StreamState.cs @@ -94,11 +94,6 @@ namespace Jellyfin.Api.Models.StreamingDtos userAgent.IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 || userAgent.IndexOf("ipod", StringComparison.OrdinalIgnoreCase) != -1) { - if (IsSegmentedLiveStream) - { - return 6; - } - return 6; }