Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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.DisplayName, ServerIndex = indexProgram.ServerIndex
                    };
                    return(true);
                }
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error(ex.Message);
            }
            return(false);
        }
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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 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 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 GetScheduledPrograms(IChannel channel, out IList<IProgram> programs)
 {
     throw new NotImplementedException();
 }
        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 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 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 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.DisplayName, ServerIndex = indexProgram.ServerIndex };
              return true;
            }
              }
              catch (Exception ex)
              {
            ServiceRegistration.Get<ILogger>().Error(ex.Message);
              }
              return false;
        }
Esempio n. 14
0
        public MediaItem CreateMediaItem(int slotIndex, string streamUrl, IChannel channel)
        {
            if (!String.IsNullOrEmpty(streamUrl))
              {
            ISystemResolver systemResolver = ServiceRegistration.Get<ISystemResolver>();
            IDictionary<Guid, MediaItemAspect> aspects = new Dictionary<Guid, MediaItemAspect>();
            MediaItemAspect providerResourceAspect;
            MediaItemAspect mediaAspect;

            SlimTvResourceAccessor resourceAccessor = new SlimTvResourceAccessor(slotIndex, streamUrl);
            aspects[ProviderResourceAspect.ASPECT_ID] =
              providerResourceAspect = new MediaItemAspect(ProviderResourceAspect.Metadata);
            aspects[MediaAspect.ASPECT_ID] = mediaAspect = new MediaItemAspect(MediaAspect.Metadata);
            // videoaspect needs to be included to associate player later!
            aspects[VideoAspect.ASPECT_ID] = new MediaItemAspect(VideoAspect.Metadata);
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_SYSTEM_ID, systemResolver.LocalSystemId);

            String raPath = resourceAccessor.CanonicalLocalResourcePath.Serialize();
            providerResourceAspect.SetAttribute(ProviderResourceAspect.ATTR_RESOURCE_ACCESSOR_PATH, raPath);

            mediaAspect.SetAttribute(MediaAspect.ATTR_TITLE, "Live TV");
            mediaAspect.SetAttribute(MediaAspect.ATTR_MIME_TYPE, "video/livetv"); //Custom mimetype for LiveTv

            LiveTvMediaItem tvStream = new LiveTvMediaItem(new Guid(), aspects);

            tvStream.AdditionalProperties[LiveTvMediaItem.SLOT_INDEX] = slotIndex;
            tvStream.AdditionalProperties[LiveTvMediaItem.CHANNEL] = channel;
            tvStream.AdditionalProperties[LiveTvMediaItem.TUNING_TIME] = DateTime.Now;

            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;
        }
Esempio n. 15
0
 public bool GetScheduledPrograms(IChannel channel, out IList <IProgram> programs)
 {
     throw new NotImplementedException();
 }