aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Playback/BaseStreamingService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/Playback/BaseStreamingService.cs')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs38
1 files changed, 15 insertions, 23 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 7bfe0e0ce..5881e22a7 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -7,6 +7,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
@@ -33,12 +34,6 @@ namespace MediaBrowser.Api.Playback
protected virtual bool EnableOutputInSubFolder => false;
/// <summary>
- /// Gets or sets the application paths.
- /// </summary>
- /// <value>The application paths.</value>
- protected IServerConfigurationManager ServerConfigurationManager { get; private set; }
-
- /// <summary>
/// Gets or sets the user manager.
/// </summary>
/// <value>The user manager.</value>
@@ -68,8 +63,6 @@ namespace MediaBrowser.Api.Playback
protected IDeviceManager DeviceManager { get; private set; }
- protected ISubtitleEncoder SubtitleEncoder { get; private set; }
-
protected IMediaSourceManager MediaSourceManager { get; private set; }
protected IJsonSerializer JsonSerializer { get; private set; }
@@ -88,33 +81,34 @@ namespace MediaBrowser.Api.Playback
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
/// </summary>
protected BaseStreamingService(
- IServerConfigurationManager serverConfig,
+ ILogger logger,
+ IServerConfigurationManager serverConfigurationManager,
+ IHttpResultFactory httpResultFactory,
IUserManager userManager,
ILibraryManager libraryManager,
IIsoManager isoManager,
IMediaEncoder mediaEncoder,
IFileSystem fileSystem,
IDlnaManager dlnaManager,
- ISubtitleEncoder subtitleEncoder,
IDeviceManager deviceManager,
IMediaSourceManager mediaSourceManager,
IJsonSerializer jsonSerializer,
- IAuthorizationContext authorizationContext)
+ IAuthorizationContext authorizationContext,
+ EncodingHelper encodingHelper)
+ : base(logger, serverConfigurationManager, httpResultFactory)
{
- ServerConfigurationManager = serverConfig;
UserManager = userManager;
LibraryManager = libraryManager;
IsoManager = isoManager;
MediaEncoder = mediaEncoder;
FileSystem = fileSystem;
DlnaManager = dlnaManager;
- SubtitleEncoder = subtitleEncoder;
DeviceManager = deviceManager;
MediaSourceManager = mediaSourceManager;
JsonSerializer = jsonSerializer;
AuthorizationContext = authorizationContext;
- EncodingHelper = new EncodingHelper(MediaEncoder, FileSystem, SubtitleEncoder);
+ EncodingHelper = encodingHelper;
}
/// <summary>
@@ -141,7 +135,7 @@ namespace MediaBrowser.Api.Playback
var filename = data.GetMD5().ToString("N", CultureInfo.InvariantCulture);
var ext = outputFileExtension.ToLowerInvariant();
- var folder = ServerConfigurationManager.ApplicationPaths.TranscodingTempPath;
+ var folder = ServerConfigurationManager.GetTranscodePath();
if (EnableOutputInSubFolder)
{
@@ -151,8 +145,6 @@ namespace MediaBrowser.Api.Playback
return Path.Combine(folder, filename + ext);
}
- protected readonly CultureInfo UsCulture = new CultureInfo("en-US");
-
protected virtual string GetDefaultEncoderPreset()
{
return "superfast";
@@ -215,7 +207,7 @@ namespace MediaBrowser.Api.Playback
}
}
- var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
+ var encodingOptions = ServerConfigurationManager.GetEncodingOptions();
var process = new Process()
{
@@ -587,8 +579,8 @@ namespace MediaBrowser.Api.Playback
}
/// <summary>
- /// Parses query parameters as StreamOptions
- /// <summary>
+ /// Parses query parameters as StreamOptions.
+ /// </summary>
/// <param name="request">The stream request.</param>
private void ParseStreamOptions(StreamRequest request)
{
@@ -767,13 +759,13 @@ namespace MediaBrowser.Api.Playback
if (mediaSource == null)
{
- var mediaSources = (await MediaSourceManager.GetPlayackMediaSources(LibraryManager.GetItemById(request.Id), null, false, false, cancellationToken).ConfigureAwait(false)).ToList();
+ var mediaSources = await MediaSourceManager.GetPlayackMediaSources(LibraryManager.GetItemById(request.Id), null, false, false, cancellationToken).ConfigureAwait(false);
mediaSource = string.IsNullOrEmpty(request.MediaSourceId)
? mediaSources[0]
: mediaSources.Find(i => string.Equals(i.Id, request.MediaSourceId));
- if (mediaSource == null && request.MediaSourceId.Equals(request.Id))
+ if (mediaSource == null && Guid.Parse(request.MediaSourceId) == request.Id)
{
mediaSource = mediaSources[0];
}
@@ -845,7 +837,7 @@ namespace MediaBrowser.Api.Playback
? GetOutputFileExtension(state)
: ('.' + state.OutputContainer);
- var encodingOptions = ApiEntryPoint.Instance.GetEncodingOptions();
+ var encodingOptions = ServerConfigurationManager.GetEncodingOptions();
state.OutputFilePath = GetOutputFilePath(state, encodingOptions, ext);