ILiveTvManager.cs 12 KB

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