From 978eedbcb7a778248acd03b7f924260db70cd406 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 25 Sep 2017 01:06:15 -0400 Subject: improve support for compressed xmltv --- MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj | 5 ++--- MediaBrowser.ServerApplication/packages.config | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 23db82cf1..9e4f52489 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -77,9 +77,8 @@ ..\packages\ServiceStack.Text.4.5.8\lib\net45\ServiceStack.Text.dll True - - ..\packages\SharpCompress.0.14.0\lib\net45\SharpCompress.dll - True + + ..\packages\SharpCompress.0.18.2\lib\net45\SharpCompress.dll ..\packages\SimpleInjector.4.0.8\lib\net45\SimpleInjector.dll diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index 85d2613bb..c7b98700e 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -1,7 +1,7 @@  - + -- cgit v1.2.3 From 539fecd08b752a50ebdbcef45b51a998f1390167 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 28 Sep 2017 13:04:06 -0400 Subject: rework live stream creation --- MediaBrowser.Controller/IO/StreamHelper.cs | 5 -- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 2 +- MediaBrowser.Controller/LiveTv/ITunerHost.cs | 15 +++- MediaBrowser.Controller/LiveTv/LiveStream.cs | 87 ---------------------- .../MediaBrowser.Controller.csproj | 1 - MediaBrowser.Server.Mono/MonoAppHost.cs | 2 +- MediaBrowser.Server.Mono/Program.cs | 2 - MediaBrowser.ServerApplication/MainStartup.cs | 2 - MediaBrowser.ServerApplication/WindowsAppHost.cs | 1 - 9 files changed, 16 insertions(+), 101 deletions(-) delete mode 100644 MediaBrowser.Controller/LiveTv/LiveStream.cs (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.Controller/IO/StreamHelper.cs b/MediaBrowser.Controller/IO/StreamHelper.cs index af97a0233..106fec41f 100644 --- a/MediaBrowser.Controller/IO/StreamHelper.cs +++ b/MediaBrowser.Controller/IO/StreamHelper.cs @@ -6,11 +6,6 @@ namespace MediaBrowser.Controller.IO { public static class StreamHelper { - public static void CopyTo(Stream source, Stream destination, int bufferSize, CancellationToken cancellationToken) - { - CopyTo(source, destination, bufferSize, null, cancellationToken); - } - public static void CopyTo(Stream source, Stream destination, int bufferSize, Action onStarted, CancellationToken cancellationToken) { byte[] buffer = new byte[bufferSize]; diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 42c31c629..be85e115c 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -383,7 +383,7 @@ namespace MediaBrowser.Controller.LiveTv event EventHandler> SeriesTimerCreated; string GetEmbyTvActiveRecordingPath(string id); - Task GetEmbyTvLiveStream(string id); + Task GetEmbyTvLiveStream(string id); ActiveRecordingInfo GetActiveRecordingInfo(string path); diff --git a/MediaBrowser.Controller/LiveTv/ITunerHost.cs b/MediaBrowser.Controller/LiveTv/ITunerHost.cs index fc344298b..2019259c5 100644 --- a/MediaBrowser.Controller/LiveTv/ITunerHost.cs +++ b/MediaBrowser.Controller/LiveTv/ITunerHost.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.LiveTv /// The stream identifier. /// The cancellation token. /// Task<MediaSourceInfo>. - Task GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken); + Task GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken); /// /// Gets the channel stream media sources. /// @@ -56,4 +56,17 @@ namespace MediaBrowser.Controller.LiveTv /// Task. Task Validate(TunerHostInfo info); } + + public interface ILiveStream + { + Task Open(CancellationToken cancellationToken); + Task Close(); + int ConsumerCount { get; } + string OriginalStreamId { get; set; } + bool EnableStreamSharing { get; set; } + ITunerHost TunerHost { get; set; } + MediaSourceInfo OpenedMediaSource { get; set; } + string UniqueId { get; } + List SharedStreamIds { get; } + } } diff --git a/MediaBrowser.Controller/LiveTv/LiveStream.cs b/MediaBrowser.Controller/LiveTv/LiveStream.cs deleted file mode 100644 index 20947462e..000000000 --- a/MediaBrowser.Controller/LiveTv/LiveStream.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.IO; -using MediaBrowser.Model.System; - -namespace MediaBrowser.Controller.LiveTv -{ - public class LiveStream - { - public MediaSourceInfo OriginalMediaSource { get; set; } - public MediaSourceInfo OpenedMediaSource { get; set; } - public int ConsumerCount - { - get { return SharedStreamIds.Count; } - } - public ITunerHost TunerHost { get; set; } - public string OriginalStreamId { get; set; } - public bool EnableStreamSharing { get; set; } - public string UniqueId = Guid.NewGuid().ToString("N"); - - public List SharedStreamIds = new List(); - protected readonly IEnvironmentInfo Environment; - protected readonly IFileSystem FileSystem; - const int StreamCopyToBufferSize = 81920; - - public LiveStream(MediaSourceInfo mediaSource, IEnvironmentInfo environment, IFileSystem fileSystem) - { - OriginalMediaSource = mediaSource; - Environment = environment; - FileSystem = fileSystem; - OpenedMediaSource = mediaSource; - EnableStreamSharing = true; - } - - public Task Open(CancellationToken cancellationToken) - { - return OpenInternal(cancellationToken); - } - - protected virtual Task OpenInternal(CancellationToken cancellationToken) - { - return Task.FromResult(true); - } - - public virtual Task Close() - { - return Task.FromResult(true); - } - - protected Stream GetInputStream(string path, bool allowAsyncFileRead) - { - var fileOpenOptions = FileOpenOptions.SequentialScan; - - if (allowAsyncFileRead) - { - fileOpenOptions |= FileOpenOptions.Asynchronous; - } - - return FileSystem.GetFileStream(path, FileOpenMode.Open, FileAccessMode.Read, FileShareMode.ReadWrite, fileOpenOptions); - } - - protected async Task DeleteTempFile(string path, int retryCount = 0) - { - try - { - FileSystem.DeleteFile(path); - return; - } - catch - { - - } - - if (retryCount > 20) - { - return; - } - - await Task.Delay(500).ConfigureAwait(false); - await DeleteTempFile(path, retryCount + 1).ConfigureAwait(false); - } - } -} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 5ef763b62..b33993859 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -145,7 +145,6 @@ - diff --git a/MediaBrowser.Server.Mono/MonoAppHost.cs b/MediaBrowser.Server.Mono/MonoAppHost.cs index fe684d928..312f14732 100644 --- a/MediaBrowser.Server.Mono/MonoAppHost.cs +++ b/MediaBrowser.Server.Mono/MonoAppHost.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Server.Mono get { // A restart script must be provided - return false; + return StartupOptions.ContainsOption("-restartpath") && StartupOptions.ContainsOption("-ffmpeg"); } } diff --git a/MediaBrowser.Server.Mono/Program.cs b/MediaBrowser.Server.Mono/Program.cs index 566a84da2..3267a77b9 100644 --- a/MediaBrowser.Server.Mono/Program.cs +++ b/MediaBrowser.Server.Mono/Program.cs @@ -12,8 +12,6 @@ using System.Reflection; using System.Text.RegularExpressions; using System.Threading.Tasks; using Emby.Drawing; -using Emby.Server.Core.Cryptography; -using Emby.Server.Core; using Emby.Server.Implementations; using Emby.Server.Implementations.EnvironmentInfo; using Emby.Server.Implementations.IO; diff --git a/MediaBrowser.ServerApplication/MainStartup.cs b/MediaBrowser.ServerApplication/MainStartup.cs index d17d9ee43..70b03aa44 100644 --- a/MediaBrowser.ServerApplication/MainStartup.cs +++ b/MediaBrowser.ServerApplication/MainStartup.cs @@ -16,9 +16,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using Emby.Server.Core.Cryptography; using Emby.Drawing; -using Emby.Server.Core; using Emby.Server.Implementations; using Emby.Server.Implementations.Browser; using Emby.Server.Implementations.EnvironmentInfo; diff --git a/MediaBrowser.ServerApplication/WindowsAppHost.cs b/MediaBrowser.ServerApplication/WindowsAppHost.cs index 19079fbc9..9896b75e3 100644 --- a/MediaBrowser.ServerApplication/WindowsAppHost.cs +++ b/MediaBrowser.ServerApplication/WindowsAppHost.cs @@ -6,7 +6,6 @@ using System.Reflection; using System.Runtime.InteropServices.ComTypes; using Emby.Server.CinemaMode; using Emby.Server.Connect; -using Emby.Server.Core; using Emby.Server.Implementations; using Emby.Server.Implementations.EntryPoints; using Emby.Server.Implementations.FFMpeg; -- cgit v1.2.3 From 8d4602035f48e5d00d3145b3e7b6a7075d627b7f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 28 Sep 2017 13:05:10 -0400 Subject: fix for missing response headers --- .../HttpServer/HttpResultFactory.cs | 43 ++++++++++------------ .../ImageEncoderHelper.cs | 1 - 2 files changed, 19 insertions(+), 25 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs index a70aad14e..86deccee1 100644 --- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -142,8 +142,6 @@ namespace Emby.Server.Implementations.HttpServer throw new ArgumentNullException("result"); } - var optimizedResult = ToOptimizedResult(requestContext, result); - if (responseHeaders == null) { responseHeaders = new Dictionary(StringComparer.OrdinalIgnoreCase); @@ -154,15 +152,7 @@ namespace Emby.Server.Implementations.HttpServer responseHeaders["Expires"] = "-1"; } - // Apply headers - var hasHeaders = optimizedResult as IHasHeaders; - - if (hasHeaders != null) - { - AddResponseHeaders(hasHeaders, responseHeaders); - } - - return optimizedResult; + return ToOptimizedResultInternal(requestContext, result, responseHeaders); } public static string GetCompressionType(IRequest request) @@ -189,6 +179,11 @@ namespace Emby.Server.Implementations.HttpServer /// /// public object ToOptimizedResult(IRequest request, T dto) + { + return ToOptimizedResultInternal(request, dto, null); + } + + private object ToOptimizedResultInternal(IRequest request, T dto, IDictionary responseHeaders = null) { var contentType = request.ResponseContentType; @@ -197,27 +192,27 @@ namespace Emby.Server.Implementations.HttpServer case "application/xml": case "text/xml": case "text/xml; charset=utf-8": //"text/xml; charset=utf-8" also matches xml - return SerializeToXmlString(dto); + return GetHttpResult(SerializeToXmlString(dto), contentType, false, responseHeaders); case "application/json": case "text/json": - return _jsonSerializer.SerializeToString(dto); + return GetHttpResult(_jsonSerializer.SerializeToString(dto), contentType, false, responseHeaders); default: - { - var ms = new MemoryStream(); - var writerFn = RequestHelper.GetResponseWriter(HttpListenerHost.Instance, contentType); + { + var ms = new MemoryStream(); + var writerFn = RequestHelper.GetResponseWriter(HttpListenerHost.Instance, contentType); - writerFn(dto, ms); - - ms.Position = 0; + writerFn(dto, ms); - if (string.Equals(request.Verb, "head", StringComparison.OrdinalIgnoreCase)) - { - return GetHttpResult(new byte[] { }, contentType, true); - } + ms.Position = 0; - return GetHttpResult(ms, contentType, true); + if (string.Equals(request.Verb, "head", StringComparison.OrdinalIgnoreCase)) + { + return GetHttpResult(new byte[] { }, contentType, true, responseHeaders); } + + return GetHttpResult(ms, contentType, true, responseHeaders); + } } } diff --git a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs index 0e99bbbad..c86e85785 100644 --- a/MediaBrowser.ServerApplication/ImageEncoderHelper.cs +++ b/MediaBrowser.ServerApplication/ImageEncoderHelper.cs @@ -1,7 +1,6 @@ using System; using Emby.Drawing; using Emby.Drawing.Skia; -using Emby.Server.Core; using Emby.Server.Implementations; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Net; -- cgit v1.2.3