The Free Software Media System - Server Backend & API
Make localhost LiveTV restreams always use plain HTTP port
Vasilye85f9f5613c0
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex cb32b8c01b..9af89112c5 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -1419,7 +1419,7 @@ namespace Emby.Server.Implementationspublic bool SupportsHttps => Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy;- public async Task<string> GetLocalApiUrl(CancellationToken cancellationToken)+ public async Task<string> GetLocalApiUrl(CancellationToken cancellationToken, bool forceHttp=false){try{@@ -1428,7 +1428,7 @@ namespace Emby.Server.Implementationsforeach (var address in addresses){- return GetLocalApiUrl(address);+ return GetLocalApiUrl(address, forceHttp);}return null;@@ -1458,7 +1458,7 @@ namespace Emby.Server.Implementations}/// <inheritdoc />- public string GetLocalApiUrl(IPAddress ipAddress)+ public string GetLocalApiUrl(IPAddress ipAddress, bool forceHttp=false){if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6){@@ -1468,20 +1468,21 @@ namespace Emby.Server.Implementationsstr.CopyTo(span.Slice(1));span[^1] = ']';- return GetLocalApiUrl(span);+ return GetLocalApiUrl(span, forceHttp);}- return GetLocalApiUrl(ipAddress.ToString());+ return GetLocalApiUrl(ipAddress.ToString(), forceHttp);}/// <inheritdoc />- public string GetLocalApiUrl(ReadOnlySpan<char> host)+ public string GetLocalApiUrl(ReadOnlySpan<char> host, bool forceHttp=false){var url = new StringBuilder(64);- url.Append(EnableHttps ? "https://" : "http://")+ bool useHttps = EnableHttps && !forceHttp;+ url.Append(useHttps ? "https://" : "http://").Append(host).Append(':')- .Append(EnableHttps ? HttpsPort : HttpPort);+ .Append(useHttps ? HttpsPort : HttpPort);string baseUrl = ServerConfigurationManager.Configuration.BaseUrl;if (baseUrl.Length != 0)diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.csindex 139aa19a4b..409917245f 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs@@ -1062,7 +1062,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV{var stream = new MediaSourceInfo{- EncoderPath = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveRecordings/" + info.Id + "/stream",+ EncoderPath = _appHost.GetLocalApiUrl("127.0.0.1", true) + "/LiveTv/LiveRecordings/" + info.Id + "/stream",EncoderProtocol = MediaProtocol.Http,Path = info.Path,Protocol = MediaProtocol.File,diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.csindex 03ee5bfb65..d89a816b3b 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunUdpStream.cs@@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun//OpenedMediaSource.Path = tempFile;//OpenedMediaSource.ReadAtNativeFramerate = true;- MediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";+ MediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1", true) + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";MediaSource.Protocol = MediaProtocol.Http;//OpenedMediaSource.SupportsDirectPlay = false;//OpenedMediaSource.SupportsDirectStream = true;diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.csindex d63588bbd1..0e600202aa 100644--- a/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs+++ b/Emby.Server.Implementations/LiveTv/TunerHosts/SharedHttpStream.cs@@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts//OpenedMediaSource.Path = tempFile;//OpenedMediaSource.ReadAtNativeFramerate = true;- MediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1") + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";+ MediaSource.Path = _appHost.GetLocalApiUrl("127.0.0.1", true) + "/LiveTv/LiveStreamFiles/" + UniqueId + "/stream.ts";MediaSource.Protocol = MediaProtocol.Http;//OpenedMediaSource.Path = TempFilePath;diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.csindex 608ffc61c2..09f6cb0431 100644--- a/MediaBrowser.Controller/IServerApplicationHost.cs+++ b/MediaBrowser.Controller/IServerApplicationHost.cs@@ -65,22 +65,26 @@ namespace MediaBrowser.Controller/// <summary>/// Gets the local API URL./// </summary>+ /// <param name="cancellationToken">Token to cancel the request if needed.</param>+ /// <param name="forceHttp">Whether to force usage of plain HTTP protocol.</param>/// <value>The local API URL.</value>- Task<string> GetLocalApiUrl(CancellationToken cancellationToken);+ Task<string> GetLocalApiUrl(CancellationToken cancellationToken, bool forceHttp=false);/// <summary>/// Gets the local API URL./// </summary>/// <param name="hostname">The hostname.</param>+ /// <param name="forceHttp">Whether to force usage of plain HTTP protocol.</param>/// <returns>The local API URL.</returns>- string GetLocalApiUrl(ReadOnlySpan<char> hostname);+ string GetLocalApiUrl(ReadOnlySpan<char> hostname, bool forceHttp=false);/// <summary>/// Gets the local API URL./// </summary>/// <param name="address">The IP address.</param>+ /// <param name="forceHttp">Whether to force usage of plain HTTP protocol.</param>/// <returns>The local API URL.</returns>- string GetLocalApiUrl(IPAddress address);+ string GetLocalApiUrl(IPAddress address, bool forceHttp=false);/// <summary>/// Open a URL in an external browser window.