ILiveTvManager.cs 12 KB

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