ILiveTvManager.cs 13 KB

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