update legacy stream
This commit is contained in:
parent
0a64609fb8
commit
b9c12ca4a7
|
@ -234,7 +234,7 @@ namespace Emby.Common.Implementations.Networking
|
|||
// Try to exclude virtual adapters
|
||||
// http://stackoverflow.com/questions/8089685/c-sharp-finding-my-machines-local-ip-address-and-not-the-vms
|
||||
var addr = ipProperties.GatewayAddresses.FirstOrDefault();
|
||||
if (addr == null|| string.Equals(addr.Address.ToString(), "0.0.0.0", StringComparison.OrdinalIgnoreCase))
|
||||
if (addr == null || string.Equals(addr.Address.ToString(), "0.0.0.0", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return new List<IPAddress>();
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ namespace Emby.Common.Implementations.Networking
|
|||
/// Gets a random port number that is currently available
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
public int GetRandomUnusedPort()
|
||||
public int GetRandomUnusedTcpPort()
|
||||
{
|
||||
var listener = new TcpListener(IPAddress.Any, 0);
|
||||
listener.Start();
|
||||
|
@ -284,6 +284,16 @@ namespace Emby.Common.Implementations.Networking
|
|||
return port;
|
||||
}
|
||||
|
||||
public int GetRandomUnusedUdpPort()
|
||||
{
|
||||
IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, 0);
|
||||
using (var udpClient = new UdpClient(localEndPoint))
|
||||
{
|
||||
var port = ((IPEndPoint)(udpClient.Client.LocalEndPoint)).Port;
|
||||
return port;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns MAC Address from first Network Card in Computer
|
||||
/// </summary>
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||
AudioCodec = i.AudioCodec,
|
||||
VideoCodec = i.VideoCodec,
|
||||
ChannelType = ChannelType.TV,
|
||||
IsLegacyTuner = (info.Url ?? string.Empty).StartsWith("hdhomerun", StringComparison.OrdinalIgnoreCase)
|
||||
IsLegacyTuner = (i.URL ?? string.Empty).StartsWith("hdhomerun", StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
}).Cast<ChannelInfo>().ToList();
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||
|
||||
var tuners = new List<LiveTvTunerInfo>();
|
||||
|
||||
var uri = new Uri(info.Url);
|
||||
var uri = new Uri(GetApiUrl(info, false));
|
||||
|
||||
using (var manager = new HdHomerunManager(_socketFactory))
|
||||
{
|
||||
|
|
|
@ -31,8 +31,9 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||
private readonly MulticastStream _multicastStream;
|
||||
private readonly string _channelUrl;
|
||||
private readonly int _numTuners;
|
||||
private readonly INetworkManager _networkManager;
|
||||
|
||||
public LegacyHdHomerunLiveStream(MediaSourceInfo mediaSource, string originalStreamId, string channelUrl, int numTuners, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost, ISocketFactory socketFactory)
|
||||
public LegacyHdHomerunLiveStream(MediaSourceInfo mediaSource, string originalStreamId, string channelUrl, int numTuners, IFileSystem fileSystem, IHttpClient httpClient, ILogger logger, IServerApplicationPaths appPaths, IServerApplicationHost appHost, ISocketFactory socketFactory, INetworkManager networkManager)
|
||||
: base(mediaSource)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
|
@ -41,6 +42,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||
_appPaths = appPaths;
|
||||
_appHost = appHost;
|
||||
_socketFactory = socketFactory;
|
||||
_networkManager = networkManager;
|
||||
OriginalStreamId = originalStreamId;
|
||||
_multicastStream = new MulticastStream(_logger);
|
||||
_channelUrl = channelUrl;
|
||||
|
@ -53,15 +55,14 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
|
|||
|
||||
var mediaSource = OriginalMediaSource;
|
||||
|
||||
var splitString = mediaSource.Path.Split('_');
|
||||
var remoteIp = splitString[0];
|
||||
var localPort = Convert.ToInt32(splitString[1]);
|
||||
var uri = new Uri(mediaSource.Path);
|
||||
var localPort = _networkManager.GetRandomUnusedUdpPort();
|
||||
|
||||
_logger.Info("Opening Legacy HDHR Live stream from {0}", remoteIp);
|
||||
_logger.Info("Opening Legacy HDHR Live stream from {0}", uri.Host);
|
||||
|
||||
var taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
StartStreaming(remoteIp, localPort, taskCompletionSource, _liveStreamCancellationTokenSource.Token);
|
||||
StartStreaming(uri.Host, localPort, taskCompletionSource, _liveStreamCancellationTokenSource.Token);
|
||||
|
||||
//OpenedMediaSource.Protocol = MediaProtocol.File;
|
||||
//OpenedMediaSource.Path = tempFile;
|
||||
|
|
|
@ -12,7 +12,9 @@ namespace MediaBrowser.Common.Net
|
|||
/// Gets a random port number that is currently available
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
int GetRandomUnusedPort();
|
||||
int GetRandomUnusedTcpPort();
|
||||
|
||||
int GetRandomUnusedUdpPort();
|
||||
|
||||
/// <summary>
|
||||
/// Returns MAC Address from first Network Card in Computer
|
||||
|
|
Loading…
Reference in New Issue
Block a user