From a0934e62261f0fc8788efb13c653973c16d02d3e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 13 Mar 2017 16:42:21 -0400 Subject: [PATCH] continue with tuner discovery --- .../LiveTv/EmbyTV/EmbyTV.cs | 14 ++++++++++++++ .../LiveTv/LiveTvManager.cs | 5 +++++ .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 1 + MediaBrowser.Api/LiveTv/LiveTvService.cs | 15 ++++++++++++++- MediaBrowser.Controller/Entities/Video.cs | 3 ++- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 1 + .../MediaEncoding/EncodingHelper.cs | 6 ++++++ 7 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index a7ccafd693..42e8c4f5fa 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -2543,6 +2543,20 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public CancellationTokenSource CancellationTokenSource { get; set; } } + public async Task> DiscoverTuners(CancellationToken cancellationToken) + { + var list = new List(); + + foreach (var host in _liveTvManager.TunerHosts) + { + var discoveredDevices = await DiscoverDevices(host, 3000, cancellationToken).ConfigureAwait(false); + + list.AddRange(discoveredDevices); + } + + return list; + } + public async Task ScanForTunerDeviceChanges(CancellationToken cancellationToken) { foreach (var host in _liveTvManager.TunerHosts) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index de39d3838e..92ef24deab 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -160,6 +160,11 @@ namespace Emby.Server.Implementations.LiveTv }).ToList(); } + public Task> DiscoverTuners(CancellationToken cancellationToken) + { + return EmbyTV.EmbyTV.Current.DiscoverTuners(cancellationToken); + } + void service_DataSourceChanged(object sender, EventArgs e) { if (!_isDisposed) diff --git a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index dbcabd1742..6d67308557 100644 --- a/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -706,6 +706,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun var modelInfo = await GetModelInfo(hostInfo, false, cancellationToken).ConfigureAwait(false); hostInfo.DeviceId = modelInfo.DeviceID; + hostInfo.FriendlyName = modelInfo.FriendlyName; return hostInfo; } diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 639021762a..2f7d049361 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -677,7 +677,14 @@ namespace MediaBrowser.Api.LiveTv [Authenticated] public class GetTunerHostTypes : IReturn> { - + + } + + [Route("/LiveTv/Tuners/Discvover", "GET")] + [Authenticated] + public class DiscoverTuners : IReturn> + { + } public class LiveTvService : BaseApiService @@ -730,6 +737,12 @@ namespace MediaBrowser.Api.LiveTv }; } + public async Task Get(DiscoverTuners request) + { + var result = await _liveTvManager.DiscoverTuners(CancellationToken.None).ConfigureAwait(false); + return ToOptimizedResult(result); + } + public async Task Get(GetLiveStreamFile request) { var directStreamProvider = (await _liveTvManager.GetEmbyTvLiveStream(request.Id).ConfigureAwait(false)) as IDirectStreamProvider; diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 78f907d61a..8906264191 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -614,7 +614,8 @@ namespace MediaBrowser.Controller.Entities Timestamp = i.Timestamp, Type = type, PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(), - SupportsDirectStream = i.VideoType == VideoType.VideoFile + SupportsDirectStream = i.VideoType == VideoType.VideoFile, + IsRemote = i.IsShortcut }; if (info.Protocol == MediaProtocol.File) diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index b3467fbbce..0dda303a3e 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -382,6 +382,7 @@ namespace MediaBrowser.Controller.LiveTv List ListingProviders { get; } List GetTunerHostTypes(); + Task> DiscoverTuners(CancellationToken cancellationToken); event EventHandler> SeriesTimerCancelled; event EventHandler> TimerCancelled; diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index ebcc9853ae..6482b68290 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -185,6 +185,12 @@ namespace MediaBrowser.Controller.MediaEncoding return null; } + // obviously don't do this for strm files + if (string.Equals(container, "strm", StringComparison.OrdinalIgnoreCase)) + { + return null; + } + return container; }