diff options
Diffstat (limited to 'MediaBrowser.Api/Playback')
12 files changed, 63 insertions, 62 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 16175229b5..a05a84b983 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -21,9 +21,11 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using CommonIO; +using MediaBrowser.Common.IO; +using MediaBrowser.Model.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller; +using MediaBrowser.Controller.IO; namespace MediaBrowser.Api.Playback { @@ -1214,7 +1216,7 @@ namespace MediaBrowser.Api.Playback FileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath)); // FFMpeg writes debug/error info to stderr. This is useful when debugging so let's put it in the log directory. - state.LogFileStream = FileSystem.GetFileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, true); + state.LogFileStream = FileSystem.GetFileStream(logFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, true); var commandLineLogMessageBytes = Encoding.UTF8.GetBytes(Request.AbsoluteUri + Environment.NewLine + Environment.NewLine + JsonSerializer.SerializeToString(state.MediaSource) + Environment.NewLine + Environment.NewLine + commandLineLogMessage + Environment.NewLine + Environment.NewLine); await state.LogFileStream.WriteAsync(commandLineLogMessageBytes, 0, commandLineLogMessageBytes.Length, cancellationTokenSource.Token).ConfigureAwait(false); @@ -2304,11 +2306,7 @@ namespace MediaBrowser.Api.Playback private void ApplyDeviceProfileSettings(StreamState state) { - var headers = new Dictionary<string, string>(); - foreach (var key in Request.Headers.AllKeys) - { - headers[key] = Request.Headers[key]; - } + var headers = Request.Headers.ToDictionary(); if (!string.IsNullOrWhiteSpace(state.Request.DeviceProfileId)) { diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 06e57bfc03..55f61f7c7b 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -13,7 +13,9 @@ using System.IO; using System.Text; using System.Threading; using System.Threading.Tasks; -using CommonIO; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; namespace MediaBrowser.Api.Playback.Hls { @@ -145,7 +147,7 @@ namespace MediaBrowser.Api.Playback.Hls private string GetLivePlaylistText(string path, int segmentLength) { - using (var stream = FileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + using (var stream = FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite)) { using (var reader = new StreamReader(stream)) { @@ -187,7 +189,7 @@ namespace MediaBrowser.Api.Playback.Hls { try { - // Need to use FileShare.ReadWrite because we're reading the file at the same time it's being written + // Need to use FileShareMode.ReadWrite because we're reading the file at the same time it's being written using (var fileStream = GetPlaylistFileStream(playlist)) { using (var reader = new StreamReader(fileStream)) @@ -227,11 +229,11 @@ namespace MediaBrowser.Api.Playback.Hls try { - return FileSystem.GetFileStream(tmpPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true); + return FileSystem.GetFileStream(tmpPath, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true); } catch (IOException) { - return FileSystem.GetFileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true); + return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true); } } diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 8dea9068de..07ace5c2c2 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -10,7 +10,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; -using ServiceStack; using System; using System.Collections.Generic; using System.Globalization; @@ -19,7 +18,10 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using CommonIO; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Services; using MimeTypes = MediaBrowser.Model.Net.MimeTypes; namespace MediaBrowser.Api.Playback.Hls @@ -67,7 +69,6 @@ namespace MediaBrowser.Api.Playback.Hls } [Route("/Videos/{Id}/hls1/{PlaylistId}/{SegmentId}.ts", "GET")] - [Api(Description = "Gets an Http live streaming segment file. Internal use only.")] public class GetHlsVideoSegment : VideoStreamRequest { public string PlaylistId { get; set; } @@ -81,7 +82,6 @@ namespace MediaBrowser.Api.Playback.Hls [Route("/Audio/{Id}/hls1/{PlaylistId}/{SegmentId}.aac", "GET")] [Route("/Audio/{Id}/hls1/{PlaylistId}/{SegmentId}.ts", "GET")] - [Api(Description = "Gets an Http live streaming segment file. Internal use only.")] public class GetHlsAudioSegment : StreamRequest { public string PlaylistId { get; set; } @@ -466,7 +466,7 @@ namespace MediaBrowser.Api.Playback.Hls return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions { Path = segmentPath, - FileShare = FileShare.ReadWrite, + FileShare = FileShareMode.ReadWrite, OnComplete = () => { if (transcodingJob != null) diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs index 976fed3f03..4519268fcf 100644 --- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs +++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs @@ -1,11 +1,13 @@ using MediaBrowser.Controller; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Net; -using ServiceStack; using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using MediaBrowser.Common.IO; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback.Hls { @@ -14,7 +16,6 @@ namespace MediaBrowser.Api.Playback.Hls /// </summary> [Route("/Audio/{Id}/hls/{SegmentId}/stream.mp3", "GET")] [Route("/Audio/{Id}/hls/{SegmentId}/stream.aac", "GET")] - [Api(Description = "Gets an Http live streaming segment file. Internal use only.")] public class GetHlsAudioSegmentLegacy { // TODO: Deprecate with new iOS app @@ -36,7 +37,6 @@ namespace MediaBrowser.Api.Playback.Hls /// Class GetHlsVideoSegment /// </summary> [Route("/Videos/{Id}/hls/{PlaylistId}/stream.m3u8", "GET")] - [Api(Description = "Gets an Http live streaming segment file. Internal use only.")] public class GetHlsPlaylistLegacy { // TODO: Deprecate with new iOS app @@ -51,7 +51,6 @@ namespace MediaBrowser.Api.Playback.Hls } [Route("/Videos/ActiveEncodings", "DELETE")] - [Api(Description = "Stops an encoding process")] public class StopEncodingProcess { [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "DELETE")] @@ -65,7 +64,6 @@ namespace MediaBrowser.Api.Playback.Hls /// Class GetHlsVideoSegment /// </summary> [Route("/Videos/{Id}/hls/{PlaylistId}/{SegmentId}.ts", "GET")] - [Api(Description = "Gets an Http live streaming segment file. Internal use only.")] public class GetHlsVideoSegmentLegacy : VideoStreamRequest { public string PlaylistId { get; set; } @@ -130,7 +128,7 @@ namespace MediaBrowser.Api.Playback.Hls var file = request.SegmentId + Path.GetExtension(Request.PathInfo); file = Path.Combine(_appPaths.TranscodingTempPath, file); - return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite).Result; + return ResultFactory.GetStaticFileResult(Request, file, FileShareMode.ReadWrite).Result; } private Task<object> GetFileResult(string path, string playlistPath) @@ -140,7 +138,7 @@ namespace MediaBrowser.Api.Playback.Hls return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions { Path = path, - FileShare = FileShare.ReadWrite, + FileShare = FileShareMode.ReadWrite, OnComplete = () => { if (transcodingJob != null) diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index 61335a6e0d..fcff2ae299 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -5,15 +5,16 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; -using ServiceStack; using System; -using CommonIO; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback.Hls { [Route("/Videos/{Id}/live.m3u8", "GET")] - [Api(Description = "Gets a video stream using HTTP live streaming.")] public class GetLiveHlsStream : VideoStreamRequest { } diff --git a/MediaBrowser.Api/Playback/MediaInfoService.cs b/MediaBrowser.Api/Playback/MediaInfoService.cs index 0611adea5f..373c522da5 100644 --- a/MediaBrowser.Api/Playback/MediaInfoService.cs +++ b/MediaBrowser.Api/Playback/MediaInfoService.cs @@ -9,7 +9,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Session; -using ServiceStack; using System; using System.Collections.Generic; using System.Linq; @@ -18,6 +17,7 @@ using System.Threading.Tasks; using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback { diff --git a/MediaBrowser.Api/Playback/Progressive/AudioService.cs b/MediaBrowser.Api/Playback/Progressive/AudioService.cs index e828a53c92..e4544370ed 100644 --- a/MediaBrowser.Api/Playback/Progressive/AudioService.cs +++ b/MediaBrowser.Api/Playback/Progressive/AudioService.cs @@ -7,10 +7,12 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; -using ServiceStack; using System.Collections.Generic; using System.Threading.Tasks; -using CommonIO; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback.Progressive { diff --git a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs index 809eabef8f..8302c1d42e 100644 --- a/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs +++ b/MediaBrowser.Api/Playback/Progressive/BaseProgressiveStreamingService.cs @@ -9,15 +9,16 @@ using MediaBrowser.Controller.Net; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Serialization; -using ServiceStack.Web; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Threading; using System.Threading.Tasks; -using CommonIO; -using ServiceStack; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback.Progressive { @@ -132,11 +133,10 @@ namespace MediaBrowser.Api.Playback.Progressive // TODO: Don't hardcode this outputHeaders["Content-Type"] = MediaBrowser.Model.Net.MimeTypes.GetMimeType("file.ts"); - var streamSource = new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, CancellationToken.None) + return new ProgressiveFileCopier(state.DirectStreamProvider, outputHeaders, null, Logger, CancellationToken.None) { AllowEndOfFile = false }; - return ResultFactory.GetAsyncStreamWriter(streamSource); } } @@ -177,11 +177,10 @@ namespace MediaBrowser.Api.Playback.Progressive outputHeaders["Content-Type"] = contentType; - var streamSource = new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, CancellationToken.None) + return new ProgressiveFileCopier(FileSystem, state.MediaPath, outputHeaders, null, Logger, CancellationToken.None) { AllowEndOfFile = false }; - return ResultFactory.GetAsyncStreamWriter(streamSource); } TimeSpan? cacheDuration = null; @@ -221,7 +220,7 @@ namespace MediaBrowser.Api.Playback.Progressive // ContentType = contentType, // IsHeadRequest = isHeadRequest, // Path = outputPath, - // FileShare = FileShare.ReadWrite, + // FileShare = FileShareMode.ReadWrite, // OnComplete = () => // { // if (transcodingJob != null) @@ -314,12 +313,12 @@ namespace MediaBrowser.Api.Playback.Progressive var result = new StaticRemoteStreamWriter(response); - result.Options["Content-Type"] = response.ContentType; + result.Headers["Content-Type"] = response.ContentType; // Add the response headers to the result object foreach (var header in responseHeaders) { - result.Options[header.Key] = header.Value; + result.Headers[header.Key] = header.Value; } return result; @@ -356,18 +355,18 @@ namespace MediaBrowser.Api.Playback.Progressive { var streamResult = ResultFactory.GetResult(new byte[] { }, contentType, responseHeaders); - var hasOptions = streamResult as IHasOptions; - if (hasOptions != null) + var hasHeaders = streamResult as IHasHeaders; + if (hasHeaders != null) { if (contentLength.HasValue) { - hasOptions.Options["Content-Length"] = contentLength.Value.ToString(CultureInfo.InvariantCulture); + hasHeaders.Headers["Content-Length"] = contentLength.Value.ToString(CultureInfo.InvariantCulture); } else { - if (hasOptions.Options.ContainsKey("Content-Length")) + if (hasHeaders.Headers.ContainsKey("Content-Length")) { - hasOptions.Options.Remove("Content-Length"); + hasHeaders.Headers.Remove("Content-Length"); } } } @@ -401,9 +400,7 @@ namespace MediaBrowser.Api.Playback.Progressive outputHeaders[item.Key] = item.Value; } - var streamSource = new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, CancellationToken.None); - - return ResultFactory.GetAsyncStreamWriter(streamSource); + return new ProgressiveFileCopier(FileSystem, outputPath, outputHeaders, job, Logger, CancellationToken.None); } finally { diff --git a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs index 3477ad57bd..a33fbcbcfd 100644 --- a/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs +++ b/MediaBrowser.Api/Playback/Progressive/ProgressiveStreamWriter.cs @@ -3,15 +3,17 @@ using System; using System.IO; using System.Threading; using System.Threading.Tasks; -using CommonIO; +using MediaBrowser.Model.IO; using MediaBrowser.Controller.Net; using System.Collections.Generic; -using ServiceStack.Web; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback.Progressive { - public class ProgressiveFileCopier : IAsyncStreamSource, IHasOptions + public class ProgressiveFileCopier : IAsyncStreamWriter, IHasHeaders { private readonly IFileSystem _fileSystem; private readonly TranscodingJob _job; @@ -27,7 +29,7 @@ namespace MediaBrowser.Api.Playback.Progressive public long StartPosition { get; set; } public bool AllowEndOfFile = true; - private IDirectStreamProvider _directStreamProvider; + private readonly IDirectStreamProvider _directStreamProvider; public ProgressiveFileCopier(IFileSystem fileSystem, string path, Dictionary<string, string> outputHeaders, TranscodingJob job, ILogger logger, CancellationToken cancellationToken) { @@ -48,7 +50,7 @@ namespace MediaBrowser.Api.Playback.Progressive _cancellationToken = cancellationToken; } - public IDictionary<string, string> Options + public IDictionary<string, string> Headers { get { @@ -58,10 +60,10 @@ namespace MediaBrowser.Api.Playback.Progressive private Stream GetInputStream() { - return _fileSystem.GetFileStream(_path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true); + return _fileSystem.GetFileStream(_path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, true); } - public async Task WriteToAsync(Stream outputStream) + public async Task WriteToAsync(Stream outputStream, CancellationToken cancellationToken) { try { diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index a1d4963c0a..f32a4e8958 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -7,12 +7,14 @@ using MediaBrowser.Controller.Library; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; -using ServiceStack; using System; using System.IO; using System.Threading.Tasks; -using CommonIO; +using MediaBrowser.Common.IO; +using MediaBrowser.Controller.IO; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback.Progressive { @@ -56,7 +58,6 @@ namespace MediaBrowser.Api.Playback.Progressive [Route("/Videos/{Id}/stream.mov", "HEAD")] [Route("/Videos/{Id}/stream.iso", "HEAD")] [Route("/Videos/{Id}/stream", "HEAD")] - [Api(Description = "Gets a video stream")] public class GetVideoStream : VideoStreamRequest { diff --git a/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs b/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs index fc94d070a0..c4a25a9269 100644 --- a/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs +++ b/MediaBrowser.Api/Playback/StaticRemoteStreamWriter.cs @@ -1,14 +1,14 @@ using MediaBrowser.Common.Net; -using ServiceStack.Web; using System.Collections.Generic; using System.IO; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback { /// <summary> /// Class StaticRemoteStreamWriter /// </summary> - public class StaticRemoteStreamWriter : IStreamWriter, IHasOptions + public class StaticRemoteStreamWriter : IStreamWriter, IHasHeaders { /// <summary> /// The _input stream @@ -29,7 +29,7 @@ namespace MediaBrowser.Api.Playback /// Gets the options. /// </summary> /// <value>The options.</value> - public IDictionary<string, string> Options + public IDictionary<string, string> Headers { get { return _options; } } diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.cs index 5b936f7182..625818d298 100644 --- a/MediaBrowser.Api/Playback/StreamRequest.cs +++ b/MediaBrowser.Api/Playback/StreamRequest.cs @@ -1,5 +1,5 @@ using MediaBrowser.Model.Dlna; -using ServiceStack; +using MediaBrowser.Model.Services; namespace MediaBrowser.Api.Playback { |
