/// <summary> /// Tries to get the current and next program for the given <paramref name="channel"/>. /// </summary> /// <param name="channel">Channel</param> /// <returns><c>true</c> if a program could be found</returns> public async Task <AsyncResult <IProgram[]> > GetNowNextProgramAsync(IChannel channel) { // TODO: caching from NativeProvider? IProgram[] programNowNext = new IProgram[2]; Channel indexChannel = channel as Channel; if (indexChannel == null || !CheckConnection(indexChannel.ServerIndex)) { return(new AsyncResult <IProgram[]>(false, null)); } try { IList <WebProgramDetailed> tvPrograms = TvServer(indexChannel.ServerIndex).GetNowNextWebProgramDetailedForChannel(channel.ChannelId); if (tvPrograms.Count > 0 && tvPrograms[0] != null) { programNowNext[0] = new Program(tvPrograms[0], indexChannel.ServerIndex); } if (tvPrograms.Count > 1 && tvPrograms[1] != null) { programNowNext[1] = new Program(tvPrograms[1], indexChannel.ServerIndex); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(new AsyncResult <IProgram[]>(false, null)); } return(new AsyncResult <IProgram[]>(programNowNext[0] != null, programNowNext)); }
public async Task <AsyncResult <MediaItem> > StartTimeshiftAsync(int slotIndex, IChannel channel) { Channel indexChannel = channel as Channel; if (indexChannel == null || !CheckConnection(indexChannel.ServerIndex)) { return(new AsyncResult <MediaItem>(false, null)); } try { ITVAccessService tvServer = TvServer(indexChannel.ServerIndex); String streamUrl = _tvServers[indexChannel.ServerIndex].IsLocalConnection ? // Prefer local timeshift file over RTSP streaming tvServer.SwitchTVServerToChannelAndGetTimeshiftFilename(GetTimeshiftUserName(slotIndex), channel.ChannelId) : tvServer.SwitchTVServerToChannelAndGetStreamingUrl(GetTimeshiftUserName(slotIndex), channel.ChannelId); if (String.IsNullOrEmpty(streamUrl)) { return(new AsyncResult <MediaItem>(false, null)); } _channels[slotIndex] = channel; // assign a MediaItem, can be null if streamUrl is the same. var timeshiftMediaItem = CreateMediaItem(slotIndex, streamUrl, channel); return(new AsyncResult <MediaItem>(true, timeshiftMediaItem)); } catch (Exception ex) { NotifyException(ex, indexChannel.ServerIndex); return(new AsyncResult <MediaItem>(false, null)); } }
public async Task <AsyncResult <IList <IProgram> > > GetProgramsAsync(IChannel channel, DateTime from, DateTime to) { Channel indexChannel = channel as Channel; if (indexChannel == null || !CheckConnection(indexChannel.ServerIndex)) { return(new AsyncResult <IList <IProgram> >(false, null)); } var programs = new List <IProgram>(); try { IList <WebProgramDetailed> tvPrograms = TvServer(indexChannel.ServerIndex).GetProgramsDetailedForChannel(channel.ChannelId, from, to); foreach (WebProgramDetailed webProgram in tvPrograms) { programs.Add(new Program(webProgram, indexChannel.ServerIndex)); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(new AsyncResult <IList <IProgram> >(false, null)); } return(new AsyncResult <IList <IProgram> >(programs.Count > 0, programs)); }
public override bool GetChannel(IProgram program, out IChannel channel) { IChannelService channelService = GlobalServiceProvider.Instance.Get <IChannelService>(); channel = channelService.GetChannel(program.ChannelId).ToChannel(); return(true); }
public override bool GetChannel(int channelId, out IChannel channel) { IChannelService channelGroupService = GlobalServiceProvider.Instance.Get <IChannelService>(); channel = channelGroupService.GetChannel(channelId).ToChannel(); return(true); }
public MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { // Channel is usually only passed as placeholder with ID only, so query the details here #if TVE3 TvDatabase.Channel fullChannel = TvDatabase.Channel.Retrieve(channel.ChannelId); bool isTv = fullChannel.IsTv; #else IChannelService channelService = GlobalServiceProvider.Instance.Get <IChannelService>(); Channel fullChannel = channelService.GetChannel(channel.ChannelId); bool isTv = fullChannel.MediaType == 0; #endif LiveTvMediaItem tvStream = isTv ? SlimTvMediaItemBuilder.CreateMediaItem(slotIndex, streamUrl, fullChannel.ToChannel()) : SlimTvMediaItemBuilder.CreateRadioMediaItem(slotIndex, streamUrl, fullChannel.ToChannel()); if (tvStream != null) { // Add program infos to the LiveTvMediaItem IProgram currentProgram; IProgram nextProgram; if (GetNowNextProgram(channel, out currentProgram, out nextProgram)) { tvStream.AdditionalProperties[LiveTvMediaItem.CURRENT_PROGRAM] = currentProgram; tvStream.AdditionalProperties[LiveTvMediaItem.NEXT_PROGRAM] = nextProgram; } return(tvStream); } return(null); }
public bool StartTimeshift(string userName, int slotIndex, IChannel channel, out MediaItem timeshiftMediaItem) { string timeshiftFile = SwitchTVServerToChannel(GetUserName(userName, slotIndex), channel.ChannelId); timeshiftMediaItem = CreateMediaItem(slotIndex, timeshiftFile, channel); return(!string.IsNullOrEmpty(timeshiftFile)); }
public bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList <IProgram> programs) { programs = null; Channel indexChannel = channel as Channel; if (indexChannel == null) { return(false); } if (!CheckConnection(indexChannel.ServerIndex)) { return(false); } programs = new List <IProgram>(); try { IList <WebProgramDetailed> tvPrograms = TvServer(indexChannel.ServerIndex).GetProgramsDetailedForChannel(channel.ChannelId, from, to); foreach (WebProgramDetailed webProgram in tvPrograms) { programs.Add(new Program(webProgram, indexChannel.ServerIndex)); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(false); } return(programs.Count > 0); }
public override Task <AsyncResult <ISchedule> > CreateScheduleDetailedAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType, int preRecordInterval, int postRecordInterval, string directory, int priority) { IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>(); Schedule tvSchedule = ScheduleFactory.CreateSchedule(channel.ChannelId, title, from, to); tvSchedule.PreRecordInterval = preRecordInterval >= 0 ? preRecordInterval : ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5); tvSchedule.PostRecordInterval = postRecordInterval >= 0 ? postRecordInterval : ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5); if (!String.IsNullOrEmpty(directory)) { tvSchedule.Directory = directory; } if (priority >= 0) { tvSchedule.Priority = priority; } tvSchedule.PreRecordInterval = preRecordInterval; tvSchedule.PostRecordInterval = postRecordInterval; tvSchedule.ScheduleType = (int)recordingType; tvSchedule.Directory = directory; tvSchedule.Priority = priority; scheduleService.SaveSchedule(tvSchedule); ISchedule schedule = tvSchedule.ToSchedule(); return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule))); }
public bool GetChannel(IProgram program, out IChannel channel) { channel = null; Program indexProgram = program as Program; if (indexProgram == null) { return(false); } if (!CheckConnection(indexProgram.ServerIndex)) { return(false); } try { WebChannelBasic tvChannel = TvServer(indexProgram.ServerIndex).GetChannelBasicById(indexProgram.ChannelId); if (tvChannel != null) { channel = new Channel { ChannelId = tvChannel.Id, Name = tvChannel.Title, ServerIndex = indexProgram.ServerIndex }; return(true); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); } return(false); }
public bool GetChannel(int channelId, out IChannel channel) { if (_channelCache.TryGetValue(channelId, out channel)) { return(true); } // TODO: lookup by ID cannot guess which server might be adressed, so we force the first one. int serverIndex = 0; if (!CheckConnection(serverIndex)) { return(false); } try { WebChannelBasic webChannel = TvServer(serverIndex).GetChannelBasicById(channelId); channel = new Channel { ChannelId = webChannel.Id, Name = webChannel.Title, ServerIndex = serverIndex }; _channelCache[channelId] = channel; return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); return(false); } }
public bool StartTimeshift(int slotIndex, IChannel channel, out MediaItem timeshiftMediaItem) { timeshiftMediaItem = null; Channel indexChannel = channel as Channel; if (indexChannel == null) { return(false); } if (!CheckConnection(indexChannel.ServerIndex)) { return(false); } try { String streamUrl = TvServer(indexChannel.ServerIndex).SwitchTVServerToChannelAndGetStreamingUrl(GetTimeshiftUserName(slotIndex), channel.ChannelId); if (String.IsNullOrEmpty(streamUrl)) { return(false); } _channels[slotIndex] = channel; // assign a MediaItem, can be null if streamUrl is the same. timeshiftMediaItem = CreateMediaItem(slotIndex, streamUrl, channel); return(true); } catch (Exception ex) { NotifyException(ex, indexChannel.ServerIndex); return(false); } }
public bool GetCurrentProgram(IChannel channel, out IProgram program) { program = null; Channel indexChannel = channel as Channel; if (indexChannel == null) { return(false); } if (!CheckConnection(indexChannel.ServerIndex)) { return(false); } try { WebProgramDetailed tvProgram = TvServer(indexChannel.ServerIndex).GetCurrentProgramOnChannel(channel.ChannelId); if (tvProgram != null) { program = new Program(tvProgram, indexChannel.ServerIndex); return(true); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Error(ex.Message); } return(false); }
public override MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { // Channel is usually only passed as placeholder with ID only, so query the details here TvDatabase.Channel fullChannel = TvDatabase.Channel.Retrieve(channel.ChannelId); bool isTv = fullChannel.IsTv; return(CreateMediaItem(slotIndex, streamUrl, channel, isTv, fullChannel.ToChannel())); }
public override bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext) { var tvChannel = TvDatabase.Channel.Retrieve(channel.ChannelId); programNow = tvChannel.CurrentProgram.ToProgram(); programNext = tvChannel.NextProgram.ToProgram(); return(programNow != null || programNext != null); }
public override bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList <IProgram> programs) { programs = _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.ChannelId), from, to) .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return(programs.Count > 0); }
public override MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { // Channel is usually only passed as placeholder with ID only, so query the details here IChannelService channelService = GlobalServiceProvider.Instance.Get <IChannelService>(); Channel fullChannel = channelService.GetChannel(channel.ChannelId); bool isTv = fullChannel.MediaType == 0; return(CreateMediaItem(slotIndex, streamUrl, channel, isTv, fullChannel.ToChannel())); }
public override Task <AsyncResult <IProgram[]> > GetNowNextProgramAsync(IChannel channel) { var tvChannel = TvDatabase.Channel.Retrieve(channel.ChannelId); var programNow = GetProgram(tvChannel.CurrentProgram); var programNext = GetProgram(tvChannel.NextProgram); var success = programNow != null || programNext != null; return(Task.FromResult(new AsyncResult <IProgram[]>(success, new[] { programNow, programNext }))); }
public override Task <bool> EditScheduleAsync(ISchedule schedule, IChannel channel = null, string title = null, DateTime?from = null, DateTime?to = null, ScheduleRecordingType?recordingType = null, int?preRecordInterval = null, int?postRecordInterval = null, string directory = null, int?priority = null) { try { ServiceRegistration.Get <ILogger>().Debug("Editing schedule {0} on channel {1} for {2}, {3} till {4}, type {5}", schedule.ScheduleId, channel.ChannelId, title, from, to, recordingType); TvDatabase.Schedule tvSchedule = TvDatabase.Schedule.Retrieve(schedule.ScheduleId); tvSchedule.IdChannel = channel.ChannelId; if (title != null) { tvSchedule.ProgramName = title; } if (from != null) { tvSchedule.StartTime = from.Value; } if (to != null) { tvSchedule.EndTime = to.Value; } if (recordingType != null) { ScheduleRecordingType scheduleRecType = recordingType.Value; tvSchedule.ScheduleType = (int)scheduleRecType; } if (preRecordInterval != null) { tvSchedule.PreRecordInterval = preRecordInterval.Value; } if (postRecordInterval != null) { tvSchedule.PostRecordInterval = postRecordInterval.Value; } if (directory != null) { tvSchedule.Directory = directory; } if (priority != null) { tvSchedule.Priority = priority.Value; } tvSchedule.Persist(); _tvControl.OnNewSchedule(); // I don't think this is needed, but doesn't hurt either return(Task.FromResult(true)); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Warn(String.Format("Failed to edit schedule {0}", schedule.ScheduleId), ex); return(Task.FromResult(false)); } }
public override Task <bool> EditScheduleAsync(ISchedule schedule, IChannel channel = null, string title = null, DateTime?from = null, DateTime?to = null, ScheduleRecordingType?recordingType = null, int?preRecordInterval = null, int?postRecordInterval = null, string directory = null, int?priority = null) { try { ServiceRegistration.Get <ILogger>().Debug("Editing schedule {0} on channel {1} for {2}, {3} till {4}, type {5}", schedule.ScheduleId, channel.ChannelId, title, from, to, recordingType); IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>(); Schedule tvSchedule = scheduleService.GetSchedule(schedule.ScheduleId); tvSchedule.IdChannel = channel.ChannelId; if (title != null) { tvSchedule.ProgramName = title; } if (from != null) { tvSchedule.StartTime = from.Value; } if (to != null) { tvSchedule.EndTime = to.Value; } if (recordingType != null) { ScheduleRecordingType scheduleRecType = recordingType.Value; tvSchedule.ScheduleType = (int)scheduleRecType; } if (preRecordInterval != null) { tvSchedule.PreRecordInterval = preRecordInterval.Value; } if (postRecordInterval != null) { tvSchedule.PostRecordInterval = postRecordInterval.Value; } if (directory != null) { tvSchedule.Directory = directory; } if (priority != null) { tvSchedule.Priority = priority.Value; } scheduleService.SaveSchedule(tvSchedule); return(Task.FromResult(true)); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Warn(String.Format("Failed to edit schedule {0}", schedule.ScheduleId), ex); return(Task.FromResult(false)); } }
public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, "Manual", from, to, (int)ScheduleRecordingType.Once); tvSchedule.PreRecordInterval = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value); tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value); tvSchedule.Persist(); _tvControl.OnNewSchedule(); schedule = tvSchedule.ToSchedule(); return(true); }
public bool GetChannel(int channelId, out IChannel channel) { #if TVE3 channel = TvDatabase.Channel.Retrieve(channelId).ToChannel(); #else IChannelService channelGroupService = GlobalServiceProvider.Instance.Get <IChannelService>(); channel = channelGroupService.GetChannel(channelId).ToChannel(); #endif return(true); }
public override bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList <IProgram> programs) { IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); programs = programService.GetProgramsByChannelAndStartEndTimes(channel.ChannelId, from, to) .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return(programs.Count > 0); }
public override Task <AsyncResult <IList <IProgram> > > GetProgramsAsync(IChannel channel, DateTime from, DateTime to) { IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); var programs = programService.GetProgramsByChannelAndStartEndTimes(channel.ChannelId, from, to) .Select(tvProgram => GetProgram(tvProgram, true)) .Distinct(ProgramComparer.Instance) .ToList(); var success = programs.Count > 0; return(Task.FromResult(new AsyncResult <IList <IProgram> >(success, programs))); }
public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>(); Schedule tvSchedule = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to); tvSchedule.PreRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5); tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5); tvSchedule.ScheduleType = (int)ScheduleRecordingType.Once; scheduleService.SaveSchedule(tvSchedule); schedule = tvSchedule.ToSchedule(); return(true); }
public override Task <AsyncResult <ISchedule> > CreateScheduleByTimeAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType) { IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>(); Schedule tvSchedule = ScheduleFactory.CreateSchedule(channel.ChannelId, title, from, to); tvSchedule.PreRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5); tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5); tvSchedule.ScheduleType = (int)recordingType; scheduleService.SaveSchedule(tvSchedule); var schedule = tvSchedule.ToSchedule(); return(Task.FromResult(new AsyncResult <ISchedule>(true, schedule))); }
public bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList <IProgram> programs) { #if TVE3 programs = _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.ChannelId), from, to) #else IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); programs = programService.GetProgramsByChannelAndStartEndTimes(channel.ChannelId, from, to) #endif .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return(programs.Count > 0); }
public override bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext) { programNow = null; programNext = null; IProgramService programService = GlobalServiceProvider.Instance.Get <IProgramService>(); var programs = programService.GetNowAndNextProgramsForChannel(channel.ChannelId).Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList(); var count = programs.Count; if (count >= 1) { programNow = programs[0]; } if (count >= 2) { programNext = programs[1]; } return(programNow != null || programNext != null); }
public bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { #if TVE3 TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, "Manual", from, to, (int)ScheduleRecordingType.Once); tvSchedule.PreRecordInterval = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value); tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value); tvSchedule.Persist(); _tvControl.OnNewSchedule(); #else IScheduleService scheduleService = GlobalServiceProvider.Get <IScheduleService>(); Schedule tvSchedule = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to); tvSchedule.PreRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5); tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5); tvSchedule.ScheduleType = (int)ScheduleRecordingType.Once; scheduleService.SaveSchedule(tvSchedule); #endif schedule = tvSchedule.ToSchedule(); return(true); }
public async Task <AsyncResult <ISchedule> > CreateScheduleByTimeAsync(IChannel channel, string title, DateTime from, DateTime to, ScheduleRecordingType recordingType) { Channel indexChannel = channel as Channel; if (indexChannel == null || !CheckConnection(indexChannel.ServerIndex)) { return(new AsyncResult <ISchedule>(false, null)); } try { var result = TvServer(indexChannel.ServerIndex).AddSchedule(channel.ChannelId, title, from, to, (WebScheduleType)recordingType); return(new AsyncResult <ISchedule>(true, null)); } catch { return(new AsyncResult <ISchedule>(false, null)); } }
/// <summary> /// Tries to get the current and next program for the given <paramref name="channel"/>. /// </summary> /// <param name="channel">Channel</param> /// <param name="programNow">Returns current program</param> /// <param name="programNext">Returns next program</param> /// <returns><c>true</c> if a program could be found</returns> public bool GetNowNextProgram (IChannel channel, out IProgram programNow, out IProgram programNext) { // TODO: caching from NativeProvider? programNow = null; programNext = null; Channel indexChannel = channel as Channel; if (indexChannel == null) return false; if (!CheckConnection(indexChannel.ServerIndex)) return false; try { IList<WebProgramDetailed> tvPrograms = TvServer(indexChannel.ServerIndex).GetNowNextWebProgramDetailedForChannel(channel.ChannelId); if (tvPrograms.Count > 0 && tvPrograms[0] != null) programNow = new Program(tvPrograms[0], indexChannel.ServerIndex); if (tvPrograms.Count > 1 && tvPrograms[1] != null) programNext = new Program(tvPrograms[1], indexChannel.ServerIndex); } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); return false; } return programNow != null; }
public override bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList<IProgram> programs) { programs = _tvBusiness.GetPrograms(TvDatabase.Channel.Retrieve(channel.ChannelId), from, to) .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return programs.Count > 0; }
public override MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { // Channel is usually only passed as placeholder with ID only, so query the details here TvDatabase.Channel fullChannel = TvDatabase.Channel.Retrieve(channel.ChannelId); bool isTv = fullChannel.IsTv; return CreateMediaItem(slotIndex, streamUrl, channel, isTv, fullChannel.ToChannel()); }
public abstract bool GetChannel(IProgram program, out IChannel channel);
public abstract bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule);
protected virtual MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel, bool isTv, IChannel fullChannel) { LiveTvMediaItem tvStream = isTv ? SlimTvMediaItemBuilder.CreateMediaItem(slotIndex, streamUrl, fullChannel) : SlimTvMediaItemBuilder.CreateRadioMediaItem(slotIndex, streamUrl, fullChannel); if (tvStream != null) { // Add program infos to the LiveTvMediaItem IProgram currentProgram; IProgram nextProgram; if (GetNowNextProgram(channel, out currentProgram, out nextProgram)) { tvStream.AdditionalProperties[LiveTvMediaItem.CURRENT_PROGRAM] = currentProgram; tvStream.AdditionalProperties[LiveTvMediaItem.NEXT_PROGRAM] = nextProgram; } return tvStream; } return null; }
public abstract bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList<IProgram> programs);
public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { TvDatabase.Schedule tvSchedule = _tvBusiness.AddSchedule(channel.ChannelId, "Manual", from, to, (int)ScheduleRecordingType.Once); tvSchedule.PreRecordInterval = Int32.Parse(_tvBusiness.GetSetting("preRecordInterval", "5").Value); tvSchedule.PostRecordInterval = Int32.Parse(_tvBusiness.GetSetting("postRecordInterval", "5").Value); tvSchedule.Persist(); _tvControl.OnNewSchedule(); schedule = tvSchedule.ToSchedule(); return true; }
public override MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { // Channel is usually only passed as placeholder with ID only, so query the details here IChannelService channelService = GlobalServiceProvider.Instance.Get<IChannelService>(); Channel fullChannel = channelService.GetChannel(channel.ChannelId); bool isTv = fullChannel.MediaType == 0; return CreateMediaItem(slotIndex, streamUrl, channel, isTv, fullChannel.ToChannel()); }
public bool GetChannel(IProgram program, out IChannel channel) { channel = null; Program indexProgram = program as Program; if (indexProgram == null) return false; if (!CheckConnection(indexProgram.ServerIndex)) return false; try { WebChannelBasic tvChannel = TvServer(indexProgram.ServerIndex).GetChannelBasicById(indexProgram.ChannelId); if (tvChannel != null) { channel = new Channel { ChannelId = tvChannel.Id, Name = tvChannel.Title, ServerIndex = indexProgram.ServerIndex }; return true; } } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); } return false; }
public bool StartTimeshift(int slotIndex, IChannel channel, out MediaItem timeshiftMediaItem) { timeshiftMediaItem = null; Channel indexChannel = channel as Channel; if (indexChannel == null) return false; if (!CheckConnection(indexChannel.ServerIndex)) return false; try { String streamUrl = TvServer(indexChannel.ServerIndex).SwitchTVServerToChannelAndGetStreamingUrl(GetTimeshiftUserName(slotIndex), channel.ChannelId); if (String.IsNullOrEmpty(streamUrl)) return false; _channels[slotIndex] = channel; // assign a MediaItem, can be null if streamUrl is the same. timeshiftMediaItem = CreateMediaItem(slotIndex, streamUrl, channel); return true; } catch (Exception ex) { NotifyException(ex, indexChannel.ServerIndex); return false; } }
public MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel) { LiveTvMediaItem tvStream = SlimTvMediaItemBuilder.CreateMediaItem(slotIndex, streamUrl, channel); if (tvStream != null) { // Add program infos to the LiveTvMediaItem IProgram currentProgram; if (GetCurrentProgram(channel, out currentProgram)) tvStream.AdditionalProperties[LiveTvMediaItem.CURRENT_PROGRAM] = currentProgram; IProgram nextProgram; if (GetNextProgram(channel, out nextProgram)) tvStream.AdditionalProperties[LiveTvMediaItem.NEXT_PROGRAM] = nextProgram; return tvStream; } return null; }
public bool GetCurrentProgram(IChannel channel, out IProgram program) { program = null; Channel indexChannel = channel as Channel; if (indexChannel == null) return false; if (!CheckConnection(indexChannel.ServerIndex)) return false; try { WebProgramDetailed tvProgram = TvServer(indexChannel.ServerIndex).GetCurrentProgramOnChannel(channel.ChannelId); if (tvProgram != null) { program = new Program(tvProgram, indexChannel.ServerIndex); return true; } } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); } return false; }
public bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList<IProgram> programs) { programs = null; Channel indexChannel = channel as Channel; if (indexChannel == null) return false; if (!CheckConnection(indexChannel.ServerIndex)) return false; programs = new List<IProgram>(); try { IList<WebProgramDetailed> tvPrograms = TvServer(indexChannel.ServerIndex).GetProgramsDetailedForChannel(channel.ChannelId, from, to); foreach (WebProgramDetailed webProgram in tvPrograms) programs.Add(new Program(webProgram, indexChannel.ServerIndex)); } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); return false; } return programs.Count > 0; }
public bool StartTimeshift(string userName, int slotIndex, IChannel channel, out MediaItem timeshiftMediaItem) { string timeshiftFile = SwitchTVServerToChannel(GetUserName(userName, slotIndex), channel.ChannelId); timeshiftMediaItem = CreateMediaItem(slotIndex, timeshiftFile, channel); return !string.IsNullOrEmpty(timeshiftFile); }
public override bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext) { programNow = null; programNext = null; IProgramService programService = GlobalServiceProvider.Instance.Get<IProgramService>(); var programs = programService.GetNowAndNextProgramsForChannel(channel.ChannelId).Select(p => p.ToProgram()).Distinct(ProgramComparer.Instance).ToList(); var count = programs.Count; if (count >= 1) programNow = programs[0]; if (count >= 2) programNext = programs[1]; return programNow != null || programNext != null; }
public abstract MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel);
public override bool GetPrograms(IChannel channel, DateTime from, DateTime to, out IList<IProgram> programs) { IProgramService programService = GlobalServiceProvider.Instance.Get<IProgramService>(); programs = programService.GetProgramsByChannelAndStartEndTimes(channel.ChannelId, from, to) .Select(tvProgram => tvProgram.ToProgram(true)) .Distinct(ProgramComparer.Instance) .ToList(); return programs.Count > 0; }
public abstract bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext);
public override bool GetChannel(IProgram program, out IChannel channel) { IChannelService channelService = GlobalServiceProvider.Instance.Get<IChannelService>(); channel = channelService.GetChannel(program.ChannelId).ToChannel(); return true; }
public virtual bool GetScheduledPrograms(IChannel channel, out IList<IProgram> programs) { throw new NotImplementedException(); }
public override bool GetChannel(int channelId, out IChannel channel) { IChannelService channelGroupService = GlobalServiceProvider.Instance.Get<IChannelService>(); channel = channelGroupService.GetChannel(channelId).ToChannel(); return true; }
public abstract bool GetChannel(int channelId, out IChannel channel);
public override bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { IScheduleService scheduleService = GlobalServiceProvider.Get<IScheduleService>(); Schedule tvSchedule = ScheduleFactory.CreateSchedule(channel.ChannelId, "Manual", from, to); tvSchedule.PreRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("preRecordInterval", 5); tvSchedule.PostRecordInterval = ServiceAgents.Instance.SettingServiceAgent.GetValue("postRecordInterval", 5); tvSchedule.ScheduleType = (int)ScheduleRecordingType.Once; scheduleService.SaveSchedule(tvSchedule); schedule = tvSchedule.ToSchedule(); return true; }
public override bool GetChannel(IProgram program, out IChannel channel) { channel = TvDatabase.Channel.Retrieve(program.ChannelId).ToChannel(); return true; }
public override bool GetChannel(int channelId, out IChannel channel) { channel = TvDatabase.Channel.Retrieve(channelId).ToChannel(); return channel != null; }
public override bool GetNowNextProgram(IChannel channel, out IProgram programNow, out IProgram programNext) { var tvChannel = TvDatabase.Channel.Retrieve(channel.ChannelId); programNow = tvChannel.CurrentProgram.ToProgram(); programNext = tvChannel.NextProgram.ToProgram(); return programNow != null || programNext != null; }
public bool StartTimeshift(int slotIndex, IChannel channel, out MediaItem timeshiftMediaItem) { throw new NotImplementedException("Not available in server side implementation"); }
public bool GetNextProgram(IChannel channel, out IProgram program) { program = null; Channel indexChannel = channel as Channel; if (indexChannel == null) return false; if (!CheckConnection(indexChannel.ServerIndex)) return false; IProgram currentProgram; try { if (GetCurrentProgram(channel, out currentProgram)) { IList<WebProgramDetailed> nextPrograms = TvServer(indexChannel.ServerIndex).GetProgramsDetailedForChannel(channel.ChannelId, currentProgram.EndTime.AddMinutes(1), currentProgram.EndTime.AddMinutes(1)); if (nextPrograms != null && nextPrograms.Count > 0) { program = new Program(nextPrograms[0], indexChannel.ServerIndex); return true; } } } catch (Exception ex) { ServiceRegistration.Get<ILogger>().Error(ex.Message); } return false; }
public bool CreateScheduleByTime(IChannel channel, DateTime from, DateTime to, out ISchedule schedule) { Channel indexChannel = channel as Channel; schedule = null; if (indexChannel == null) return false; if (!CheckConnection(indexChannel.ServerIndex)) return false; try { return TvServer(indexChannel.ServerIndex).AddSchedule(channel.ChannelId, "Manual", from, to, WebScheduleType.Once); } catch { return false; } }