From b3de0249d8b97e305b064a45f6113d5b0d39f3bb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 18 Jul 2015 14:07:03 -0400 Subject: [PATCH] replace channel tabs --- MediaBrowser.Model/Dlna/StreamBuilder.cs | 14 -------------- .../HttpServer/HttpResultFactory.cs | 2 +- .../HttpServer/RangeRequestWriter.cs | 18 +++++++++++++----- .../LiveTv/LiveTvMediaSourceProvider.cs | 8 ++++++-- .../Sync/SyncedMediaSourceProvider.cs | 8 ++++++-- .../MediaBrowser.WebDashboard.csproj | 3 --- 6 files changed, 26 insertions(+), 27 deletions(-) diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index d1abda17e..0f99da8b4 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -772,20 +772,6 @@ namespace MediaBrowser.Model.Dlna } } - // Look for supported embedded subs that we can just mux into the output - foreach (SubtitleProfile profile in subtitleProfiles) - { - if (!profile.SupportsLanguage(subtitleStream.Language)) - { - continue; - } - - if (profile.Method == SubtitleDeliveryMethod.Embed && subtitleStream.IsTextSubtitleStream == MediaStream.IsTextFormat(profile.Format)) - { - return profile; - } - } - return new SubtitleProfile { Method = SubtitleDeliveryMethod.Encode, diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs index ecf58e4a6..da37cfa8b 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpResultFactory.cs @@ -459,7 +459,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer if (!string.IsNullOrEmpty(rangeHeader)) { - return new RangeRequestWriter(rangeHeader, stream, contentType, isHeadRequest) + return new RangeRequestWriter(rangeHeader, stream, contentType, isHeadRequest, _logger) { OnComplete = options.OnComplete }; diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 8c72f9e7e..322114112 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -1,4 +1,5 @@ -using ServiceStack.Web; +using MediaBrowser.Model.Logging; +using ServiceStack.Web; using System; using System.Collections.Generic; using System.Globalization; @@ -25,6 +26,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer private long TotalContentLength { get; set; } public Action OnComplete { get; set; } + private readonly ILogger _logger; /// /// The _options @@ -61,7 +63,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// The source. /// Type of the content. /// if set to true [is head request]. - public RangeRequestWriter(string rangeHeader, Stream source, string contentType, bool isHeadRequest) + public RangeRequestWriter(string rangeHeader, Stream source, string contentType, bool isHeadRequest, ILogger logger) { if (string.IsNullOrEmpty(contentType)) { @@ -71,6 +73,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer RangeHeader = rangeHeader; SourceStream = source; IsHeadRequest = isHeadRequest; + this._logger = logger; ContentType = contentType; Options["Content-Type"] = contentType; @@ -188,10 +191,15 @@ namespace MediaBrowser.Server.Implementations.HttpServer } else { - CopyToInternal(source, responseStream, Convert.ToInt32(RangeLength)); + CopyToInternal(source, responseStream, RangeLength); } } } + catch (Exception ex) + { + _logger.ErrorException("Error in range request writer", ex); + throw; + } finally { if (OnComplete != null) @@ -201,7 +209,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } - private void CopyToInternal(Stream source, Stream destination, int copyLength) + private void CopyToInternal(Stream source, Stream destination, long copyLength) { const int bufferSize = 81920; var array = new byte[bufferSize]; @@ -210,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer { var bytesToCopy = Math.Min(count, copyLength); - destination.Write(array, 0, bytesToCopy); + destination.Write(array, 0, Convert.ToInt32(bytesToCopy)); copyLength -= bytesToCopy; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index b26732441..5ebb79629 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -51,6 +51,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv return Task.FromResult>(new List()); } + // Do not use a pipe here because Roku http requests to the server will fail, without any explicit error message. + private const char StreamIdDelimeter = '_'; + private const string StreamIdDelimeterString = "|"; + private async Task> GetMediaSourcesInternal(ILiveTvItem item, CancellationToken cancellationToken) { IEnumerable sources; @@ -89,7 +93,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv openKeys.Add(item.GetType().Name); openKeys.Add(item.Id.ToString("N")); openKeys.Add(source.Id ?? string.Empty); - source.OpenToken = string.Join("|", openKeys.ToArray()); + source.OpenToken = string.Join(StreamIdDelimeterString, openKeys.ToArray()); // Dummy this up so that direct play checks can still run if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http) @@ -108,7 +112,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv MediaSourceInfo stream; const bool isAudio = false; - var keys = openToken.Split(new[] { '|' }, 3); + var keys = openToken.Split(new[] { StreamIdDelimeter }, 3); var mediaSourceId = keys.Length >= 3 ? keys[2] : null; if (string.Equals(keys[0], typeof(LiveTvChannel).Name, StringComparison.OrdinalIgnoreCase)) diff --git a/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs index f7f320741..524bf9294 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncedMediaSourceProvider.cs @@ -90,15 +90,19 @@ namespace MediaBrowser.Server.Implementations.Sync keyList.Add(provider.GetType().FullName.GetMD5().ToString("N")); keyList.Add(target.Id.GetMD5().ToString("N")); keyList.Add(item.Id); - mediaSource.OpenToken = string.Join("|", keyList.ToArray()); + mediaSource.OpenToken = string.Join(StreamIdDelimeterString, keyList.ToArray()); } list.Add(mediaSource); } + // Do not use a pipe here because Roku http requests to the server will fail, without any explicit error message. + private const char StreamIdDelimeter = '_'; + private const string StreamIdDelimeterString = "|"; + public async Task OpenMediaSource(string openToken, CancellationToken cancellationToken) { - var openKeys = openToken.Split(new[] { '|' }, 3); + var openKeys = openToken.Split(new[] { StreamIdDelimeter }, 3); var provider = _syncManager.ServerSyncProviders .FirstOrDefault(i => string.Equals(openKeys[0], i.GetType().FullName.GetMD5().ToString("N"), StringComparison.OrdinalIgnoreCase)); diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 04ba6d700..ef5bc71ef 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -517,9 +517,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest