aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-26 11:48:14 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-26 11:48:14 -0400
commit98442402a5f8f8f37de5dcac07a1d08666623d74 (patch)
treeb14438250db46b158a342b288dee97112a3ae5d6
parent0a313b508790b0051d65c7e1c2e5aa549d9d0a24 (diff)
fixes #550 - Add internal interfaces for live tv
-rw-r--r--MediaBrowser.Api/LiveTv/LiveTvService.cs74
-rw-r--r--MediaBrowser.Api/MediaBrowser.Api.csproj1
-rw-r--r--MediaBrowser.Controller/LiveTv/ChannelInfo.cs21
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvManager.cs30
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvService.cs25
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj3
-rw-r--r--MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj6
-rw-r--r--MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj6
-rw-r--r--MediaBrowser.Model/LiveTv/ChannelInfoDto.cs21
-rw-r--r--MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs15
-rw-r--r--MediaBrowser.Model/MediaBrowser.Model.csproj2
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs45
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj1
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs7
14 files changed, 257 insertions, 0 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
new file mode 100644
index 0000000000..a7a709aee5
--- /dev/null
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -0,0 +1,74 @@
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.LiveTv;
+using ServiceStack.ServiceHost;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Api.LiveTv
+{
+ [Route("/LiveTv/Services", "GET")]
+ [Api(Description = "Gets available live tv services.")]
+ public class GetServices : IReturn<List<LiveTvServiceInfo>>
+ {
+ }
+
+ [Route("/LiveTv/Channels", "GET")]
+ [Api(Description = "Gets available live tv channels.")]
+ public class GetChannels : IReturn<List<ChannelInfoDto>>
+ {
+ // Add filter by service if needed, and/or other filters
+ }
+
+ public class LiveTvService : BaseApiService
+ {
+ private readonly ILiveTvManager _liveTvManager;
+
+ public LiveTvService(ILiveTvManager liveTvManager)
+ {
+ _liveTvManager = liveTvManager;
+ }
+
+ public object Get(GetServices request)
+ {
+ var services = _liveTvManager.Services;
+
+ var result = services.Select(GetServiceInfo)
+ .ToList();
+
+ return ToOptimizedResult(result);
+ }
+
+ public object Get(GetChannels request)
+ {
+ var services = _liveTvManager.Services;
+
+ var result = services.Select(GetServiceInfo)
+ .ToList();
+
+ return ToOptimizedResult(result);
+ }
+
+ public async Task<IEnumerable<ChannelInfoDto>> GetChannelsAsync(GetChannels request)
+ {
+ var services = _liveTvManager.Services;
+
+ var channelTasks = services.Select(i => i.GetChannelsAsync(CancellationToken.None));
+
+ var channelLists = await Task.WhenAll(channelTasks).ConfigureAwait(false);
+
+ // Aggregate all channels from all services
+ return channelLists.SelectMany(i => i)
+ .Select(_liveTvManager.GetChannelInfoDto);
+ }
+
+ private LiveTvServiceInfo GetServiceInfo(ILiveTvService service)
+ {
+ return new LiveTvServiceInfo
+ {
+ Name = service.Name
+ };
+ }
+ }
+}
diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj
index 4f54b52498..21e73361c2 100644
--- a/MediaBrowser.Api/MediaBrowser.Api.csproj
+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj
@@ -81,6 +81,7 @@
<Compile Include="Library\LibraryHelpers.cs" />
<Compile Include="Library\LibraryService.cs" />
<Compile Include="Library\LibraryStructureService.cs" />
+ <Compile Include="LiveTv\LiveTvService.cs" />
<Compile Include="LocalizationService.cs" />
<Compile Include="MoviesService.cs" />
<Compile Include="NotificationsService.cs" />
diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs
new file mode 100644
index 0000000000..5f40134482
--- /dev/null
+++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs
@@ -0,0 +1,21 @@
+
+namespace MediaBrowser.Controller.LiveTv
+{
+ /// <summary>
+ /// Class ChannelInfo
+ /// </summary>
+ public class ChannelInfo
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of the service.
+ /// </summary>
+ /// <value>The name of the service.</value>
+ public string ServiceName { get; set; }
+ }
+}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
new file mode 100644
index 0000000000..de88d15620
--- /dev/null
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -0,0 +1,30 @@
+using MediaBrowser.Model.LiveTv;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+ /// <summary>
+ /// Manages all live tv services installed on the server
+ /// </summary>
+ public interface ILiveTvManager
+ {
+ /// <summary>
+ /// Gets the services.
+ /// </summary>
+ /// <value>The services.</value>
+ IReadOnlyList<ILiveTvService> Services { get; }
+
+ /// <summary>
+ /// Adds the parts.
+ /// </summary>
+ /// <param name="services">The services.</param>
+ void AddParts(IEnumerable<ILiveTvService> services);
+
+ /// <summary>
+ /// Gets the channel info dto.
+ /// </summary>
+ /// <param name="info">The info.</param>
+ /// <returns>ChannelInfoDto.</returns>
+ ChannelInfoDto GetChannelInfoDto(ChannelInfo info);
+ }
+}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
new file mode 100644
index 0000000000..4d9ec85311
--- /dev/null
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+ /// <summary>
+ /// Represents a single live tv back end (next pvr, media portal, etc).
+ /// </summary>
+ public interface ILiveTvService
+ {
+ /// <summary>
+ /// Gets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ string Name { get; }
+
+ /// <summary>
+ /// Gets the channels async.
+ /// </summary>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task{IEnumerable{ChannelInfo}}.</returns>
+ Task<IEnumerable<ChannelInfo>> GetChannelsAsync(CancellationToken cancellationToken);
+ }
+}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 0b27a350bd..57219ae513 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -96,6 +96,9 @@
<Compile Include="Library\ILibraryPrescanTask.cs" />
<Compile Include="Library\IMetadataSaver.cs" />
<Compile Include="Library\ItemUpdateType.cs" />
+ <Compile Include="LiveTv\ChannelInfo.cs" />
+ <Compile Include="LiveTv\ILiveTvManager.cs" />
+ <Compile Include="LiveTv\ILiveTvService.cs" />
<Compile Include="Localization\ILocalizationManager.cs" />
<Compile Include="Notifications\INotificationsRepository.cs" />
<Compile Include="Notifications\NotificationUpdateEventArgs.cs" />
diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj
index e0ff0fbc63..56e9c3f8e3 100644
--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj
+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj
@@ -215,6 +215,12 @@
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
<Link>IO\IZipClient.cs</Link>
</Compile>
+ <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
+ <Link>LiveTv\ChannelInfoDto.cs</Link>
+ </Compile>
+ <Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
+ <Link>LiveTv\LiveTvServiceInfo.cs</Link>
+ </Compile>
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
<Link>Logging\ILogger.cs</Link>
</Compile>
diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj
index 59b3af342c..92abac5cff 100644
--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj
+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj
@@ -199,6 +199,12 @@
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
<Link>IO\IZipClient.cs</Link>
</Compile>
+ <Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
+ <Link>LiveTv\ChannelInfoDto.cs</Link>
+ </Compile>
+ <Compile Include="..\MediaBrowser.Model\LiveTv\LiveTvServiceInfo.cs">
+ <Link>LiveTv\LiveTvServiceInfo.cs</Link>
+ </Compile>
<Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs">
<Link>Logging\ILogger.cs</Link>
</Compile>
diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
new file mode 100644
index 0000000000..5150897c3d
--- /dev/null
+++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
@@ -0,0 +1,21 @@
+
+namespace MediaBrowser.Model.LiveTv
+{
+ /// <summary>
+ /// Class ChannelInfoDto
+ /// </summary>
+ public class ChannelInfoDto
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the name of the service.
+ /// </summary>
+ /// <value>The name of the service.</value>
+ public string ServiceName { get; set; }
+ }
+}
diff --git a/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs
new file mode 100644
index 0000000000..87647738f3
--- /dev/null
+++ b/MediaBrowser.Model/LiveTv/LiveTvServiceInfo.cs
@@ -0,0 +1,15 @@
+
+namespace MediaBrowser.Model.LiveTv
+{
+ /// <summary>
+ /// Class ServiceInfo
+ /// </summary>
+ public class LiveTvServiceInfo
+ {
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ public string Name { get; set; }
+ }
+}
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index fa4fc29862..b317dbf0ee 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -66,6 +66,8 @@
<Compile Include="IO\IIsoManager.cs" />
<Compile Include="IO\IIsoMount.cs" />
<Compile Include="IO\IIsoMounter.cs" />
+ <Compile Include="LiveTv\ChannelInfoDto.cs" />
+ <Compile Include="LiveTv\LiveTvServiceInfo.cs" />
<Compile Include="Net\WebSocketMessage.cs" />
<Compile Include="Net\WebSocketMessageType.cs" />
<Compile Include="Net\WebSocketState.cs" />
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
new file mode 100644
index 0000000000..87b02816f7
--- /dev/null
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -0,0 +1,45 @@
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Model.LiveTv;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Server.Implementations.LiveTv
+{
+ /// <summary>
+ /// Class LiveTvManager
+ /// </summary>
+ public class LiveTvManager : ILiveTvManager
+ {
+ private readonly List<ILiveTvService> _services = new List<ILiveTvService>();
+ /// <summary>
+ /// Gets the services.
+ /// </summary>
+ /// <value>The services.</value>
+ public IReadOnlyList<ILiveTvService> Services
+ {
+ get { return _services; }
+ }
+
+ /// <summary>
+ /// Adds the parts.
+ /// </summary>
+ /// <param name="services">The services.</param>
+ public void AddParts(IEnumerable<ILiveTvService> services)
+ {
+ _services.AddRange(services);
+ }
+
+ /// <summary>
+ /// Gets the channel info dto.
+ /// </summary>
+ /// <param name="info">The info.</param>
+ /// <returns>ChannelInfoDto.</returns>
+ public ChannelInfoDto GetChannelInfoDto(ChannelInfo info)
+ {
+ return new ChannelInfoDto
+ {
+ Name = info.Name,
+ ServiceName = info.ServiceName
+ };
+ }
+ }
+}
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 86e250fe42..27dc44ee5d 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -148,6 +148,7 @@
<Compile Include="Library\Validators\PeoplePostScanTask.cs" />
<Compile Include="Library\Validators\StudiosPostScanTask.cs" />
<Compile Include="Library\Validators\StudiosValidator.cs" />
+ <Compile Include="LiveTv\LiveTvManager.cs" />
<Compile Include="Localization\LocalizationManager.cs" />
<Compile Include="MediaEncoder\MediaEncoder.cs" />
<Compile Include="Persistence\SqliteChapterRepository.cs" />
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index d0f7da73de..f921f1c11a 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -15,6 +15,7 @@ using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.MediaInfo;
using MediaBrowser.Controller.Notifications;
@@ -39,6 +40,7 @@ using MediaBrowser.Server.Implementations.EntryPoints;
using MediaBrowser.Server.Implementations.HttpServer;
using MediaBrowser.Server.Implementations.IO;
using MediaBrowser.Server.Implementations.Library;
+using MediaBrowser.Server.Implementations.LiveTv;
using MediaBrowser.Server.Implementations.Localization;
using MediaBrowser.Server.Implementations.MediaEncoder;
using MediaBrowser.Server.Implementations.Persistence;
@@ -154,6 +156,8 @@ namespace MediaBrowser.ServerApplication
private IIsoManager IsoManager { get; set; }
private ISessionManager SessionManager { get; set; }
+ private ILiveTvManager LiveTvManager { get; set; }
+
private ILocalizationManager LocalizationManager { get; set; }
/// <summary>
@@ -285,6 +289,9 @@ namespace MediaBrowser.ServerApplication
DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataRepository, ItemRepository, ImageProcessor);
RegisterSingleInstance(DtoService);
+ LiveTvManager = new LiveTvManager();
+ RegisterSingleInstance(LiveTvManager);
+
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));