aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-08-16 01:54:40 -0400
committerGitHub <noreply@github.com>2016-08-16 01:54:40 -0400
commit3e2d74539c13d12618642fbe23b36148260f7d9e (patch)
tree4f231c4c7198d48d1b341eba469c27e48aefe3bf /MediaBrowser.Api
parentf66a25db1cd80025c0a334495e112ff4e0e35eb8 (diff)
parent14be817766fe55cfeeb3184f3e1a999ce5759188 (diff)
Merge pull request #2063 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Api')
-rw-r--r--MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs4
-rw-r--r--MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs29
-rw-r--r--MediaBrowser.Api/Sync/SyncService.cs3
3 files changed, 27 insertions, 9 deletions
diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
index 56842e69dd..b8cb6b14f0 100644
--- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
+++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs
@@ -370,9 +370,9 @@ namespace MediaBrowser.Api.Playback.Progressive
outputHeaders[item.Key] = item.Value;
}
- Func<Stream, Task> streamWriter = stream => new ProgressiveFileCopier(FileSystem, job, Logger).StreamFile(outputPath, stream, CancellationToken.None);
+ var streamSource = new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, CancellationToken.None);
- return ResultFactory.GetAsyncStreamWriter(streamWriter, outputHeaders);
+ return ResultFactory.GetAsyncStreamWriter(streamSource);
}
finally
{
diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
index 63d71b85ef..0a9a446412 100644
--- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
+++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs
@@ -4,38 +4,55 @@ using System.IO;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
+using MediaBrowser.Controller.Net;
+using System.Collections.Generic;
+using ServiceStack.Web;
namespace MediaBrowser.Api.Playback.Progressive
{
- public class ProgressiveFileCopier
+ public class ProgressiveFileCopier : IAsyncStreamSource, IHasOptions
{
private readonly IFileSystem _fileSystem;
private readonly TranscodingJob _job;
private readonly ILogger _logger;
+ private readonly string _path;
+ private readonly CancellationToken _cancellationToken;
+ private readonly Dictionary<string, string> _outputHeaders;
// 256k
private const int BufferSize = 81920;
private long _bytesWritten = 0;
- public ProgressiveFileCopier(IFileSystem fileSystem, TranscodingJob job, ILogger logger)
+ public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken)
{
_fileSystem = fileSystem;
+ _path = path;
+ _outputHeaders = outputHeaders;
_job = job;
_logger = logger;
+ _cancellationToken = cancellationToken;
}
- public async Task StreamFile(string path, Stream outputStream, CancellationToken cancellationToken)
+ public IDictionary<string, string> Options
+ {
+ get
+ {
+ return _outputHeaders;
+ }
+ }
+
+ public async Task WriteToAsync(Stream outputStream)
{
try
{
var eofCount = 0;
- using (var fs = _fileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
+ using (var fs = _fileSystem.GetFileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true))
{
while (eofCount < 15)
{
- var bytesRead = await CopyToAsyncInternal(fs, outputStream, BufferSize, cancellationToken).ConfigureAwait(false);
+ var bytesRead = await CopyToAsyncInternal(fs, outputStream, BufferSize, _cancellationToken).ConfigureAwait(false);
//var position = fs.Position;
//_logger.Debug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
@@ -46,7 +63,7 @@ namespace MediaBrowser.Api.Playback.Progressive
{
eofCount++;
}
- await Task.Delay(100, cancellationToken).ConfigureAwait(false);
+ await Task.Delay(100, _cancellationToken).ConfigureAwait(false);
}
else
{
diff --git a/MediaBrowser.Api/Sync/SyncService.cs b/MediaBrowser.Api/Sync/SyncService.cs
index a15ce216f2..b9544d71ba 100644
--- a/MediaBrowser.Api/Sync/SyncService.cs
+++ b/MediaBrowser.Api/Sync/SyncService.cs
@@ -66,6 +66,7 @@ namespace MediaBrowser.Api.Sync
public string Id { get; set; }
}
+ [Route("/Sync/Items/Cancel", "POST", Summary = "Cancels items from a sync target")]
[Route("/Sync/{TargetId}/Items", "DELETE", Summary = "Cancels items from a sync target")]
public class CancelItems : IReturnVoid
{
@@ -211,7 +212,7 @@ namespace MediaBrowser.Api.Sync
return ToOptimizedResult(result);
}
- public void Delete(CancelItems request)
+ public void Any(CancelItems request)
{
var itemIds = request.ItemIds.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);