ILiveTvManager.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. 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. QueryResult<BaseItemDto> GetRecommendedPrograms(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken);
  212. /// <summary>
  213. /// Gets the recommended programs internal.
  214. /// </summary>
  215. QueryResult<BaseItem> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken);
  216. /// <summary>
  217. /// Gets the live tv information.
  218. /// </summary>
  219. /// <param name="cancellationToken">The cancellation token.</param>
  220. /// <returns>Task{LiveTvInfo}.</returns>
  221. Task<LiveTvInfo> GetLiveTvInfo(CancellationToken cancellationToken);
  222. /// <summary>
  223. /// Resets the tuner.
  224. /// </summary>
  225. /// <param name="id">The identifier.</param>
  226. /// <param name="cancellationToken">The cancellation token.</param>
  227. /// <returns>Task.</returns>
  228. Task ResetTuner(string id, CancellationToken cancellationToken);
  229. /// <summary>
  230. /// Gets the live tv folder.
  231. /// </summary>
  232. /// <param name="cancellationToken">The cancellation token.</param>
  233. Folder GetInternalLiveTvFolder(CancellationToken cancellationToken);
  234. /// <summary>
  235. /// Gets the live tv folder.
  236. /// </summary>
  237. /// <param name="userId">The user identifier.</param>
  238. /// <param name="cancellationToken">The cancellation token.</param>
  239. /// <returns>BaseItemDto.</returns>
  240. BaseItemDto GetLiveTvFolder(string userId, CancellationToken cancellationToken);
  241. /// <summary>
  242. /// Gets the enabled users.
  243. /// </summary>
  244. /// <returns>IEnumerable{User}.</returns>
  245. IEnumerable<User> GetEnabledUsers();
  246. /// <summary>
  247. /// Gets the internal channels.
  248. /// </summary>
  249. QueryResult<BaseItem> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken);
  250. /// <summary>
  251. /// Gets the internal recordings.
  252. /// </summary>
  253. Task<QueryResult<BaseItem>> GetInternalRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken);
  254. /// <summary>
  255. /// Gets the recording media sources.
  256. /// </summary>
  257. Task<IEnumerable<MediaSourceInfo>> GetRecordingMediaSources(IHasMediaSources item, CancellationToken cancellationToken);
  258. /// <summary>
  259. /// Gets the channel media sources.
  260. /// </summary>
  261. Task<IEnumerable<MediaSourceInfo>> GetChannelMediaSources(IHasMediaSources item, CancellationToken cancellationToken);
  262. /// <summary>
  263. /// Adds the information to recording dto.
  264. /// </summary>
  265. /// <param name="item">The item.</param>
  266. /// <param name="dto">The dto.</param>
  267. /// <param name="user">The user.</param>
  268. void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null);
  269. /// <summary>
  270. /// Adds the information to program dto.
  271. /// </summary>
  272. /// <param name="programs">The programs.</param>
  273. /// <param name="fields">The fields.</param>
  274. /// <param name="user">The user.</param>
  275. /// <returns>Task.</returns>
  276. Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> programs, ItemFields[] fields, User user = null);
  277. /// <summary>
  278. /// Saves the tuner host.
  279. /// </summary>
  280. Task<TunerHostInfo> SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
  281. /// <summary>
  282. /// Saves the listing provider.
  283. /// </summary>
  284. /// <param name="info">The information.</param>
  285. /// <param name="validateLogin">if set to <c>true</c> [validate login].</param>
  286. /// <param name="validateListings">if set to <c>true</c> [validate listings].</param>
  287. /// <returns>Task.</returns>
  288. Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings);
  289. void DeleteListingsProvider(string id);
  290. Task<TunerChannelMapping> SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber);
  291. TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, NameValuePair[] mappings, List<ChannelInfo> providerChannels);
  292. /// <summary>
  293. /// Gets the lineups.
  294. /// </summary>
  295. /// <param name="providerType">Type of the provider.</param>
  296. /// <param name="providerId">The provider identifier.</param>
  297. /// <param name="country">The country.</param>
  298. /// <param name="location">The location.</param>
  299. /// <returns>Task&lt;List&lt;NameIdPair&gt;&gt;.</returns>
  300. Task<List<NameIdPair>> GetLineups(string providerType, string providerId, string country, string location);
  301. /// <summary>
  302. /// Gets the registration information.
  303. /// </summary>
  304. /// <param name="feature">The feature.</param>
  305. /// <returns>Task&lt;MBRegistrationRecord&gt;.</returns>
  306. Task<MBRegistrationRecord> GetRegistrationInfo(string feature);
  307. /// <summary>
  308. /// Adds the channel information.
  309. /// </summary>
  310. /// <param name="items">The items.</param>
  311. /// <param name="options">The options.</param>
  312. /// <param name="user">The user.</param>
  313. void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> items, DtoOptions options, User user);
  314. Task<List<ChannelInfo>> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken);
  315. Task<List<ChannelInfo>> GetChannelsFromListingsProviderData(string id, CancellationToken cancellationToken);
  316. List<IListingsProvider> ListingProviders { get; }
  317. List<NameIdPair> GetTunerHostTypes();
  318. Task<List<TunerHostInfo>> DiscoverTuners(bool newDevicesOnly, CancellationToken cancellationToken);
  319. event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCancelled;
  320. event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCancelled;
  321. event EventHandler<GenericEventArgs<TimerEventInfo>> TimerCreated;
  322. event EventHandler<GenericEventArgs<TimerEventInfo>> SeriesTimerCreated;
  323. string GetEmbyTvActiveRecordingPath(string id);
  324. Task<ILiveStream> GetEmbyTvLiveStream(string id);
  325. ActiveRecordingInfo GetActiveRecordingInfo(string path);
  326. void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null);
  327. }
  328. }