aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/Playback/TranscodingThrottler.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-31 23:07:45 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-31 23:07:45 -0400
commit13d8110ce29a7d976c3e88dc4b330922964ac11a (patch)
treeddc2a61bfd9d001224aa640e220c7903ac62cb74 /MediaBrowser.Api/Playback/TranscodingThrottler.cs
parentb28857feea210a40f984e69517bcbafbfb639773 (diff)
make api project portable
Diffstat (limited to 'MediaBrowser.Api/Playback/TranscodingThrottler.cs')
-rw-r--r--MediaBrowser.Api/Playback/TranscodingThrottler.cs16
1 files changed, 10 insertions, 6 deletions
diff --git a/MediaBrowser.Api/Playback/TranscodingThrottler.cs b/MediaBrowser.Api/Playback/TranscodingThrottler.cs
index a7d53cd44..c42d0c3e4 100644
--- a/MediaBrowser.Api/Playback/TranscodingThrottler.cs
+++ b/MediaBrowser.Api/Playback/TranscodingThrottler.cs
@@ -2,8 +2,8 @@
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Logging;
using System;
-using System.IO;
-using System.Threading;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.Threading;
namespace MediaBrowser.Api.Playback
{
@@ -11,15 +11,19 @@ namespace MediaBrowser.Api.Playback
{
private readonly TranscodingJob _job;
private readonly ILogger _logger;
- private Timer _timer;
+ private ITimer _timer;
private bool _isPaused;
private readonly IConfigurationManager _config;
+ private readonly ITimerFactory _timerFactory;
+ private readonly IFileSystem _fileSystem;
- public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config)
+ public TranscodingThrottler(TranscodingJob job, ILogger logger, IConfigurationManager config, ITimerFactory timerFactory, IFileSystem fileSystem)
{
_job = job;
_logger = logger;
_config = config;
+ _timerFactory = timerFactory;
+ _fileSystem = fileSystem;
}
private EncodingOptions GetOptions()
@@ -29,7 +33,7 @@ namespace MediaBrowser.Api.Playback
public void Start()
{
- _timer = new Timer(TimerCallback, null, 5000, 5000);
+ _timer = _timerFactory.Create(TimerCallback, null, 5000, 5000);
}
private void TimerCallback(object state)
@@ -120,7 +124,7 @@ namespace MediaBrowser.Api.Playback
try
{
- var bytesTranscoded = job.BytesTranscoded ?? new FileInfo(path).Length;
+ var bytesTranscoded = job.BytesTranscoded ?? _fileSystem.GetFileInfo(path).Length;
// Estimate the bytes the transcoder should be ahead
double gapFactor = gapLengthInTicks;