ILiveTvManager.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. using System;
  2. using MediaBrowser.Controller.Dto;
  3. using MediaBrowser.Controller.Entities;
  4. using MediaBrowser.Model.Dto;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.LiveTv;
  7. using MediaBrowser.Model.Querying;
  8. using System.Collections.Generic;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. using MediaBrowser.Model.Events;
  12. using MediaBrowser.Controller.Library;
  13. namespace MediaBrowser.Controller.LiveTv
  14. {
  15. /// <summary>
  16. /// Manages all live tv services installed on the server
  17. /// </summary>
  18. public interface ILiveTvManager
  19. {
  20. /// <summary>
  21. /// Gets the services.
  22. /// </summary>
  23. /// <value>The services.</value>
  24. IReadOnlyList<ILiveTvService> Services { get; }
  25. /// <summary>
  26. /// Gets the new timer defaults asynchronous.
  27. /// </summary>
  28. /// <param name="cancellationToken">The cancellation token.</param>
  29. /// <returns>Task{TimerInfo}.</returns>
  30. Task<SeriesTimerInfoDto> GetNewTimerDefaults(CancellationToken cancellationToken);
  31. /// <summary>
  32. /// Gets the new timer defaults.
  33. /// </summary>
  34. /// <param name="programId">The program identifier.</param>
  35. /// <param name="cancellationToken">The cancellation token.</param>
  36. /// <returns>Task{SeriesTimerInfoDto}.</returns>
  37. Task<SeriesTimerInfoDto> GetNewTimerDefaults(string programId, CancellationToken cancellationToken);
  38. /// <summary>
  39. /// Cancels the timer.
  40. /// </summary>
  41. /// <param name="id">The identifier.</param>
  42. /// <returns>Task.</returns>
  43. Task CancelTimer(string id);
  44. /// <summary>
  45. /// Cancels the series timer.
  46. /// </summary>
  47. /// <param name="id">The identifier.</param>
  48. /// <returns>Task.</returns>
  49. Task CancelSeriesTimer(string id);
  50. /// <summary>
  51. /// Adds the parts.
  52. /// </summary>
  53. /// <param name="services">The services.</param>
  54. /// <param name="tunerHosts">The tuner hosts.</param>
  55. /// <param name="listingProviders">The listing providers.</param>
  56. void AddParts(IEnumerable<ILiveTvService> services, IEnumerable<ITunerHost> tunerHosts, IEnumerable<IListingsProvider> listingProviders);
  57. /// <summary>
  58. /// Gets the timer.
  59. /// </summary>
  60. /// <param name="id">The identifier.</param>
  61. /// <param name="cancellationToken">The cancellation token.</param>
  62. /// <returns>Task{TimerInfoDto}.</returns>
  63. Task<TimerInfoDto> GetTimer(string id, CancellationToken cancellationToken);
  64. /// <summary>
  65. /// Gets the series timer.
  66. /// </summary>
  67. /// <param name="id">The identifier.</param>
  68. /// <param name="cancellationToken">The cancellation token.</param>
  69. /// <returns>Task{TimerInfoDto}.</returns>
  70. Task<SeriesTimerInfoDto> GetSeriesTimer(string id, CancellationToken cancellationToken);
  71. /// <summary>
  72. /// Gets the recordings.
  73. /// </summary>
  74. /// <param name="query">The query.</param>
  75. /// <param name="options">The options.</param>
  76. QueryResult<BaseItemDto> GetRecordings(RecordingQuery query, DtoOptions options);
  77. /// <summary>
  78. /// Gets the timers.
  79. /// </summary>
  80. /// <param name="query">The query.</param>
  81. /// <param name="cancellationToken">The cancellation token.</param>
  82. /// <returns>Task{QueryResult{TimerInfoDto}}.</returns>
  83. Task<QueryResult<TimerInfoDto>> GetTimers(TimerQuery query, CancellationToken cancellationToken);
  84. /// <summary>
  85. /// Gets the series timers.
  86. /// </summary>
  87. /// <param name="query">The query.</param>
  88. /// <param name="cancellationToken">The cancellation token.</param>
  89. /// <returns>Task{QueryResult{SeriesTimerInfoDto}}.</returns>
  90. Task<QueryResult<SeriesTimerInfoDto>> GetSeriesTimers(SeriesTimerQuery query, CancellationToken cancellationToken);
  91. /// <summary>
  92. /// Gets the channel stream.
  93. /// </summary>
  94. /// <param name="id">The identifier.</param>
  95. /// <param name="mediaSourceId">The media source identifier.</param>
  96. /// <param name="cancellationToken">The cancellation token.</param>
  97. /// <returns>Task{StreamResponseInfo}.</returns>
  98. Task<Tuple<MediaSourceInfo, ILiveStream>> GetChannelStream(string id, string mediaSourceId, List<ILiveStream> currentLiveStreams, CancellationToken cancellationToken);
  99. /// <summary>
  100. /// Gets the program.
  101. /// </summary>
  102. /// <param name="id">The identifier.</param>
  103. /// <param name="cancellationToken">The cancellation token.</param>
  104. /// <param name="user">The user.</param>
  105. /// <returns>Task{ProgramInfoDto}.</returns>
  106. Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null);
  107. /// <summary>
  108. /// Gets the programs.
  109. /// </summary>
  110. /// <param name="query">The query.</param>
  111. /// <param name="options">The options.</param>
  112. /// <param name="cancellationToken">The cancellation token.</param>
  113. /// <returns>IEnumerable{ProgramInfo}.</returns>
  114. Task<QueryResult<BaseItemDto>> GetPrograms(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken);
  115. /// <summary>
  116. /// Updates the timer.
  117. /// </summary>
  118. /// <param name="timer">The timer.</param>
  119. /// <param name="cancellationToken">The cancellation token.</param>
  120. /// <returns>Task.</returns>
  121. Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken);
  122. /// <summary>
  123. /// Updates the timer.
  124. /// </summary>
  125. /// <param name="timer">The timer.</param>
  126. /// <param name="cancellationToken">The cancellation token.</param>
  127. /// <returns>Task.</returns>
  128. Task UpdateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken);
  129. /// <summary>
  130. /// Creates the timer.
  131. /// </summary>
  132. /// <param name="timer">The timer.</param>
  133. /// <param name="cancellationToken">The cancellation token.</param>
  134. /// <returns>Task.</returns>
  135. Task CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken);
  136. /// <summary>
  137. /// Creates the series timer.
  138. /// </summary>
  139. /// <param name="timer">The timer.</param>
  140. /// <param name="cancellationToken">The cancellation token.</param>
  141. /// <returns>Task.</returns>
  142. Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken);
  143. /// <summary>
  144. /// Gets the guide information.
  145. /// </summary>
  146. /// <returns>GuideInfo.</returns>
  147. GuideInfo GetGuideInfo();
  148. /// <summary>
  149. /// Gets the recommended programs.
  150. /// </summary>
  151. /// <param name="query">The query.</param>
  152. /// <param name="options">The options.</param>
  153. /// <param name="cancellationToken">The cancellation token.</param>
  154. QueryResult<BaseItemDto> GetRecommendedPrograms(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken);
  155. /// <summary>
  156. /// Gets the recommended programs internal.
  157. /// </summary>
  158. QueryResult<BaseItem> GetRecommendedProgramsInternal(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken);
  159. /// <summary>
  160. /// Gets the live tv information.
  161. /// </summary>
  162. /// <param name="cancellationToken">The cancellation token.</param>
  163. /// <returns>Task{LiveTvInfo}.</returns>
  164. LiveTvInfo GetLiveTvInfo(CancellationToken cancellationToken);
  165. /// <summary>
  166. /// Resets the tuner.
  167. /// </summary>
  168. /// <param name="id">The identifier.</param>
  169. /// <param name="cancellationToken">The cancellation token.</param>
  170. /// <returns>Task.</returns>
  171. Task ResetTuner(string id, CancellationToken cancellationToken);
  172. /// <summary>
  173. /// Gets the live tv folder.
  174. /// </summary>
  175. /// <param name="cancellationToken">The cancellation token.</param>
  176. Folder GetInternalLiveTvFolder(CancellationToken cancellationToken);
  177. /// <summary>
  178. /// Gets the enabled users.
  179. /// </summary>
  180. /// <returns>IEnumerable{User}.</returns>
  181. IEnumerable<User> GetEnabledUsers();
  182. /// <summary>
  183. /// Gets the internal channels.
  184. /// </summary>
  185. QueryResult<BaseItem> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken);
  186. /// <summary>
  187. /// Gets the channel media sources.
  188. /// </summary>
  189. Task<IEnumerable<MediaSourceInfo>> GetChannelMediaSources(BaseItem item, CancellationToken cancellationToken);
  190. /// <summary>
  191. /// Adds the information to program dto.
  192. /// </summary>
  193. /// <param name="programs">The programs.</param>
  194. /// <param name="fields">The fields.</param>
  195. /// <param name="user">The user.</param>
  196. /// <returns>Task.</returns>
  197. Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> programs, ItemFields[] fields, User user = null);
  198. /// <summary>
  199. /// Saves the tuner host.
  200. /// </summary>
  201. Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
  202. /// <summary>
  203. /// Saves the listing provider.
  204. /// </summary>
  205. /// <param name="info">The information.</param>
  206. /// <param name="validateLogin">if set to <c>true</c> [validate login].</param>
  207. /// <param name="validateListings">if set to <c>true</c> [validate listings].</param>
  208. /// <returns>Task.</returns>
  209. Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings);
  210. void DeleteListingsProvider(string id);
  211. Task<TunerChannelMapping> SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber);
  212. TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, NameValuePair[] mappings, List<ChannelInfo> providerChannels);
  213. /// <summary>
  214. /// Gets the lineups.
  215. /// </summary>
  216. /// <param name="providerType">Type of the provider.</param>
  217. /// <param name="providerId">The provider identifier.</param>
  218. /// <param name="country">The country.</param>
  219. /// <param name="location">The location.</param>
  220. /// <returns>Task&lt;List&lt;NameIdPair&gt;&gt;.</returns>
  221. Task<List<NameIdPair>> GetLineups(string providerType, string providerId, string country, string location);
  222. /// <summary>
  223. /// Adds the channel information.
  224. /// </summary>
  225. /// <param name="items">The items.</param>
  226. /// <param name="options">The options.</param>
  227. /// <param name="user">The user.</param>
  228. void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> items, DtoOptions options, User user);
  229. Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken);
  230. Task<List<ChannelInfo>> GetChannelsFromListingsProviderData(string id, CancellationToken cancellationToken);
  231. IListingsProvider[] ListingProviders { get; }
  232. List<NameIdPair> GetTunerHostTypes();
  233. Task<List<TunerHostInfo>> DiscoverTuners(bool newDevicesOnly, CancellationToken cancellationToken);
  234. event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
  235. event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCancelled;
  236. event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
  237. event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;
  238. string GetEmbyTvActiveRecordingPath(string id);
  239. ActiveRecordingInfo GetActiveRecordingInfo(string path);
  240. void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null);
  241. List<BaseItem> GetRecordingFolders(User user);
  242. }
  243. public class ActiveRecordingInfo
  244. {
  245. public string Id { get; set; }
  246. public string Path { get; set; }
  247. public TimerInfo Timer { get; set; }
  248. public CancellationTokenSource CancellationTokenSource { get; set; }
  249. }
  250. }