aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Playback
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Api/Playback')
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs93
-rw-r--r--MediaBrowser.Api/Playback/Hls/BaseHlsService.cs39
-rw-r--r--MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs31
-rw-r--r--MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs4
-rw-r--r--MediaBrowser.Api/Playback/Hls/VideoHlsService.cs31
-rw-r--r--MediaBrowser.Api/Playback/Progressive/AudioService.cs28
-rw-r--r--MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs29
-rw-r--r--MediaBrowser.Api/Playback/Progressive/VideoService.cs28
-rw-r--r--MediaBrowser.Api/Playback/TranscodingThrottler.cs29
-rw-r--r--MediaBrowser.Api/Playback/UniversalAudioService.cs3
10 files changed, 234 insertions, 81 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index ec42cad33..073686298 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -68,10 +69,8 @@ namespace MediaBrowser.Api.Playback
protected IDeviceManager DeviceManager { get; private set; }
protected ISubtitleEncoder SubtitleEncoder { get; private set; }
protected IMediaSourceManager MediaSourceManager { get; private set; }
- protected IZipClient ZipClient { get; private set; }
protected IJsonSerializer JsonSerializer { get; private set; }
- public static IServerApplicationHost AppHost;
public static IHttpClient HttpClient;
protected IAuthorizationContext AuthorizationContext { get; private set; }
@@ -80,21 +79,33 @@ namespace MediaBrowser.Api.Playback
/// <summary>
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
/// </summary>
- protected BaseStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext)
+ protected BaseStreamingService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext)
{
- JsonSerializer = jsonSerializer;
- AuthorizationContext = authorizationContext;
- ZipClient = zipClient;
- MediaSourceManager = mediaSourceManager;
- DeviceManager = deviceManager;
- SubtitleEncoder = subtitleEncoder;
- DlnaManager = dlnaManager;
- FileSystem = fileSystem;
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);
}
@@ -187,7 +198,8 @@ namespace MediaBrowser.Api.Playback
/// <param name="cancellationTokenSource">The cancellation token source.</param>
/// <param name="workingDirectory">The working directory.</param>
/// <returns>Task.</returns>
- protected async Task<TranscodingJob> StartFfMpeg(StreamState state,
+ protected async Task<TranscodingJob> StartFfMpeg(
+ StreamState state,
string outputPath,
CancellationTokenSource cancellationTokenSource,
string workingDirectory = null)
@@ -215,24 +227,27 @@ namespace MediaBrowser.Api.Playback
var transcodingId = Guid.NewGuid().ToString("N");
var commandLineArgs = GetCommandLineArguments(outputPath, encodingOptions, state, true);
- var process = ApiEntryPoint.Instance.ProcessFactory.Create(new ProcessOptions
+ var process = new Process()
{
- CreateNoWindow = true,
- UseShellExecute = false,
-
- // Must consume both stdout and stderr or deadlocks may occur
- //RedirectStandardOutput = true,
- RedirectStandardError = true,
- RedirectStandardInput = true,
-
- FileName = MediaEncoder.EncoderPath,
- Arguments = commandLineArgs,
-
- IsHidden = true,
- ErrorDialog = false,
- EnableRaisingEvents = true,
- WorkingDirectory = !string.IsNullOrWhiteSpace(workingDirectory) ? workingDirectory : null
- });
+ StartInfo = new ProcessStartInfo()
+ {
+ WindowStyle = ProcessWindowStyle.Hidden,
+ CreateNoWindow = true,
+ UseShellExecute = false,
+
+ // Must consume both stdout and stderr or deadlocks may occur
+ //RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ RedirectStandardInput = true,
+
+ FileName = MediaEncoder.EncoderPath,
+ Arguments = commandLineArgs,
+ WorkingDirectory = string.IsNullOrWhiteSpace(workingDirectory) ? null : workingDirectory,
+
+ ErrorDialog = false
+ },
+ EnableRaisingEvents = true
+ };
var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath,
state.Request.PlaySessionId,
@@ -248,13 +263,17 @@ namespace MediaBrowser.Api.Playback
Logger.LogInformation(commandLineLogMessage);
var logFilePrefix = "ffmpeg-transcode";
- if (state.VideoRequest != null && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase) && string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase))
- {
- logFilePrefix = "ffmpeg-directstream";
- }
- else if (state.VideoRequest != null && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
+ if (state.VideoRequest != null)
{
- logFilePrefix = "ffmpeg-remux";
+ if (string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase)
+ && string.Equals(state.OutputAudioCodec, "copy", StringComparison.OrdinalIgnoreCase))
+ {
+ logFilePrefix = "ffmpeg-directstream";
+ }
+ else if (string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase))
+ {
+ logFilePrefix = "ffmpeg-remux";
+ }
}
var logFilePath = Path.Combine(ServerConfigurationManager.ApplicationPaths.LogDirectoryPath, logFilePrefix + "-" + Guid.NewGuid() + ".txt");
@@ -317,7 +336,7 @@ namespace MediaBrowser.Api.Playback
{
if (EnableThrottling(state))
{
- transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, ApiEntryPoint.Instance.TimerFactory, FileSystem);
+ transcodingJob.TranscodingThrottler = state.TranscodingThrottler = new TranscodingThrottler(transcodingJob, Logger, ServerConfigurationManager, FileSystem);
state.TranscodingThrottler.Start();
}
}
@@ -341,7 +360,7 @@ namespace MediaBrowser.Api.Playback
/// <param name="process">The process.</param>
/// <param name="job">The job.</param>
/// <param name="state">The state.</param>
- private void OnFfMpegProcessExited(IProcess process, TranscodingJob job, StreamState state)
+ private void OnFfMpegProcessExited(Process process, TranscodingJob job, StreamState state)
{
if (job != null)
{
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 08a2183f8..1acc42ea5 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -55,17 +55,6 @@ namespace MediaBrowser.Api.Playback.Hls
protected override TranscodingJobType TranscodingJobType => TranscodingJobType.Hls;
/// <summary>
- /// Processes the request.
- /// </summary>
- /// <param name="request">The request.</param>
- /// <param name="isLive">if set to <c>true</c> [is live].</param>
- /// <returns>System.Object.</returns>
- protected async Task<object> ProcessRequest(StreamRequest request, bool isLive)
- {
- return await ProcessRequestAsync(request, isLive).ConfigureAwait(false);
- }
-
- /// <summary>
/// Processes the request async.
/// </summary>
/// <param name="request">The request.</param>
@@ -74,7 +63,7 @@ namespace MediaBrowser.Api.Playback.Hls
/// <exception cref="ArgumentException">A video bitrate is required
/// or
/// An audio bitrate is required</exception>
- private async Task<object> ProcessRequestAsync(StreamRequest request, bool isLive)
+ protected async Task<object> ProcessRequestAsync(StreamRequest request, bool isLive)
{
var cancellationTokenSource = new CancellationTokenSource();
@@ -324,7 +313,31 @@ namespace MediaBrowser.Api.Playback.Hls
return 0;
}
- public BaseHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
+ public BaseHlsService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext)
+ : base(serverConfig,
+ userManager,
+ libraryManager,
+ isoManager,
+ mediaEncoder,
+ fileSystem,
+ dlnaManager,
+ subtitleEncoder,
+ deviceManager,
+ mediaSourceManager,
+ jsonSerializer,
+ authorizationContext)
{
}
}
diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
index 30696ec97..45f003cae 100644
--- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs
@@ -95,7 +95,32 @@ namespace MediaBrowser.Api.Playback.Hls
public class DynamicHlsService : BaseHlsService
{
- public DynamicHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, INetworkManager networkManager) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
+ public DynamicHlsService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext,
+ INetworkManager networkManager)
+ : base(serverConfig,
+ userManager,
+ libraryManager,
+ isoManager,
+ mediaEncoder,
+ fileSystem,
+ dlnaManager,
+ subtitleEncoder,
+ deviceManager,
+ mediaSourceManager,
+ jsonSerializer,
+ authorizationContext)
{
NetworkManager = networkManager;
}
@@ -209,7 +234,7 @@ namespace MediaBrowser.Api.Playback.Hls
// If the playlist doesn't already exist, startup ffmpeg
try
{
- ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.PlaySessionId, p => false);
+ await ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.PlaySessionId, p => false);
if (currentTranscodingIndex.HasValue)
{
@@ -233,7 +258,7 @@ namespace MediaBrowser.Api.Playback.Hls
job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
if (job.TranscodingThrottler != null)
{
- job.TranscodingThrottler.UnpauseTranscoding();
+ await job.TranscodingThrottler.UnpauseTranscoding();
}
}
}
diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
index 02b837912..6a2c7ae03 100644
--- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
+++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
@@ -102,9 +102,9 @@ namespace MediaBrowser.Api.Playback.Hls
return GetFileResult(file, file);
}
- public void Delete(StopEncodingProcess request)
+ public Task Delete(StopEncodingProcess request)
{
- ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.PlaySessionId, path => true);
+ return ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, request.PlaySessionId, path => true);
}
/// <summary>
diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
index 142dc2dfd..eb1bbfb74 100644
--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Devices;
using MediaBrowser.Controller.Dlna;
@@ -24,9 +25,9 @@ namespace MediaBrowser.Api.Playback.Hls
[Authenticated]
public class VideoHlsService : BaseHlsService
{
- public object Get(GetLiveHlsStream request)
+ public Task<object> Get(GetLiveHlsStream request)
{
- return ProcessRequest(request, true);
+ return ProcessRequestAsync(request, true);
}
/// <summary>
@@ -130,7 +131,31 @@ namespace MediaBrowser.Api.Playback.Hls
return args;
}
- public VideoHlsService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
+ public VideoHlsService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext)
+ : base(serverConfig,
+ userManager,
+ libraryManager,
+ isoManager,
+ mediaEncoder,
+ fileSystem,
+ dlnaManager,
+ subtitleEncoder,
+ deviceManager,
+ mediaSourceManager,
+ jsonSerializer,
+ authorizationContext)
{
}
}
diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs
index 150571ce9..208a5560d 100644
--- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs
@@ -32,7 +32,33 @@ namespace MediaBrowser.Api.Playback.Progressive
//[Authenticated]
public class AudioService : BaseProgressiveStreamingService
{
- public AudioService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor, environmentInfo)
+ public AudioService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext,
+ IEnvironmentInfo environmentInfo)
+ : base(serverConfig,
+ userManager,
+ libraryManager,
+ isoManager,
+ mediaEncoder,
+ fileSystem,
+ dlnaManager,
+ subtitleEncoder,
+ deviceManager,
+ mediaSourceManager,
+ jsonSerializer,
+ authorizationContext,
+ environmentInfo)
{
}
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index 621d1ff88..c197de173 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -25,12 +25,35 @@ namespace MediaBrowser.Api.Playback.Progressive
/// </summary>
public abstract class BaseProgressiveStreamingService : BaseStreamingService
{
- protected readonly IImageProcessor ImageProcessor;
protected readonly IEnvironmentInfo EnvironmentInfo;
- public BaseProgressiveStreamingService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext)
+ public BaseProgressiveStreamingService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext,
+ IEnvironmentInfo environmentInfo)
+ : base(serverConfig,
+ userManager,
+ libraryManager,
+ isoManager,
+ mediaEncoder,
+ fileSystem,
+ dlnaManager,
+ subtitleEncoder,
+ deviceManager,
+ mediaSourceManager,
+ jsonSerializer,
+ authorizationContext)
{
- ImageProcessor = imageProcessor;
EnvironmentInfo = environmentInfo;
}
diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
index 00b79ccdd..a0ea5c62d 100644
--- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs
@@ -68,7 +68,33 @@ namespace MediaBrowser.Api.Playback.Progressive
//[Authenticated]
public class VideoService : BaseProgressiveStreamingService
{
- public VideoService(IServerConfigurationManager serverConfig, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IDlnaManager dlnaManager, ISubtitleEncoder subtitleEncoder, IDeviceManager deviceManager, IMediaSourceManager mediaSourceManager, IZipClient zipClient, IJsonSerializer jsonSerializer, IAuthorizationContext authorizationContext, IImageProcessor imageProcessor, IEnvironmentInfo environmentInfo) : base(serverConfig, userManager, libraryManager, isoManager, mediaEncoder, fileSystem, dlnaManager, subtitleEncoder, deviceManager, mediaSourceManager, zipClient, jsonSerializer, authorizationContext, imageProcessor, environmentInfo)
+ public VideoService(
+ IServerConfigurationManager serverConfig,
+ IUserManager userManager,
+ ILibraryManager libraryManager,
+ IIsoManager isoManager,
+ IMediaEncoder mediaEncoder,
+ IFileSystem fileSystem,
+ IDlnaManager dlnaManager,
+ ISubtitleEncoder subtitleEncoder,
+ IDeviceManager deviceManager,
+ IMediaSourceManager mediaSourceManager,
+ IJsonSerializer jsonSerializer,
+ IAuthorizationContext authorizationContext,
+ IEnvironmentInfo environmentInfo)
+ : base(serverConfig,
+ userManager,
+ libraryManager,
+ isoManager,
+ mediaEncoder,
+ fileSystem,
+ dlnaManager,
+ subtitleEncoder,
+ deviceManager,
+ mediaSourceManager,
+ jsonSerializer,
+ authorizationContext,
+ environmentInfo)
{
}
diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs
index 97f21c8f3..0e73d77ef 100644
--- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs
+++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs
@@ -1,8 +1,9 @@
using System;
+using System.Threading;
+using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Threading;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Api.Playback
@@ -11,18 +12,16 @@ namespace MediaBrowser.Api.Playback
{
private readonly TranscodingJob _job;
private readonly ILogger _logger;
- private ITimer _timer;
+ private Timer _timer;
private bool _isPaused;
private readonly IConfigurationManager _config;
- private readonly ITimerFactory _timerFactory;
private readonly IFileSystem _fileSystem;
- public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, ITimerFactory timerFactory, IFileSystem fileSystem)
+ public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, IFileSystem fileSystem)
{
_job = job;
_logger = logger;
_config = config;
- _timerFactory = timerFactory;
_fileSystem = fileSystem;
}
@@ -33,10 +32,10 @@ namespace MediaBrowser.Api.Playback
public void Start()
{
- _timer = _timerFactory.Create(TimerCallback, null, 5000, 5000);
+ _timer = new Timer(TimerCallback, null, 5000, 5000);
}
- private void TimerCallback(object state)
+ private async void TimerCallback(object state)
{
if (_job.HasExited)
{
@@ -48,15 +47,15 @@ namespace MediaBrowser.Api.Playback
if (options.EnableThrottling && IsThrottleAllowed(_job, options.ThrottleDelaySeconds))
{
- PauseTranscoding();
+ await PauseTranscoding();
}
else
{
- UnpauseTranscoding();
+ await UnpauseTranscoding();
}
}
- private void PauseTranscoding()
+ private async Task PauseTranscoding()
{
if (!_isPaused)
{
@@ -64,7 +63,7 @@ namespace MediaBrowser.Api.Playback
try
{
- _job.Process.StandardInput.Write("c");
+ await _job.Process.StandardInput.WriteAsync("c");
_isPaused = true;
}
catch (Exception ex)
@@ -74,7 +73,7 @@ namespace MediaBrowser.Api.Playback
}
}
- public void UnpauseTranscoding()
+ public async Task UnpauseTranscoding()
{
if (_isPaused)
{
@@ -82,7 +81,7 @@ namespace MediaBrowser.Api.Playback
try
{
- _job.Process.StandardInput.WriteLine();
+ await _job.Process.StandardInput.WriteLineAsync();
_isPaused = false;
}
catch (Exception ex)
@@ -153,10 +152,10 @@ namespace MediaBrowser.Api.Playback
return false;
}
- public void Stop()
+ public async Task Stop()
{
DisposeTimer();
- UnpauseTranscoding();
+ await UnpauseTranscoding();
}
public void Dispose()
diff --git a/MediaBrowser.Api/Playback/UniversalAudioService.cs b/MediaBrowser.Api/Playback/UniversalAudioService.cs
index 1aa77792c..e07770a4c 100644
--- a/MediaBrowser.Api/Playback/UniversalAudioService.cs
+++ b/MediaBrowser.Api/Playback/UniversalAudioService.cs
@@ -287,7 +287,6 @@ namespace MediaBrowser.Api.Playback
SubtitleEncoder,
DeviceManager,
MediaSourceManager,
- ZipClient,
JsonSerializer,
AuthorizationContext,
NetworkManager)
@@ -334,10 +333,8 @@ namespace MediaBrowser.Api.Playback
SubtitleEncoder,
DeviceManager,
MediaSourceManager,
- ZipClient,
JsonSerializer,
AuthorizationContext,
- ImageProcessor,
EnvironmentInfo)
{
Request = Request