mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
Properly use DI to reference other controllers.
This commit is contained in:
parent
db36b9d501
commit
0f32beb75f
@ -1,14 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using MediaBrowser.Controller.Dto;
|
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Model.Dto;
|
using MediaBrowser.Model.Dto;
|
||||||
using MediaBrowser.Model.Globalization;
|
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers
|
namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -18,32 +14,15 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Authorize(Policy = Policies.DefaultAuthorization)]
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
||||||
public class TrailersController : BaseJellyfinApiController
|
public class TrailersController : BaseJellyfinApiController
|
||||||
{
|
{
|
||||||
private readonly IUserManager _userManager;
|
private readonly ItemsController _itemsController;
|
||||||
private readonly ILibraryManager _libraryManager;
|
|
||||||
private readonly ILogger<ItemsController> _logger;
|
|
||||||
private readonly IDtoService _dtoService;
|
|
||||||
private readonly ILocalizationManager _localizationManager;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TrailersController"/> class.
|
/// Initializes a new instance of the <see cref="TrailersController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
|
/// <param name="itemsController">Instance of <see cref="ItemsController"/>.</param>
|
||||||
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
|
public TrailersController(ItemsController itemsController)
|
||||||
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
|
||||||
/// <param name="dtoService">Instance of the <see cref="IDtoService"/> interface.</param>
|
|
||||||
/// <param name="localizationManager">Instance of the <see cref="ILocalizationManager"/> interface.</param>
|
|
||||||
public TrailersController(
|
|
||||||
ILoggerFactory loggerFactory,
|
|
||||||
IUserManager userManager,
|
|
||||||
ILibraryManager libraryManager,
|
|
||||||
IDtoService dtoService,
|
|
||||||
ILocalizationManager localizationManager)
|
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
_itemsController = itemsController;
|
||||||
_libraryManager = libraryManager;
|
|
||||||
_dtoService = dtoService;
|
|
||||||
_localizationManager = localizationManager;
|
|
||||||
_logger = loggerFactory.CreateLogger<ItemsController>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -214,12 +193,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
{
|
{
|
||||||
var includeItemTypes = "Trailer";
|
var includeItemTypes = "Trailer";
|
||||||
|
|
||||||
return new ItemsController(
|
return _itemsController
|
||||||
_userManager,
|
|
||||||
_libraryManager,
|
|
||||||
_localizationManager,
|
|
||||||
_dtoService,
|
|
||||||
_logger)
|
|
||||||
.GetItems(
|
.GetItems(
|
||||||
userId,
|
userId,
|
||||||
userId,
|
userId,
|
||||||
|
@ -7,21 +7,12 @@ using System.Threading.Tasks;
|
|||||||
using Jellyfin.Api.Constants;
|
using Jellyfin.Api.Constants;
|
||||||
using Jellyfin.Api.Helpers;
|
using Jellyfin.Api.Helpers;
|
||||||
using Jellyfin.Api.Models.VideoDtos;
|
using Jellyfin.Api.Models.VideoDtos;
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller.Configuration;
|
|
||||||
using MediaBrowser.Controller.Devices;
|
|
||||||
using MediaBrowser.Controller.Dlna;
|
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Controller.MediaEncoding;
|
|
||||||
using MediaBrowser.Controller.Net;
|
using MediaBrowser.Controller.Net;
|
||||||
using MediaBrowser.Model.Dlna;
|
using MediaBrowser.Model.Dlna;
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers
|
namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -30,72 +21,28 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UniversalAudioController : BaseJellyfinApiController
|
public class UniversalAudioController : BaseJellyfinApiController
|
||||||
{
|
{
|
||||||
private readonly ILoggerFactory _loggerFactory;
|
|
||||||
private readonly IUserManager _userManager;
|
|
||||||
private readonly ILibraryManager _libraryManager;
|
|
||||||
private readonly IDeviceManager _deviceManager;
|
|
||||||
private readonly IDlnaManager _dlnaManager;
|
|
||||||
private readonly IMediaEncoder _mediaEncoder;
|
|
||||||
private readonly IFileSystem _fileSystem;
|
|
||||||
private readonly IMediaSourceManager _mediaSourceManager;
|
|
||||||
private readonly IAuthorizationContext _authorizationContext;
|
private readonly IAuthorizationContext _authorizationContext;
|
||||||
private readonly INetworkManager _networkManager;
|
private readonly MediaInfoController _mediaInfoController;
|
||||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
private readonly DynamicHlsController _dynamicHlsController;
|
||||||
private readonly TranscodingJobHelper _transcodingJobHelper;
|
private readonly AudioController _audioController;
|
||||||
private readonly IConfiguration _configuration;
|
|
||||||
private readonly ISubtitleEncoder _subtitleEncoder;
|
|
||||||
private readonly IHttpClientFactory _httpClientFactory;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="UniversalAudioController"/> class.
|
/// Initializes a new instance of the <see cref="UniversalAudioController"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="loggerFactory">Instance of the <see cref="ILoggerFactory"/> interface.</param>
|
|
||||||
/// <param name="serverConfigurationManager">Instance of the <see cref="IServerConfigurationManager"/> interface.</param>
|
|
||||||
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
|
|
||||||
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
|
||||||
/// <param name="mediaEncoder">Instance of the <see cref="IMediaEncoder"/> interface.</param>
|
|
||||||
/// <param name="fileSystem">Instance of the <see cref="IFileSystem"/> interface.</param>
|
|
||||||
/// <param name="dlnaManager">Instance of the <see cref="IDlnaManager"/> interface.</param>
|
|
||||||
/// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
|
|
||||||
/// <param name="mediaSourceManager">Instance of the <see cref="IMediaSourceManager"/> interface.</param>
|
|
||||||
/// <param name="authorizationContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
|
/// <param name="authorizationContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
|
||||||
/// <param name="networkManager">Instance of the <see cref="INetworkManager"/> interface.</param>
|
/// <param name="mediaInfoController">Instance of the <see cref="MediaInfoController"/>.</param>
|
||||||
/// <param name="transcodingJobHelper">Instance of the <see cref="TranscodingJobHelper"/> interface.</param>
|
/// <param name="dynamicHlsController">Instance of the <see cref="DynamicHlsController"/>.</param>
|
||||||
/// <param name="configuration">Instance of the <see cref="IConfiguration"/> interface.</param>
|
/// <param name="audioController">Instance of the <see cref="AudioController"/>.</param>
|
||||||
/// <param name="subtitleEncoder">Instance of the <see cref="ISubtitleEncoder"/> interface.</param>
|
|
||||||
/// <param name="httpClientFactory">Instance of the <see cref="IHttpClientFactory"/> interface.</param>
|
|
||||||
public UniversalAudioController(
|
public UniversalAudioController(
|
||||||
ILoggerFactory loggerFactory,
|
|
||||||
IServerConfigurationManager serverConfigurationManager,
|
|
||||||
IUserManager userManager,
|
|
||||||
ILibraryManager libraryManager,
|
|
||||||
IMediaEncoder mediaEncoder,
|
|
||||||
IFileSystem fileSystem,
|
|
||||||
IDlnaManager dlnaManager,
|
|
||||||
IDeviceManager deviceManager,
|
|
||||||
IMediaSourceManager mediaSourceManager,
|
|
||||||
IAuthorizationContext authorizationContext,
|
IAuthorizationContext authorizationContext,
|
||||||
INetworkManager networkManager,
|
MediaInfoController mediaInfoController,
|
||||||
TranscodingJobHelper transcodingJobHelper,
|
DynamicHlsController dynamicHlsController,
|
||||||
IConfiguration configuration,
|
AudioController audioController)
|
||||||
ISubtitleEncoder subtitleEncoder,
|
|
||||||
IHttpClientFactory httpClientFactory)
|
|
||||||
{
|
{
|
||||||
_userManager = userManager;
|
|
||||||
_libraryManager = libraryManager;
|
|
||||||
_mediaEncoder = mediaEncoder;
|
|
||||||
_fileSystem = fileSystem;
|
|
||||||
_dlnaManager = dlnaManager;
|
|
||||||
_deviceManager = deviceManager;
|
|
||||||
_mediaSourceManager = mediaSourceManager;
|
|
||||||
_authorizationContext = authorizationContext;
|
_authorizationContext = authorizationContext;
|
||||||
_networkManager = networkManager;
|
_mediaInfoController = mediaInfoController;
|
||||||
_loggerFactory = loggerFactory;
|
_dynamicHlsController = dynamicHlsController;
|
||||||
_serverConfigurationManager = serverConfigurationManager;
|
_audioController = audioController;
|
||||||
_transcodingJobHelper = transcodingJobHelper;
|
|
||||||
_configuration = configuration;
|
|
||||||
_subtitleEncoder = subtitleEncoder;
|
|
||||||
_httpClientFactory = httpClientFactory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -151,8 +98,7 @@ namespace Jellyfin.Api.Controllers
|
|||||||
var deviceProfile = GetDeviceProfile(container, transcodingContainer, audioCodec, transcodingProtocol, breakOnNonKeyFrames, transcodingAudioChannels, maxAudioSampleRate, maxAudioBitDepth, maxAudioChannels);
|
var deviceProfile = GetDeviceProfile(container, transcodingContainer, audioCodec, transcodingProtocol, breakOnNonKeyFrames, transcodingAudioChannels, maxAudioSampleRate, maxAudioBitDepth, maxAudioChannels);
|
||||||
_authorizationContext.GetAuthorizationInfo(Request).DeviceId = deviceId;
|
_authorizationContext.GetAuthorizationInfo(Request).DeviceId = deviceId;
|
||||||
|
|
||||||
var mediaInfoController = new MediaInfoController(_mediaSourceManager, _deviceManager, _libraryManager, _networkManager, _mediaEncoder, _userManager, _authorizationContext, _loggerFactory.CreateLogger<MediaInfoController>(), _serverConfigurationManager);
|
var playbackInfoResult = await _mediaInfoController.GetPostedPlaybackInfo(
|
||||||
var playbackInfoResult = await mediaInfoController.GetPostedPlaybackInfo(
|
|
||||||
itemId,
|
itemId,
|
||||||
userId,
|
userId,
|
||||||
maxStreamingBitrate,
|
maxStreamingBitrate,
|
||||||
@ -180,21 +126,6 @@ namespace Jellyfin.Api.Controllers
|
|||||||
var isStatic = mediaSource.SupportsDirectStream;
|
var isStatic = mediaSource.SupportsDirectStream;
|
||||||
if (!isStatic && string.Equals(mediaSource.TranscodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
if (!isStatic && string.Equals(mediaSource.TranscodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
var dynamicHlsController = new DynamicHlsController(
|
|
||||||
_libraryManager,
|
|
||||||
_userManager,
|
|
||||||
_dlnaManager,
|
|
||||||
_authorizationContext,
|
|
||||||
_mediaSourceManager,
|
|
||||||
_serverConfigurationManager,
|
|
||||||
_mediaEncoder,
|
|
||||||
_fileSystem,
|
|
||||||
_subtitleEncoder,
|
|
||||||
_configuration,
|
|
||||||
_deviceManager,
|
|
||||||
_transcodingJobHelper,
|
|
||||||
_networkManager,
|
|
||||||
_loggerFactory.CreateLogger<DynamicHlsController>());
|
|
||||||
var transcodingProfile = deviceProfile.TranscodingProfiles[0];
|
var transcodingProfile = deviceProfile.TranscodingProfiles[0];
|
||||||
|
|
||||||
// hls segment container can only be mpegts or fmp4 per ffmpeg documentation
|
// hls segment container can only be mpegts or fmp4 per ffmpeg documentation
|
||||||
@ -203,10 +134,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
|
|
||||||
if (isHeadRequest)
|
if (isHeadRequest)
|
||||||
{
|
{
|
||||||
dynamicHlsController.Request.Method = HttpMethod.Head.Method;
|
_dynamicHlsController.Request.Method = HttpMethod.Head.Method;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await dynamicHlsController.GetMasterHlsAudioPlaylist(
|
return await _dynamicHlsController.GetMasterHlsAudioPlaylist(
|
||||||
itemId,
|
itemId,
|
||||||
".m3u8",
|
".m3u8",
|
||||||
isStatic,
|
isStatic,
|
||||||
@ -261,27 +192,12 @@ namespace Jellyfin.Api.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var audioController = new AudioController(
|
|
||||||
_dlnaManager,
|
|
||||||
_userManager,
|
|
||||||
_authorizationContext,
|
|
||||||
_libraryManager,
|
|
||||||
_mediaSourceManager,
|
|
||||||
_serverConfigurationManager,
|
|
||||||
_mediaEncoder,
|
|
||||||
_fileSystem,
|
|
||||||
_subtitleEncoder,
|
|
||||||
_configuration,
|
|
||||||
_deviceManager,
|
|
||||||
_transcodingJobHelper,
|
|
||||||
_httpClientFactory);
|
|
||||||
|
|
||||||
if (isHeadRequest)
|
if (isHeadRequest)
|
||||||
{
|
{
|
||||||
audioController.Request.Method = HttpMethod.Head.Method;
|
_audioController.Request.Method = HttpMethod.Head.Method;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await audioController.GetAudioStream(
|
return await _audioController.GetAudioStream(
|
||||||
itemId,
|
itemId,
|
||||||
isStatic ? null : ("." + mediaSource.TranscodingContainer),
|
isStatic ? null : ("." + mediaSource.TranscodingContainer),
|
||||||
isStatic,
|
isStatic,
|
||||||
|
Loading…
Reference in New Issue
Block a user