Merge pull request #2798 from JustAMan/fix-livetv-again

Make localhost LiveTV restreams always use plain HTTP port
pull/2991/head
Joshua M. Boniface 5 years ago committed by GitHub
commit f502c89331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1185,7 +1185,7 @@ namespace Emby.Server.Implementations
public bool SupportsHttps => Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy; public 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 try
{ {
@ -1194,7 +1194,7 @@ namespace Emby.Server.Implementations
foreach (var address in addresses) foreach (var address in addresses)
{ {
return GetLocalApiUrl(address); return GetLocalApiUrl(address, forceHttp);
} }
return null; return null;
@ -1224,7 +1224,7 @@ namespace Emby.Server.Implementations
} }
/// <inheritdoc /> /// <inheritdoc />
public string GetLocalApiUrl(IPAddress ipAddress) public string GetLocalApiUrl(IPAddress ipAddress, bool forceHttp = false)
{ {
if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6) if (ipAddress.AddressFamily == AddressFamily.InterNetworkV6)
{ {
@ -1234,20 +1234,21 @@ namespace Emby.Server.Implementations
str.CopyTo(span.Slice(1)); str.CopyTo(span.Slice(1));
span[^1] = ']'; span[^1] = ']';
return GetLocalApiUrl(span); return GetLocalApiUrl(span, forceHttp);
} }
return GetLocalApiUrl(ipAddress.ToString()); return GetLocalApiUrl(ipAddress.ToString(), forceHttp);
} }
/// <inheritdoc /> /// <inheritdoc />
public string GetLocalApiUrl(ReadOnlySpan<char> host) public string GetLocalApiUrl(ReadOnlySpan<char> host, bool forceHttp = false)
{ {
var url = new StringBuilder(64); var url = new StringBuilder(64);
url.Append(EnableHttps ? "https://" : "http://") bool useHttps = EnableHttps && !forceHttp;
url.Append(useHttps ? "https://" : "http://")
.Append(host) .Append(host)
.Append(':') .Append(':')
.Append(EnableHttps ? HttpsPort : HttpPort); .Append(useHttps ? HttpsPort : HttpPort);
string baseUrl = ServerConfigurationManager.Configuration.BaseUrl; string baseUrl = ServerConfigurationManager.Configuration.BaseUrl;
if (baseUrl.Length != 0) if (baseUrl.Length != 0)

@ -1059,7 +1059,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
var stream = new MediaSourceInfo 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, EncoderProtocol = MediaProtocol.Http,
Path = info.Path, Path = info.Path,
Protocol = MediaProtocol.File, Protocol = MediaProtocol.File,

@ -121,7 +121,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
//OpenedMediaSource.Path = tempFile; //OpenedMediaSource.Path = tempFile;
//OpenedMediaSource.ReadAtNativeFramerate = true; //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; MediaSource.Protocol = MediaProtocol.Http;
//OpenedMediaSource.SupportsDirectPlay = false; //OpenedMediaSource.SupportsDirectPlay = false;
//OpenedMediaSource.SupportsDirectStream = true; //OpenedMediaSource.SupportsDirectStream = true;

@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
//OpenedMediaSource.Path = tempFile; //OpenedMediaSource.Path = tempFile;
//OpenedMediaSource.ReadAtNativeFramerate = true; //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; MediaSource.Protocol = MediaProtocol.Http;
//OpenedMediaSource.Path = TempFilePath; //OpenedMediaSource.Path = TempFilePath;

@ -265,9 +265,15 @@ namespace Jellyfin.Server
.LocalNetworkAddresses .LocalNetworkAddresses
.Select(appHost.NormalizeConfiguredLocalAddress) .Select(appHost.NormalizeConfiguredLocalAddress)
.Where(i => i != null) .Where(i => i != null)
.ToList(); .ToHashSet();
if (addresses.Any()) if (addresses.Any() && !addresses.Contains(IPAddress.Any))
{ {
if (!addresses.Contains(IPAddress.Loopback))
{
// we must listen on loopback for LiveTV to function regardless of the settings
addresses.Add(IPAddress.Loopback);
}
foreach (var address in addresses) foreach (var address in addresses)
{ {
_logger.LogInformation("Kestrel listening on {IpAddress}", address); _logger.LogInformation("Kestrel listening on {IpAddress}", address);

@ -65,22 +65,26 @@ namespace MediaBrowser.Controller
/// <summary> /// <summary>
/// Gets the local API URL. /// Gets the local API URL.
/// </summary> /// </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> /// <value>The local API URL.</value>
Task<string> GetLocalApiUrl(CancellationToken cancellationToken); Task<string> GetLocalApiUrl(CancellationToken cancellationToken, bool forceHttp = false);
/// <summary> /// <summary>
/// Gets the local API URL. /// Gets the local API URL.
/// </summary> /// </summary>
/// <param name="hostname">The hostname.</param> /// <param name="hostname">The hostname.</param>
/// <param name="forceHttp">Whether to force usage of plain HTTP protocol.</param>
/// <returns>The local API URL.</returns> /// <returns>The local API URL.</returns>
string GetLocalApiUrl(ReadOnlySpan<char> hostname); string GetLocalApiUrl(ReadOnlySpan<char> hostname, bool forceHttp = false);
/// <summary> /// <summary>
/// Gets the local API URL. /// Gets the local API URL.
/// </summary> /// </summary>
/// <param name="address">The IP address.</param> /// <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> /// <returns>The local API URL.</returns>
string GetLocalApiUrl(IPAddress address); string GetLocalApiUrl(IPAddress address, bool forceHttp = false);
/// <summary> /// <summary>
/// Open a URL in an external browser window. /// Open a URL in an external browser window.

Loading…
Cancel
Save