using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Querying;
namespace MediaBrowser.Controller.LiveTv
{
///
/// Manages all live tv services installed on the server
///
public interface ILiveTvManager
{
///
/// Gets the services.
///
/// The services.
IReadOnlyList Services { get; }
///
/// Gets the new timer defaults asynchronous.
///
/// The cancellation token.
/// Task{TimerInfo}.
Task GetNewTimerDefaults(CancellationToken cancellationToken);
///
/// Gets the new timer defaults.
///
/// The program identifier.
/// The cancellation token.
/// Task{SeriesTimerInfoDto}.
Task GetNewTimerDefaults(string programId, CancellationToken cancellationToken);
///
/// Cancels the timer.
///
/// The identifier.
/// Task.
Task CancelTimer(string id);
///
/// Cancels the series timer.
///
/// The identifier.
/// Task.
Task CancelSeriesTimer(string id);
///
/// Adds the parts.
///
/// The services.
/// The tuner hosts.
/// The listing providers.
void AddParts(IEnumerable services, IEnumerable tunerHosts, IEnumerable listingProviders);
///
/// Gets the timer.
///
/// The identifier.
/// The cancellation token.
/// Task{TimerInfoDto}.
Task GetTimer(string id, CancellationToken cancellationToken);
///
/// Gets the series timer.
///
/// The identifier.
/// The cancellation token.
/// Task{TimerInfoDto}.
Task GetSeriesTimer(string id, CancellationToken cancellationToken);
///
/// Gets the recordings.
///
/// The query.
/// The options.
QueryResult GetRecordings(RecordingQuery query, DtoOptions options);
///
/// Gets the timers.
///
/// The query.
/// The cancellation token.
/// Task{QueryResult{TimerInfoDto}}.
Task> GetTimers(TimerQuery query, CancellationToken cancellationToken);
///
/// Gets the series timers.
///
/// The query.
/// The cancellation token.
/// Task{QueryResult{SeriesTimerInfoDto}}.
Task> GetSeriesTimers(SeriesTimerQuery query, CancellationToken cancellationToken);
///
/// Gets the channel stream.
///
/// The identifier.
/// The media source identifier.
/// The cancellation token.
/// Task{StreamResponseInfo}.
Task> GetChannelStream(string id, string mediaSourceId, List currentLiveStreams, CancellationToken cancellationToken);
///
/// Gets the program.
///
/// The identifier.
/// The cancellation token.
/// The user.
/// Task{ProgramInfoDto}.
Task GetProgram(string id, CancellationToken cancellationToken, User user = null);
///
/// Gets the programs.
///
/// The query.
/// The options.
/// The cancellation token.
/// IEnumerable{ProgramInfo}.
Task> GetPrograms(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken);
///
/// Updates the timer.
///
/// The timer.
/// The cancellation token.
/// Task.
Task UpdateTimer(TimerInfoDto timer, CancellationToken cancellationToken);
///
/// Updates the timer.
///
/// The timer.
/// The cancellation token.
/// Task.
Task UpdateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken);
///
/// Creates the timer.
///
/// The timer.
/// The cancellation token.
/// Task.
Task CreateTimer(TimerInfoDto timer, CancellationToken cancellationToken);
///
/// Creates the series timer.
///
/// The timer.
/// The cancellation token.
/// Task.
Task CreateSeriesTimer(SeriesTimerInfoDto timer, CancellationToken cancellationToken);
///
/// Gets the guide information.
///
/// GuideInfo.
GuideInfo GetGuideInfo();
///
/// Gets the recommended programs.
///
/// The query.
/// The options.
/// The cancellation token.
QueryResult GetRecommendedPrograms(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken);
///
/// Gets the recommended programs internal.
///
QueryResult GetRecommendedProgramsInternal(InternalItemsQuery query, DtoOptions options, CancellationToken cancellationToken);
///
/// Gets the live tv information.
///
/// The cancellation token.
/// Task{LiveTvInfo}.
LiveTvInfo GetLiveTvInfo(CancellationToken cancellationToken);
///
/// Resets the tuner.
///
/// The identifier.
/// The cancellation token.
/// Task.
Task ResetTuner(string id, CancellationToken cancellationToken);
///
/// Gets the live tv folder.
///
/// The cancellation token.
Folder GetInternalLiveTvFolder(CancellationToken cancellationToken);
///
/// Gets the enabled users.
///
/// IEnumerable{User}.
IEnumerable GetEnabledUsers();
///
/// Gets the internal channels.
///
QueryResult GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken);
///
/// Gets the channel media sources.
///
Task> GetChannelMediaSources(BaseItem item, CancellationToken cancellationToken);
///
/// Adds the information to program dto.
///
/// The programs.
/// The fields.
/// The user.
/// Task.
Task AddInfoToProgramDto(IReadOnlyCollection<(BaseItem, BaseItemDto)> programs, ItemFields[] fields, User user = null);
///
/// Saves the tuner host.
///
Task SaveTunerHost(TunerHostInfo info, bool dataSourceChanged = true);
///
/// Saves the listing provider.
///
/// The information.
/// if set to true [validate login].
/// if set to true [validate listings].
/// Task.
Task SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings);
void DeleteListingsProvider(string id);
Task SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber);
TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, NameValuePair[] mappings, List providerChannels);
///
/// Gets the lineups.
///
/// Type of the provider.
/// The provider identifier.
/// The country.
/// The location.
/// Task<List<NameIdPair>>.
Task> GetLineups(string providerType, string providerId, string country, string location);
///
/// Adds the channel information.
///
/// The items.
/// The options.
/// The user.
void AddChannelInfo(IReadOnlyCollection<(BaseItemDto, LiveTvChannel)> items, DtoOptions options, User user);
Task> GetChannelsForListingsProvider(string id, CancellationToken cancellationToken);
Task> GetChannelsFromListingsProviderData(string id, CancellationToken cancellationToken);
IListingsProvider[] ListingProviders { get; }
List GetTunerHostTypes();
Task> DiscoverTuners(bool newDevicesOnly, CancellationToken cancellationToken);
event EventHandler> SeriesTimerCancelled;
event EventHandler> TimerCancelled;
event EventHandler> TimerCreated;
event EventHandler> SeriesTimerCreated;
string GetEmbyTvActiveRecordingPath(string id);
ActiveRecordingInfo GetActiveRecordingInfo(string path);
void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null);
List GetRecordingFolders(User user);
}
public class ActiveRecordingInfo
{
public string Id { get; set; }
public string Path { get; set; }
public TimerInfo Timer { get; set; }
public CancellationTokenSource CancellationTokenSource { get; set; }
}
}