ILiveTvManager.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. /// Deletes the recording.
  40. /// </summary>
  41. /// <param name="id">The identifier.</param>
  42. /// <returns>Task.</returns>
  43. Task DeleteRecording(string id);
  44. /// <summary>
  45. /// Deletes the recording.
  46. /// </summary>
  47. /// <param name="recording">The recording.</param>
  48. /// <returns>Task.</returns>
  49. Task DeleteRecording(BaseItem recording);
  50. /// <summary>
  51. /// Cancels the timer.
  52. /// </summary>
  53. /// <param name="id">The identifier.</param>
  54. /// <returns>Task.</returns>
  55. Task CancelTimer(string id);
  56. /// <summary>
  57. /// Cancels the series timer.
  58. /// </summary>
  59. /// <param name="id">The identifier.</param>
  60. /// <returns>Task.</returns>
  61. Task CancelSeriesTimer(string id);
  62. /// <summary>
  63. /// Adds the parts.
  64. /// </summary>
  65. /// <param name="services">The services.</param>
  66. /// <param name="tunerHosts">The tuner hosts.</param>
  67. /// <param name="listingProviders">The listing providers.</param>
  68. void AddParts(IEnumerable<ILiveTvService> services, IEnumerable<ITunerHost> tunerHosts, IEnumerable<IListingsProvider> listingProviders);
  69. /// <summary>
  70. /// Gets the recording.
  71. /// </summary>
  72. /// <param name="id">The identifier.</param>
  73. /// <param name="options">The options.</param>
  74. /// <param name="cancellationToken">The cancellation token.</param>
  75. /// <param name="user">The user.</param>
  76. /// <returns>Task{RecordingInfoDto}.</returns>
  77. Task<BaseItemDto> GetRecording(string id, DtoOptions options, CancellationToken cancellationToken, User user = null);
  78. /// <summary>
  79. /// Gets the timer.
  80. /// </summary>
  81. /// <param name="id">The identifier.</param>
  82. /// <param name="cancellationToken">The cancellation token.</param>
  83. /// <returns>Task{TimerInfoDto}.</returns>
  84. Task<TimerInfoDto> GetTimer(string id, CancellationToken cancellationToken);
  85. /// <summary>
  86. /// Gets the series timer.
  87. /// </summary>
  88. /// <param name="id">The identifier.</param>
  89. /// <param name="cancellationToken">The cancellation token.</param>
  90. /// <returns>Task{TimerInfoDto}.</returns>
  91. Task<SeriesTimerInfoDto> GetSeriesTimer(string id, CancellationToken cancellationToken);
  92. /// <summary>
  93. /// Gets the recordings.
  94. /// </summary>
  95. /// <param name="query">The query.</param>
  96. /// <param name="options">The options.</param>
  97. /// <param name="cancellationToken">The cancellation token.</param>
  98. /// <returns>QueryResult{RecordingInfoDto}.</returns>
  99. Task<QueryResult<BaseItemDto>> GetRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken);
  100. Task<QueryResult<BaseItemDto>> GetRecordingSeries(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken);
  101. /// <summary>
  102. /// Gets the timers.
  103. /// </summary>
  104. /// <param name="query">The query.</param>
  105. /// <param name="cancellationToken">The cancellation token.</param>
  106. /// <returns>Task{QueryResult{TimerInfoDto}}.</returns>
  107. Task<QueryResult<TimerInfoDto>> GetTimers(TimerQuery query, CancellationToken cancellationToken);
  108. /// <summary>
  109. /// Gets the series timers.
  110. /// </summary>
  111. /// <param name="query">The query.</param>
  112. /// <param name="cancellationToken">The cancellation token.</param>
  113. /// <returns>Task{QueryResult{SeriesTimerInfoDto}}.</returns>
  114. Task<QueryResult<SeriesTimerInfoDto>> GetSeriesTimers(SeriesTimerQuery query, CancellationToken cancellationToken);
  115. /// <summary>
  116. /// Gets the channel.
  117. /// </summary>
  118. /// <param name="id">The identifier.</param>
  119. /// <returns>Channel.</returns>
  120. LiveTvChannel GetInternalChannel(string id);
  121. /// <summary>
  122. /// Gets the recording.
  123. /// </summary>
  124. /// <param name="id">The identifier.</param>
  125. /// <param name="cancellationToken">The cancellation token.</param>
  126. /// <returns>LiveTvRecording.</returns>
  127. Task<BaseItem> GetInternalRecording(string id, CancellationToken cancellationToken);
  128. /// <summary>
  129. /// Gets the recording stream.
  130. /// </summary>
  131. /// <param name="id">The identifier.</param>
  132. /// <param name="cancellationToken">The cancellation token.</param>
  133. /// <returns>Task{Stream}.</returns>
  134. Task<MediaSourceInfo> GetRecordingStream(string id, CancellationToken cancellationToken);
  135. /// <summary>
  136. /// Gets the channel stream.
  137. /// </summary>
  138. /// <param name="id">The identifier.</param>
  139. /// <param name="mediaSourceId">The media source identifier.</param>
  140. /// <param name="cancellationToken">The cancellation token.</param>
  141. /// <returns>Task{StreamResponseInfo}.</returns>
  142. Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken);
  143. /// <summary>
  144. /// Gets the program.
  145. /// </summary>
  146. /// <param name="id">The identifier.</param>
  147. /// <param name="cancellationToken">The cancellation token.</param>
  148. /// <param name="user">The user.</param>
  149. /// <returns>Task{ProgramInfoDto}.</returns>
  150. Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null);
  151. /// <summary>
  152. /// Gets the programs.
  153. /// </summary>
  154. /// <param name="query">The query.</param>
  155. /// <param name="options">The options.</param>
  156. /// <param name="cancellationToken">The cancellation token.</param>
  157. /// <returns>IEnumerable{ProgramInfo}.</returns>
  158. Task<QueryResult<BaseItemDto>> GetPrograms(ProgramQuery query, DtoOptions options, CancellationToken cancellationToken);
  159. /// <summary>
  160. /// Updates the timer.
  161. /// </summary>
  162. /// <param name="timer">The timer.</param>
  163. /// <param name="cancellationToken">The cancellation token.</param>
  164. /// <returns>Task.</returns>
  165. Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken);
  166. /// <summary>
  167. /// Updates the timer.
  168. /// </summary>
  169. /// <param name="timer">The timer.</param>
  170. /// <param name="cancellationToken">The cancellation token.</param>
  171. /// <returns>Task.</returns>
  172. Task UpdateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken);
  173. /// <summary>
  174. /// Creates the timer.
  175. /// </summary>
  176. /// <param name="timer">The timer.</param>
  177. /// <param name="cancellationToken">The cancellation token.</param>
  178. /// <returns>Task.</returns>
  179. Task CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken);
  180. /// <summary>
  181. /// Creates the series timer.
  182. /// </summary>
  183. /// <param name="timer">The timer.</param>
  184. /// <param name="cancellationToken">The cancellation token.</param>
  185. /// <returns>Task.</returns>
  186. Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken);
  187. /// <summary>
  188. /// Gets the recording groups.
  189. /// </summary>
  190. /// <param name="query">The query.</param>
  191. /// <param name="cancellationToken">The cancellation token.</param>
  192. /// <returns>Task{QueryResult{RecordingGroupDto}}.</returns>
  193. Task<QueryResult<BaseItemDto>> GetRecordingGroups(RecordingGroupQuery query, CancellationToken cancellationToken);
  194. /// <summary>
  195. /// Closes the live stream.
  196. /// </summary>
  197. /// <param name="id">The identifier.</param>
  198. /// <returns>Task.</returns>
  199. Task CloseLiveStream(string id);
  200. /// <summary>
  201. /// Gets the guide information.
  202. /// </summary>
  203. /// <returns>GuideInfo.</returns>
  204. GuideInfo GetGuideInfo();
  205. /// <summary>
  206. /// Gets the recommended programs.
  207. /// </summary>
  208. /// <param name="query">The query.</param>
  209. /// <param name="options">The options.</param>
  210. /// <param name="cancellationToken">The cancellation token.</param>
  211. /// <returns>Task{QueryResult{ProgramInfoDto}}.</returns>
  212. Task<QueryResult<BaseItemDto>> GetRecommendedPrograms(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken);
  213. /// <summary>
  214. /// Gets the recommended programs internal.
  215. /// </summary>
  216. /// <returns>Task&lt;QueryResult&lt;LiveTvProgram&gt;&gt;.</returns>
  217. Task<QueryResult<LiveTvProgram>> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken);
  218. /// <summary>
  219. /// Gets the live tv information.
  220. /// </summary>
  221. /// <param name="cancellationToken">The cancellation token.</param>
  222. /// <returns>Task{LiveTvInfo}.</returns>
  223. Task<LiveTvInfo> GetLiveTvInfo(CancellationToken cancellationToken);
  224. /// <summary>
  225. /// Resets the tuner.
  226. /// </summary>
  227. /// <param name="id">The identifier.</param>
  228. /// <param name="cancellationToken">The cancellation token.</param>
  229. /// <returns>Task.</returns>
  230. Task ResetTuner(string id, CancellationToken cancellationToken);
  231. /// <summary>
  232. /// Gets the live tv folder.
  233. /// </summary>
  234. /// <param name="cancellationToken">The cancellation token.</param>
  235. /// <returns>BaseItemDto.</returns>
  236. Task<Folder> GetInternalLiveTvFolder(CancellationToken cancellationToken);
  237. /// <summary>
  238. /// Gets the live tv folder.
  239. /// </summary>
  240. /// <param name="userId">The user identifier.</param>
  241. /// <param name="cancellationToken">The cancellation token.</param>
  242. /// <returns>BaseItemDto.</returns>
  243. Task<BaseItemDto> GetLiveTvFolder(string userId, CancellationToken cancellationToken);
  244. /// <summary>
  245. /// Gets the enabled users.
  246. /// </summary>
  247. /// <returns>IEnumerable{User}.</returns>
  248. IEnumerable<User> GetEnabledUsers();
  249. /// <summary>
  250. /// Gets the internal channels.
  251. /// </summary>
  252. Task<QueryResult<LiveTvChannel>> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken);
  253. /// <summary>
  254. /// Gets the internal recordings.
  255. /// </summary>
  256. Task<QueryResult<BaseItem>> GetInternalRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken);
  257. /// <summary>
  258. /// Gets the recording media sources.
  259. /// </summary>
  260. Task<IEnumerable<MediaSourceInfo>> GetRecordingMediaSources(IHasMediaSources item, CancellationToken cancellationToken);
  261. /// <summary>
  262. /// Gets the channel media sources.
  263. /// </summary>
  264. Task<IEnumerable<MediaSourceInfo>> GetChannelMediaSources(IHasMediaSources item, CancellationToken cancellationToken);
  265. /// <summary>
  266. /// Adds the information to recording dto.
  267. /// </summary>
  268. /// <param name="item">The item.</param>
  269. /// <param name="dto">The dto.</param>
  270. /// <param name="user">The user.</param>
  271. void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null);
  272. /// <summary>
  273. /// Adds the information to program dto.
  274. /// </summary>
  275. /// <param name="programs">The programs.</param>
  276. /// <param name="fields">The fields.</param>
  277. /// <param name="user">The user.</param>
  278. /// <returns>Task.</returns>
  279. Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> programs, List<ItemFields> fields, User user = null);
  280. /// <summary>
  281. /// Saves the tuner host.
  282. /// </summary>
  283. Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
  284. /// <summary>
  285. /// Saves the listing provider.
  286. /// </summary>
  287. /// <param name="info">The information.</param>
  288. /// <param name="validateLogin">if set to <c>true</c> [validate login].</param>
  289. /// <param name="validateListings">if set to <c>true</c> [validate listings].</param>
  290. /// <returns>Task.</returns>
  291. Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings);
  292. void DeleteListingsProvider(string id);
  293. Task<TunerChannelMapping> SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber);
  294. TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, List<NameValuePair> mappings, List<ChannelInfo> providerChannels);
  295. /// <summary>
  296. /// Gets the lineups.
  297. /// </summary>
  298. /// <param name="providerType">Type of the provider.</param>
  299. /// <param name="providerId">The provider identifier.</param>
  300. /// <param name="country">The country.</param>
  301. /// <param name="location">The location.</param>
  302. /// <returns>Task&lt;List&lt;NameIdPair&gt;&gt;.</returns>
  303. Task<List<NameIdPair>> GetLineups(string providerType, string providerId, string country, string location);
  304. /// <summary>
  305. /// Gets the registration information.
  306. /// </summary>
  307. /// <param name="feature">The feature.</param>
  308. /// <returns>Task&lt;MBRegistrationRecord&gt;.</returns>
  309. Task<MBRegistrationRecord> GetRegistrationInfo(string feature);
  310. /// <summary>
  311. /// Adds the channel information.
  312. /// </summary>
  313. /// <param name="items">The items.</param>
  314. /// <param name="options">The options.</param>
  315. /// <param name="user">The user.</param>
  316. Task AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> items, DtoOptions options, User user);
  317. /// <summary>
  318. /// Called when [recording file deleted].
  319. /// </summary>
  320. /// <param name="recording">The recording.</param>
  321. /// <returns>Task.</returns>
  322. Task OnRecordingFileDeleted(BaseItem recording);
  323. Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken);
  324. Task<List<ChannelInfo>> GetChannelsFromListingsProviderData(string id, CancellationToken cancellationToken);
  325. List<IListingsProvider> ListingProviders { get; }
  326. List<NameIdPair> GetTunerHostTypes();
  327. Task<List<TunerHostInfo>> DiscoverTuners(bool newDevicesOnly, CancellationToken cancellationToken);
  328. event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
  329. event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCancelled;
  330. event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
  331. event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;
  332. string GetEmbyTvActiveRecordingPath(string id);
  333. Task<LiveStream> GetEmbyTvLiveStream(string id);
  334. }
  335. }