From a7b0b601fa7a783e6b8dfbbc8c74485f53a58259 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 2 Oct 2017 16:18:27 -0400 Subject: 3.2.33.1 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index ff7ab5136..75e244625 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.0")] +[assembly: AssemblyVersion("3.2.33.1")] -- cgit v1.2.3 From 1caae368d5f75d96dada65cd2175831982363c21 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 4 Oct 2017 14:51:56 -0400 Subject: 3.2.33.2 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 75e244625..9dbc18ddd 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.1")] +[assembly: AssemblyVersion("3.2.33.2")] -- cgit v1.2.3 From db01b79901e503350f8359cab8b1eeae5ea30735 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 5 Oct 2017 14:11:46 -0400 Subject: 3.2.33.3 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 9dbc18ddd..22bfb62f2 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.2")] +[assembly: AssemblyVersion("3.2.33.3")] -- cgit v1.2.3 From be1ed79cf633b5e9d8728ca50fe6e98d514f0ad6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Oct 2017 02:15:47 -0400 Subject: 3.2.33.4 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 22bfb62f2..d2ae99469 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.3")] +[assembly: AssemblyVersion("3.2.33.4")] -- cgit v1.2.3 From 3c7ee764eca1d5babe648a7d98a711bebaf17e3f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 9 Oct 2017 01:24:55 -0400 Subject: 3.2.33.5 --- Emby.Photos/PhotoProvider.cs | 4 ++-- Mono.Nat/Upnp/Messages/UpnpMessage.cs | 1 + SharedVersion.cs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'SharedVersion.cs') diff --git a/Emby.Photos/PhotoProvider.cs b/Emby.Photos/PhotoProvider.cs index fe77cff69..b2d6ecdcb 100644 --- a/Emby.Photos/PhotoProvider.cs +++ b/Emby.Photos/PhotoProvider.cs @@ -31,14 +31,14 @@ namespace Emby.Photos } // These are causing taglib to hang - private string[] _excludeExtensions = new string[] { ".dng" }; + private string[] _includextensions = new string[] { ".jpg", ".jpeg", ".png", ".tiff" }; public Task FetchAsync(Photo item, MetadataRefreshOptions options, CancellationToken cancellationToken) { item.SetImagePath(ImageType.Primary, item.Path); // Examples: https://github.com/mono/taglib-sharp/blob/a5f6949a53d09ce63ee7495580d6802921a21f14/tests/fixtures/TagLib.Tests.Images/NullOrientationTest.cs - if (!_excludeExtensions.Contains(Path.GetExtension(item.Path) ?? string.Empty, StringComparer.OrdinalIgnoreCase)) + if (_includextensions.Contains(Path.GetExtension(item.Path) ?? string.Empty, StringComparer.OrdinalIgnoreCase)) { try { diff --git a/Mono.Nat/Upnp/Messages/UpnpMessage.cs b/Mono.Nat/Upnp/Messages/UpnpMessage.cs index 54cca4494..d15e48b2f 100644 --- a/Mono.Nat/Upnp/Messages/UpnpMessage.cs +++ b/Mono.Nat/Upnp/Messages/UpnpMessage.cs @@ -51,6 +51,7 @@ namespace Mono.Nat.Upnp NatUtility.Log("Initiating request to: {0}", ss); var req = new HttpRequestOptions(); + req.LogErrors = false; req.Url = ss; req.EnableKeepAlive = false; req.RequestContentType = "text/xml; charset=\"utf-8\""; diff --git a/SharedVersion.cs b/SharedVersion.cs index d2ae99469..fcfa2ec5a 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.4")] +[assembly: AssemblyVersion("3.2.33.5")] -- cgit v1.2.3 From f534ac2c3e83ea0e7965c58092a135fa77ae6dfc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 11 Oct 2017 02:26:41 -0400 Subject: 3.2.33.6 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index fcfa2ec5a..cd78e0886 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.5")] +[assembly: AssemblyVersion("3.2.33.6")] -- cgit v1.2.3 From 2f06bb5bf52dc4dfc3d1763488d215a7e352a1fc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Oct 2017 01:47:13 -0400 Subject: 3.2.33.7 --- Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs | 8 -------- SharedVersion.cs | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'SharedVersion.cs') diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index 8d1854f4b..9fc6687d1 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -93,13 +93,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts protected override async Task> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) { - var channelIdPrefix = GetFullChannelIdPrefix(info); - - if (!channelId.StartsWith(channelIdPrefix, StringComparison.OrdinalIgnoreCase)) - { - return null; - } - var channels = await GetChannels(info, true, cancellationToken).ConfigureAwait(false); var channel = channels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); if (channel != null) @@ -165,7 +158,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts RequiresOpening = true, RequiresClosing = true, RequiresLooping = info.EnableStreamLooping, - EnableMpDecimate = info.EnableMpDecimate, ReadAtNativeFramerate = false, diff --git a/SharedVersion.cs b/SharedVersion.cs index cd78e0886..617d9cf04 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.6")] +[assembly: AssemblyVersion("3.2.33.7")] -- cgit v1.2.3 From f8a3701bb515dae6be7d8b23bf83c4ce7aac8aa1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 14 Oct 2017 02:54:16 -0400 Subject: 3.2.33.8 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 617d9cf04..881dbe03c 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.7")] +[assembly: AssemblyVersion("3.2.33.8")] -- cgit v1.2.3 From 6f15141d73aae2fa78511077580fdc2cd895694f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 14 Oct 2017 14:36:40 -0400 Subject: 3.2.33.9 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 881dbe03c..1db2b31b5 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.8")] +[assembly: AssemblyVersion("3.2.33.9")] -- cgit v1.2.3 From b4fff161fa80b55c9e1ea63914669b4bcd78e41e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 Oct 2017 14:09:14 -0400 Subject: 3.2.33.10 --- .../Localization/LocalizationManager.cs | 15 +++++++++++++-- SharedVersion.cs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'SharedVersion.cs') diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 278a39cd1..b0cee12be 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -387,36 +387,47 @@ namespace Emby.Server.Implementations.Localization return new LocalizatonOption[] { new LocalizatonOption{ Name="Arabic", Value="ar"}, + new LocalizatonOption{ Name="Belarusian (Belarus)", Value="be-BY"}, new LocalizatonOption{ Name="Bulgarian (Bulgaria)", Value="bg-BG"}, new LocalizatonOption{ Name="Catalan", Value="ca"}, new LocalizatonOption{ Name="Chinese Simplified", Value="zh-CN"}, new LocalizatonOption{ Name="Chinese Traditional", Value="zh-TW"}, + new LocalizatonOption{ Name="Chinese Traditional (Hong Kong)", Value="zh-HK"}, new LocalizatonOption{ Name="Croatian", Value="hr"}, new LocalizatonOption{ Name="Czech", Value="cs"}, new LocalizatonOption{ Name="Danish", Value="da"}, new LocalizatonOption{ Name="Dutch", Value="nl"}, new LocalizatonOption{ Name="English (United Kingdom)", Value="en-GB"}, - new LocalizatonOption{ Name="English (United States)", Value="en-us"}, + new LocalizatonOption{ Name="English (United States)", Value="en-US"}, new LocalizatonOption{ Name="Finnish", Value="fi"}, new LocalizatonOption{ Name="French", Value="fr"}, new LocalizatonOption{ Name="French (Canada)", Value="fr-CA"}, new LocalizatonOption{ Name="German", Value="de"}, new LocalizatonOption{ Name="Greek", Value="el"}, new LocalizatonOption{ Name="Hebrew", Value="he"}, + new LocalizatonOption{ Name="Hindi (India)", Value="hi-IN"}, new LocalizatonOption{ Name="Hungarian", Value="hu"}, new LocalizatonOption{ Name="Indonesian", Value="id"}, new LocalizatonOption{ Name="Italian", Value="it"}, + new LocalizatonOption{ Name="Japanese", Value="ja"}, new LocalizatonOption{ Name="Kazakh", Value="kk"}, + new LocalizatonOption{ Name="Korean", Value="ko"}, + new LocalizatonOption{ Name="Lithuanian", Value="lt-LT"}, + new LocalizatonOption{ Name="Malay", Value="ms"}, new LocalizatonOption{ Name="Norwegian Bokmål", Value="nb"}, new LocalizatonOption{ Name="Persian", Value="fa"}, new LocalizatonOption{ Name="Polish", Value="pl"}, new LocalizatonOption{ Name="Portuguese (Brazil)", Value="pt-BR"}, new LocalizatonOption{ Name="Portuguese (Portugal)", Value="pt-PT"}, + new LocalizatonOption{ Name="Romanian", Value="ro"}, new LocalizatonOption{ Name="Russian", Value="ru"}, + new LocalizatonOption{ Name="Slovak", Value="sk"}, new LocalizatonOption{ Name="Slovenian (Slovenia)", Value="sl-SI"}, - new LocalizatonOption{ Name="Spanish", Value="es-ES"}, + new LocalizatonOption{ Name="Spanish", Value="es"}, + new LocalizatonOption{ Name="Spanish (Latin America)", Value="es-419"}, new LocalizatonOption{ Name="Spanish (Mexico)", Value="es-MX"}, new LocalizatonOption{ Name="Swedish", Value="sv"}, + new LocalizatonOption{ Name="Swiss German", Value="gsw"}, new LocalizatonOption{ Name="Turkish", Value="tr"}, new LocalizatonOption{ Name="Ukrainian", Value="uk"}, new LocalizatonOption{ Name="Vietnamese", Value="vi"} diff --git a/SharedVersion.cs b/SharedVersion.cs index 1db2b31b5..e92f1a55e 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.9")] +[assembly: AssemblyVersion("3.2.33.10")] -- cgit v1.2.3 From b263726a3f13a0e6627b6065478c4a9ba15729cc Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 16 Oct 2017 14:27:46 -0400 Subject: 3.2.33.11 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index e92f1a55e..6af624ee6 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.10")] +[assembly: AssemblyVersion("3.2.33.11")] -- cgit v1.2.3 From 32e89f6debd79c4383320b2fbd42224fc2dce891 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 17 Oct 2017 15:50:10 -0400 Subject: resolve version changing in now playing display --- Emby.Server.Implementations/ApplicationHost.cs | 9 +++++++- .../HttpServer/Security/AuthorizationContext.cs | 26 ++++++++++++++++++++-- .../HttpServer/Security/SessionContext.cs | 9 -------- SharedVersion.cs | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) (limited to 'SharedVersion.cs') diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 91493cf53..c1ab9ec22 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -775,7 +775,14 @@ namespace Emby.Server.Implementations } // Put the app config in the log for troubleshooting purposes - Logger.LogMultiline("Application configuration:", LogSeverity.Info, new StringBuilder(JsonSerializer.SerializeToString(ConfigurationManager.CommonConfiguration))); + var configJson = new StringBuilder(JsonSerializer.SerializeToString(ConfigurationManager.CommonConfiguration)); + + if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePassword)) + { + configJson = configJson.Replace(ServerConfigurationManager.Configuration.CertificatePassword, "####"); + } + + Logger.LogMultiline("Application configuration:", LogSeverity.Info, configJson); if (Plugins != null) { diff --git a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs index c9d5ed007..a41c51d1a 100644 --- a/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/AuthorizationContext.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using MediaBrowser.Model.Services; using System.Linq; +using System.Threading; namespace Emby.Server.Implementations.HttpServer.Security { @@ -95,23 +96,44 @@ namespace Emby.Server.Implementations.HttpServer.Security { info.UserId = tokenInfo.UserId; + var updateToken = false; + // TODO: Remove these checks for IsNullOrWhiteSpace if (string.IsNullOrWhiteSpace(info.Client)) { info.Client = tokenInfo.AppName; } + + if (string.IsNullOrWhiteSpace(info.DeviceId)) + { + info.DeviceId = tokenInfo.DeviceId; + } + + if (string.IsNullOrWhiteSpace(info.Device)) { info.Device = tokenInfo.DeviceName; } - if (string.IsNullOrWhiteSpace(info.DeviceId)) + else if (!string.Equals(info.Device, tokenInfo.DeviceName, StringComparison.OrdinalIgnoreCase)) { - info.DeviceId = tokenInfo.DeviceId; + updateToken = true; + tokenInfo.DeviceName = info.Device; } + if (string.IsNullOrWhiteSpace(info.Version)) { info.Version = tokenInfo.AppVersion; } + else if (!string.Equals(info.Version, tokenInfo.AppVersion, StringComparison.OrdinalIgnoreCase)) + { + updateToken = true; + tokenInfo.AppVersion = info.Version; + } + + if (updateToken) + { + _authRepo.Update(tokenInfo, CancellationToken.None); + } } else { diff --git a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs index dd5d64bf6..9826a0d56 100644 --- a/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs +++ b/Emby.Server.Implementations/HttpServer/Security/SessionContext.cs @@ -25,15 +25,6 @@ namespace Emby.Server.Implementations.HttpServer.Security { var authorization = _authContext.GetAuthorizationInfo(requestContext); - //if (!string.IsNullOrWhiteSpace(authorization.Token)) - //{ - // var auth = GetTokenInfo(requestContext); - // if (auth != null) - // { - // return _sessionManager.GetSessionByAuthenticationToken(auth, authorization.DeviceId, requestContext.RemoteIp, authorization.Version); - // } - //} - var user = string.IsNullOrWhiteSpace(authorization.UserId) ? null : _userManager.GetUserById(authorization.UserId); return _sessionManager.LogSessionActivity(authorization.Client, authorization.Version, authorization.DeviceId, authorization.Device, requestContext.RemoteIp, user); } diff --git a/SharedVersion.cs b/SharedVersion.cs index 6af624ee6..92ae176b8 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.11")] +[assembly: AssemblyVersion("3.2.33.12")] -- cgit v1.2.3 From ab61eb5cae54578b434566d0c9d84f38b1b523bf Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 18 Oct 2017 21:22:13 -0400 Subject: 3.2.33.13 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 92ae176b8..6cc9cee20 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.12")] +[assembly: AssemblyVersion("3.2.33.13")] -- cgit v1.2.3 From 0cf4f01dc72b3775e3af067ed1eef51c683a3c02 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 20 Oct 2017 12:18:35 -0400 Subject: 3.2.33.14 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 6cc9cee20..2761b3a27 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.13")] +[assembly: AssemblyVersion("3.2.33.14")] -- cgit v1.2.3 From 7e2c52936ff15c2569a5cb6b3c5351c16c4163ff Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 21 Oct 2017 12:40:11 -0400 Subject: 3.2.33.15 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 2761b3a27..b8fee04d7 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.14")] +[assembly: AssemblyVersion("3.2.33.15")] -- cgit v1.2.3 From 61a2c23b0f7d469135b501d543fc6a146ed94f14 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Oct 2017 02:23:03 -0400 Subject: 3.2.33.16 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index b8fee04d7..b2144e9de 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.15")] +[assembly: AssemblyVersion("3.2.33.16")] -- cgit v1.2.3 From f6df19ddf4b1e412abe90ad28d237edb5fc24ece Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Oct 2017 02:38:57 -0400 Subject: 3.2.33.17 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index b2144e9de..e5411afd7 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.16")] +[assembly: AssemblyVersion("3.2.33.17")] -- cgit v1.2.3 From 4fb4a87ca0d2730a8dee20ceb09f31e01ff6d5cf Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 22 Oct 2017 17:38:37 -0400 Subject: 3.2.33.18 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index e5411afd7..9e5fa9c8e 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.17")] +[assembly: AssemblyVersion("3.2.33.18")] -- cgit v1.2.3 From 141e5b56b0a9c2cdf125314abc68e61dd414bda9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 23 Oct 2017 02:06:11 -0400 Subject: 3.2.33.19 --- SharedVersion.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'SharedVersion.cs') diff --git a/SharedVersion.cs b/SharedVersion.cs index 9e5fa9c8e..67b6004ad 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.18")] +[assembly: AssemblyVersion("3.2.33.19")] -- cgit v1.2.3 From 9b71812325f03b8147d7ec13511974856f7daa6a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 23 Oct 2017 15:14:11 -0400 Subject: update live stream management --- .../HttpServer/HttpListenerHost.cs | 2 - .../LiveTv/EmbyTV/EmbyTV.cs | 24 ++- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 2 +- .../TunerHosts/HdHomerun/HdHomerunHttpStream.cs | 55 +++---- .../TunerHosts/HdHomerun/HdHomerunManager.cs | 34 ++-- .../TunerHosts/HdHomerun/HdHomerunUdpStream.cs | 178 +++++++++++---------- .../LiveTv/TunerHosts/LiveStream.cs | 15 +- MediaBrowser.Controller/LiveTv/ITunerHost.cs | 4 +- SharedVersion.cs | 2 +- 9 files changed, 159 insertions(+), 157 deletions(-) (limited to 'SharedVersion.cs') diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 1d3d4f1e5..937eb8029 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -411,8 +411,6 @@ namespace Emby.Server.Implementations.HttpServer host = host ?? string.Empty; - _logger.Debug("Validating host {0}", host); - if (_networkManager.IsInPrivateAddressSpace(host)) { hosts.Add("localhost"); diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index e7a360594..6c254018e 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1222,7 +1222,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV _logger.Info("Closing live stream {0}", id); - await stream.Close().ConfigureAwait(false); + stream.Close(); _logger.Info("Live stream {0} closed successfully", id); } } @@ -1286,9 +1286,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV Id = timer.Id }; - if (_activeRecordings.TryAdd(timer.Id, activeRecordingInfo)) + if (!_activeRecordings.ContainsKey(timer.Id)) { - await RecordStream(timer, recordingEndDate, activeRecordingInfo, activeRecordingInfo.CancellationTokenSource.Token).ConfigureAwait(false); + await RecordStream(timer, recordingEndDate, activeRecordingInfo).ConfigureAwait(false); } else { @@ -1397,8 +1397,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV return Path.Combine(recordPath, recordingFileName); } - private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, - ActiveRecordingInfo activeRecordingInfo, CancellationToken cancellationToken) + private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, ActiveRecordingInfo activeRecordingInfo) { if (timer == null) { @@ -1420,19 +1419,18 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (programInfo != null) { CopyProgramInfoToTimerInfo(programInfo, timer); - //activeRecordingInfo.Program = programInfo; } string seriesPath = null; var recordPath = GetRecordingPath(timer, out seriesPath); var recordingStatus = RecordingStatus.New; + var recorder = await GetRecorder().ConfigureAwait(false); + string liveStreamId = null; try { - var recorder = await GetRecorder().ConfigureAwait(false); - var allMediaSources = await GetChannelStreamMediaSources(timer.ChannelId, CancellationToken.None).ConfigureAwait(false); _logger.Info("Opening recording stream from tuner provider"); @@ -1442,14 +1440,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var mediaStreamInfo = liveStreamInfo.Item2; liveStreamId = mediaStreamInfo.Id; - // HDHR doesn't seem to release the tuner right away after first probing with ffmpeg - //await Task.Delay(3000, cancellationToken).ConfigureAwait(false); - recordPath = recorder.GetOutputPath(mediaStreamInfo, recordPath); recordPath = EnsureFileUnique(recordPath, timer.Id); _libraryMonitor.ReportFileSystemChangeBeginning(recordPath); - activeRecordingInfo.Path = recordPath; var duration = recordingEndDate - DateTime.UtcNow; @@ -1459,6 +1453,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV Action onStarted = async () => { + activeRecordingInfo.Path = recordPath; + + _activeRecordings.TryAdd(timer.Id, activeRecordingInfo); + timer.Status = RecordingStatus.InProgress; _timerProvider.AddOrUpdate(timer, false); @@ -1470,7 +1468,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV EnforceKeepUpTo(timer, seriesPath); }; - await recorder.Record(liveStreamInfo.Item1 as IDirectStreamProvider, mediaStreamInfo, recordPath, duration, onStarted, cancellationToken).ConfigureAwait(false); + await recorder.Record(liveStreamInfo.Item1 as IDirectStreamProvider, mediaStreamInfo, recordPath, duration, onStarted, activeRecordingInfo.CancellationTokenSource.Token).ConfigureAwait(false); recordingStatus = RecordingStatus.Completed; _logger.Info("Recording completed: {0}", recordPath); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index f8bb766d2..59346cdec 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -203,7 +203,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var uri = new Uri(GetApiUrl(info, false)); - using (var manager = new HdHomerunManager(_socketFactory)) + using (var manager = new HdHomerunManager(_socketFactory, Logger)) { // Legacy HdHomeruns are IPv4 only var ipInfo = _networkManager.ParseIpAddress(uri.Host); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs index f3d89c6cc..7e0e5fc5c 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs @@ -22,8 +22,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private readonly IHttpClient _httpClient; private readonly IServerApplicationHost _appHost; - private readonly TaskCompletionSource _liveStreamTaskCompletionSource = new TaskCompletionSource(); - public HdHomerunHttpStream(MediaSourceInfo mediaSource, string originalStreamId, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost, IEnvironmentInfo environment) : base(mediaSource, environment, fileSystem, logger, appPaths) { @@ -32,7 +30,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun OriginalStreamId = originalStreamId; } - protected override Task OpenInternal(CancellationToken openCancellationToken) + public override async Task Open(CancellationToken openCancellationToken) { LiveStreamCancellationTokenSource.Token.ThrowIfCancellationRequested(); @@ -40,11 +38,26 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var url = mediaSource.Path; + FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); + Logger.Info("Opening HDHR Live stream from {0}", url); - var taskCompletionSource = new TaskCompletionSource(); + var response = await _httpClient.SendAsync(new HttpRequestOptions + { + Url = url, + CancellationToken = CancellationToken.None, + BufferContent = false, + + // Increase a little bit + TimeoutMs = 30000, - StartStreaming(url, taskCompletionSource, LiveStreamCancellationTokenSource.Token); + EnableHttpCompression = false + + }, "GET").ConfigureAwait(false); + + Logger.Info("Opened HDHR stream from {0}", url); + + StartStreaming(response, LiveStreamCancellationTokenSource.Token); //OpenedMediaSource.Protocol = MediaProtocol.File; //OpenedMediaSource.Path = tempFile; @@ -58,50 +71,30 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun //OpenedMediaSource.SupportsDirectPlay = false; //OpenedMediaSource.SupportsDirectStream = true; //OpenedMediaSource.SupportsTranscoding = true; - - return taskCompletionSource.Task; - - //await Task.Delay(5000).ConfigureAwait(false); } - public override async Task Close() + public override void Close() { Logger.Info("Closing HDHR live stream"); LiveStreamCancellationTokenSource.Cancel(); - - await _liveStreamTaskCompletionSource.Task.ConfigureAwait(false); - await DeleteTempFile(TempFilePath).ConfigureAwait(false); } - private Task StartStreaming(string url, TaskCompletionSource openTaskCompletionSource, CancellationToken cancellationToken) + private Task StartStreaming(HttpResponseInfo response, CancellationToken cancellationToken) { return Task.Run(async () => { try { - using (var response = await _httpClient.SendAsync(new HttpRequestOptions - { - Url = url, - CancellationToken = cancellationToken, - BufferContent = false, - - // Increase a little bit - TimeoutMs = 30000, - - EnableHttpCompression = false - - }, "GET").ConfigureAwait(false)) + using (response) { using (var stream = response.Content) { - Logger.Info("Opened HDHR stream from {0}", url); - - Logger.Info("Beginning multicastStream.CopyUntilCancelled"); + Logger.Info("Beginning HdHomerunHttpStream stream to file"); FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None)) { - StreamHelper.CopyTo(stream, fileStream, 81920, () => Resolve(openTaskCompletionSource), cancellationToken); + StreamHelper.CopyTo(stream, fileStream, 81920, null, cancellationToken); } } } @@ -114,7 +107,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun Logger.ErrorException("Error copying live stream.", ex); } - _liveStreamTaskCompletionSource.TrySetResult(true); + await DeleteTempFile(TempFilePath).ConfigureAwait(false); }); } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs index c737c4cba..5156f1744 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunManager.cs @@ -6,6 +6,7 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Net; +using MediaBrowser.Model.Logging; namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { @@ -89,9 +90,12 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private readonly ISocketFactory _socketFactory; private IpAddressInfo _remoteIp; - public HdHomerunManager(ISocketFactory socketFactory) + private ILogger _logger; + + public HdHomerunManager(ISocketFactory socketFactory, ILogger logger) { _socketFactory = socketFactory; + _logger = logger; } public void Dispose() @@ -140,6 +144,8 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun _lockkey = (uint)rand.Next(); } + var lockKeyValue = _lockkey.Value; + var ipEndPoint = new IpEndPointInfo(_remoteIp, HdHomeRunPort); for (int i = 0; i < numTuners; ++i) @@ -148,7 +154,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun continue; _activeTuner = i; - var lockKeyString = String.Format("{0:d}", _lockkey.Value); + var lockKeyString = String.Format("{0:d}", lockKeyValue); var lockkeyMsg = CreateSetMessage(i, "lockkey", lockKeyString, null); await tcpClient.SendToAsync(lockkeyMsg, 0, lockkeyMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); @@ -160,27 +166,27 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var commandList = commands.GetCommands(); foreach(Tuple command in commandList) { - var channelMsg = CreateSetMessage(i, command.Item1, command.Item2, _lockkey.Value); + var channelMsg = CreateSetMessage(i, command.Item1, command.Item2, lockKeyValue); await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); // parse response to make sure it worked if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal)) { - await ReleaseLockkey(tcpClient).ConfigureAwait(false); + await ReleaseLockkey(tcpClient, lockKeyValue).ConfigureAwait(false); continue; } } var targetValue = String.Format("rtp://{0}:{1}", localIp, localPort); - var targetMsg = CreateSetMessage(i, "target", targetValue, _lockkey.Value); + var targetMsg = CreateSetMessage(i, "target", targetValue, lockKeyValue); await tcpClient.SendToAsync(targetMsg, 0, targetMsg.Length, ipEndPoint, cancellationToken).ConfigureAwait(false); response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); // parse response to make sure it worked if (!ParseReturnMessage(response.Buffer, response.ReceivedBytes, out returnVal)) { - await ReleaseLockkey(tcpClient).ConfigureAwait(false); + await ReleaseLockkey(tcpClient, lockKeyValue).ConfigureAwait(false); continue; } @@ -201,7 +207,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun foreach (Tuple command in commandList) { - var channelMsg = CreateSetMessage(_activeTuner, command.Item1, command.Item2, _lockkey.Value); + var channelMsg = CreateSetMessage(_activeTuner, command.Item1, command.Item2, _lockkey); await tcpClient.SendToAsync(channelMsg, 0, channelMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), cancellationToken).ConfigureAwait(false); var response = await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, cancellationToken).ConfigureAwait(false); // parse response to make sure it worked @@ -216,24 +222,28 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun public async Task StopStreaming() { - if (!_lockkey.HasValue) + var lockKey = _lockkey; + + if (!lockKey.HasValue) return; using (var socket = _socketFactory.CreateTcpSocket(_remoteIp, HdHomeRunPort)) { - await ReleaseLockkey(socket).ConfigureAwait(false); + await ReleaseLockkey(socket, lockKey.Value).ConfigureAwait(false); } } - private async Task ReleaseLockkey(ISocket tcpClient) + private async Task ReleaseLockkey(ISocket tcpClient, uint lockKeyValue) { - var releaseTarget = CreateSetMessage(_activeTuner, "target", "none", _lockkey); + _logger.Info("HdHomerunManager.ReleaseLockkey {0}", lockKeyValue); + + var releaseTarget = CreateSetMessage(_activeTuner, "target", "none", lockKeyValue); await tcpClient.SendToAsync(releaseTarget, 0, releaseTarget.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), CancellationToken.None).ConfigureAwait(false); var receiveBuffer = new byte[8192]; await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, CancellationToken.None).ConfigureAwait(false); - var releaseKeyMsg = CreateSetMessage(_activeTuner, "lockkey", "none", _lockkey); + var releaseKeyMsg = CreateSetMessage(_activeTuner, "lockkey", "none", lockKeyValue); _lockkey = null; await tcpClient.SendToAsync(releaseKeyMsg, 0, releaseKeyMsg.Length, new IpEndPointInfo(_remoteIp, HdHomeRunPort), CancellationToken.None).ConfigureAwait(false); await tcpClient.ReceiveAsync(receiveBuffer, 0, receiveBuffer.Length, CancellationToken.None).ConfigureAwait(false); diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs index 4187fcd8f..06326d26c 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs @@ -1,23 +1,16 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; using System.Threading; using System.Threading.Tasks; -using Emby.Server.Implementations.IO; using MediaBrowser.Common.Net; using MediaBrowser.Controller; using MediaBrowser.Controller.Library; -using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.Dto; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; using MediaBrowser.Model.MediaInfo; using MediaBrowser.Model.Net; using MediaBrowser.Model.System; -using System.Globalization; -using MediaBrowser.Controller.IO; namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun { @@ -26,7 +19,6 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private readonly IServerApplicationHost _appHost; private readonly ISocketFactory _socketFactory; - private readonly TaskCompletionSource _liveStreamTaskCompletionSource = new TaskCompletionSource(); private readonly IHdHomerunChannelCommands _channelCommands; private readonly int _numTuners; private readonly INetworkManager _networkManager; @@ -42,7 +34,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun _numTuners = numTuners; } - protected override Task OpenInternal(CancellationToken openCancellationToken) + public override async Task Open(CancellationToken openCancellationToken) { LiveStreamCancellationTokenSource.Token.ThrowIfCancellationRequested(); @@ -51,11 +43,53 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var uri = new Uri(mediaSource.Path); var localPort = _networkManager.GetRandomUnusedUdpPort(); + FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); + Logger.Info("Opening HDHR UDP Live stream from {0}", uri.Host); + var remoteAddress = _networkManager.ParseIpAddress(uri.Host); + IpAddressInfo localAddress = null; + using (var tcpSocket = _socketFactory.CreateSocket(remoteAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp, false)) + { + try + { + tcpSocket.Connect(new IpEndPointInfo(remoteAddress, HdHomerunManager.HdHomeRunPort)); + localAddress = tcpSocket.LocalEndPoint.IpAddress; + tcpSocket.Close(); + } + catch (Exception) + { + Logger.Error("Unable to determine local ip address for Legacy HDHomerun stream."); + return; + } + } + + var udpClient = _socketFactory.CreateUdpSocket(localPort); + var hdHomerunManager = new HdHomerunManager(_socketFactory, Logger); + + try + { + // send url to start streaming + await hdHomerunManager.StartStreaming(remoteAddress, localAddress, localPort, _channelCommands, _numTuners, openCancellationToken).ConfigureAwait(false); + } + catch (Exception ex) + { + using (udpClient) + { + using (hdHomerunManager) + { + if (!(ex is OperationCanceledException)) + { + Logger.ErrorException("Error opening live stream:", ex); + } + throw; + } + } + } + var taskCompletionSource = new TaskCompletionSource(); - StartStreaming(uri.Host, localPort, taskCompletionSource, LiveStreamCancellationTokenSource.Token); + StartStreaming(udpClient, hdHomerunManager, remoteAddress, localAddress, localPort, taskCompletionSource, LiveStreamCancellationTokenSource.Token); //OpenedMediaSource.Protocol = MediaProtocol.File; //OpenedMediaSource.Path = tempFile; @@ -67,86 +101,47 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun //OpenedMediaSource.SupportsDirectStream = true; //OpenedMediaSource.SupportsTranscoding = true; - return taskCompletionSource.Task; - //await Task.Delay(5000).ConfigureAwait(false); + await taskCompletionSource.Task.ConfigureAwait(false); } - public override Task Close() + public override void Close() { Logger.Info("Closing HDHR UDP live stream"); LiveStreamCancellationTokenSource.Cancel(); - - return _liveStreamTaskCompletionSource.Task; } - private Task StartStreaming(string remoteIp, int localPort, TaskCompletionSource openTaskCompletionSource, CancellationToken cancellationToken) + private Task StartStreaming(ISocket udpClient, HdHomerunManager hdHomerunManager, IpAddressInfo remoteAddress, IpAddressInfo localAddress, int localPort, TaskCompletionSource openTaskCompletionSource, CancellationToken cancellationToken) { return Task.Run(async () => { - var isFirstAttempt = true; - using (var udpClient = _socketFactory.CreateUdpSocket(localPort)) + using (udpClient) { - using (var hdHomerunManager = new HdHomerunManager(_socketFactory)) + using (hdHomerunManager) { - var remoteAddress = _networkManager.ParseIpAddress(remoteIp); - IpAddressInfo localAddress = null; - using (var tcpSocket = _socketFactory.CreateSocket(remoteAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp, false)) + try + { + await CopyTo(udpClient, TempFilePath, openTaskCompletionSource, cancellationToken).ConfigureAwait(false); + } + catch (OperationCanceledException ex) { - try - { - tcpSocket.Connect(new IpEndPointInfo(remoteAddress, HdHomerunManager.HdHomeRunPort)); - localAddress = tcpSocket.LocalEndPoint.IpAddress; - tcpSocket.Close(); - } - catch (Exception) - { - Logger.Error("Unable to determine local ip address for Legacy HDHomerun stream."); - return; - } + Logger.Info("HDHR UDP stream cancelled or timed out from {0}", remoteAddress); + openTaskCompletionSource.TrySetException(ex); + } + catch (Exception ex) + { + Logger.ErrorException("Error opening live stream:", ex); + openTaskCompletionSource.TrySetException(ex); } - while (!cancellationToken.IsCancellationRequested) + try { - try - { - // send url to start streaming - await hdHomerunManager.StartStreaming(remoteAddress, localAddress, localPort, _channelCommands, _numTuners, cancellationToken).ConfigureAwait(false); - - Logger.Info("Opened HDHR UDP stream from {0}", remoteAddress); - - if (!cancellationToken.IsCancellationRequested) - { - FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath)); - using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None)) - { - CopyTo(udpClient, fileStream, openTaskCompletionSource, cancellationToken); - } - } - } - catch (OperationCanceledException ex) - { - Logger.Info("HDHR UDP stream cancelled or timed out from {0}", remoteAddress); - openTaskCompletionSource.TrySetException(ex); - break; - } - catch (Exception ex) - { - if (isFirstAttempt) - { - Logger.ErrorException("Error opening live stream:", ex); - openTaskCompletionSource.TrySetException(ex); - break; - } - - Logger.ErrorException("Error copying live stream, will reopen", ex); - } - - isFirstAttempt = false; + await hdHomerunManager.StopStreaming().ConfigureAwait(false); } + catch + { - await hdHomerunManager.StopStreaming().ConfigureAwait(false); - _liveStreamTaskCompletionSource.TrySetResult(true); + } } } @@ -157,36 +152,45 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun private void Resolve(TaskCompletionSource openTaskCompletionSource) { Task.Run(() => - { - openTaskCompletionSource.TrySetResult(true); - }); + { + openTaskCompletionSource.TrySetResult(true); + }); } private static int RtpHeaderBytes = 12; - private void CopyTo(ISocket udpClient, Stream target, TaskCompletionSource openTaskCompletionSource, CancellationToken cancellationToken) + private async Task CopyTo(ISocket udpClient, string file, TaskCompletionSource openTaskCompletionSource, CancellationToken cancellationToken) { - var source = _socketFactory.CreateNetworkStream(udpClient, false); var bufferSize = 81920; byte[] buffer = new byte[bufferSize]; int read; var resolved = false; - while ((read = source.Read(buffer, 0, buffer.Length)) != 0) + using (var source = _socketFactory.CreateNetworkStream(udpClient, false)) { - cancellationToken.ThrowIfCancellationRequested(); + using (var fileStream = FileSystem.GetFileStream(file, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None)) + { + var currentCancellationToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, new CancellationTokenSource(TimeSpan.FromSeconds(30)).Token).Token; - read -= RtpHeaderBytes; + while ((read = await source.ReadAsync(buffer, 0, buffer.Length, currentCancellationToken).ConfigureAwait(false)) != 0) + { + cancellationToken.ThrowIfCancellationRequested(); - if (read > 0) - { - target.Write(buffer, RtpHeaderBytes, read); - } + currentCancellationToken = cancellationToken; - if (!resolved) - { - resolved = true; - Resolve(openTaskCompletionSource); + read -= RtpHeaderBytes; + + if (read > 0) + { + fileStream.Write(buffer, RtpHeaderBytes, read); + } + + if (!resolved) + { + resolved = true; + Resolve(openTaskCompletionSource); + } + } } } } diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs index 685f794fd..12695cd8e 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/LiveStream.cs @@ -47,19 +47,13 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts TempFilePath = Path.Combine(appPaths.TranscodingTempPath, UniqueId + ".ts"); } - public Task Open(CancellationToken cancellationToken) - { - return OpenInternal(cancellationToken); - } - - protected virtual Task OpenInternal(CancellationToken cancellationToken) + public virtual Task Open(CancellationToken openCancellationToken) { return Task.FromResult(true); } - public virtual Task Close() + public virtual void Close() { - return Task.FromResult(true); } protected Stream GetInputStream(string path, bool allowAsyncFileRead) @@ -76,6 +70,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts protected async Task DeleteTempFile(string path, int retryCount = 0) { + if (retryCount == 0) + { + Logger.Info("Deleting temp file {0}", path); + } + try { FileSystem.DeleteFile(path); diff --git a/MediaBrowser.Controller/LiveTv/ITunerHost.cs b/MediaBrowser.Controller/LiveTv/ITunerHost.cs index 2019259c5..523eec24a 100644 --- a/MediaBrowser.Controller/LiveTv/ITunerHost.cs +++ b/MediaBrowser.Controller/LiveTv/ITunerHost.cs @@ -59,8 +59,8 @@ namespace MediaBrowser.Controller.LiveTv public interface ILiveStream { - Task Open(CancellationToken cancellationToken); - Task Close(); + Task Open(CancellationToken openCancellationToken); + void Close(); int ConsumerCount { get; } string OriginalStreamId { get; set; } bool EnableStreamSharing { get; set; } diff --git a/SharedVersion.cs b/SharedVersion.cs index 67b6004ad..7e6965cbc 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.33.19")] +[assembly: AssemblyVersion("3.2.33.20")] -- cgit v1.2.3