Beispiel #1
0
        private LinkedMediaPortalChannel GetLinkedMediaPortalChannelInternal(ChannelType channelType, Guid channelId, string displayName, out bool isAutoLinked, out bool duplicateChannelsFound)
        {
            EnsureLoaded();

            _readerWriterLock.EnterReadLock();
            try
            {
                isAutoLinked           = false;
                duplicateChannelsFound = false;

                if (_linksById.ContainsKey(channelId))
                {
                    ChannelLink link = _linksById[channelId];
                    return(new LinkedMediaPortalChannel(link.MPChannelId, link.MPChannelName));
                }

                TvDatabase.Channel channel = GetChannelByDisplayName(channelType, displayName,
                                                                     out duplicateChannelsFound);
                if (channel != null)
                {
                    isAutoLinked = true;
                    _autoLinkedMPChannels[channel.IdChannel] = true;
                    return(new LinkedMediaPortalChannel(channel.IdChannel, channel.DisplayName));
                }

                return(null);
            }
            finally
            {
                _readerWriterLock.ExitReadLock();
            }
        }
 public RecordingThread(Guid recorderTunerId, string serverHostName, int tcpPort, CardChannelAllocation channelAllocation,
                        DateTime startTimeUtc, DateTime stopTimeUtc, UpcomingProgram recordingProgram, string suggestedBaseFileName,
                        TvDatabase.Card recordOnCard, TvDatabase.Channel channel)
     : base(recorderTunerId, serverHostName, tcpPort, channelAllocation, startTimeUtc, stopTimeUtc, recordingProgram, true)
 {
     _suggestedBaseFileName = suggestedBaseFileName;
     _recordOnCard          = recordOnCard;
     _channel = channel;
 }
 public RecordingThread(Guid recorderId, string schedulerBaseUrl, CardChannelAllocation channelAllocation,
     DateTime startTimeUtc, DateTime stopTimeUtc, UpcomingProgram recordingProgram, string suggestedBaseFileName,
     TvDatabase.Card recordOnCard, TvDatabase.Channel channel)
     : base(recorderId, schedulerBaseUrl, channelAllocation, startTimeUtc, stopTimeUtc, recordingProgram, true)
 {
     _suggestedBaseFileName = suggestedBaseFileName;
     _recordOnCard = recordOnCard;
     _channel = channel;
 }
 public RecordingThread(Guid recorderTunerId, string serverHostName, int tcpPort, CardChannelAllocation channelAllocation,
     DateTime startTimeUtc, DateTime stopTimeUtc, UpcomingProgram recordingProgram, string suggestedBaseFileName,
     TvDatabase.Card recordOnCard, TvDatabase.Channel channel)
     : base(recorderTunerId, serverHostName, tcpPort, channelAllocation, startTimeUtc, stopTimeUtc, recordingProgram, true)
 {
     _suggestedBaseFileName = suggestedBaseFileName;
     _recordOnCard = recordOnCard;
     _channel = channel;
 }
Beispiel #5
0
 public RecordingThread(Guid recorderId, string schedulerBaseUrl, CardChannelAllocation channelAllocation,
                        DateTime startTimeUtc, DateTime stopTimeUtc, UpcomingProgram recordingProgram, string suggestedBaseFileName,
                        TvDatabase.Card recordOnCard, TvDatabase.Channel channel)
     : base(recorderId, schedulerBaseUrl, channelAllocation, startTimeUtc, stopTimeUtc, recordingProgram, true)
 {
     _suggestedBaseFileName = suggestedBaseFileName;
     _recordOnCard          = recordOnCard;
     _channel = channel;
 }
Beispiel #6
0
 public static bool IsSameTransponder(int cardId, TvDatabase.TuningDetail tuning, int otherChannelId)
 {
     TvDatabase.Channel otherChannel = TvDatabase.Channel.Retrieve(otherChannelId);
     if (otherChannel != null)
     {
         return(IsSameTransponder(cardId, tuning, otherChannel));
     }
     return(false);
 }
 public ImportChannel(TvDatabase.Channel mpChannel, string groupName, int groupSequence)
 {
     this.Channel       = mpChannel;
     this.GroupName     = groupName;
     this.GroupSequence = groupSequence;
     if (mpChannel.ChannelNumber > 0)
     {
         this.LogicalChannelNumber = mpChannel.ChannelNumber;
     }
 }
        private static TvDatabase.Channel GetLinkedMediaPortalChannel(ChannelType channelType, Guid channelId, string displayName)
        {
            TvDatabase.Channel       allocatedChannel = null;
            LinkedMediaPortalChannel linkedChannel    = ChannelLinks.GetLinkedMediaPortalChannel(channelType, channelId, displayName);

            if (linkedChannel != null)
            {
                allocatedChannel = TvDatabase.Channel.Retrieve(linkedChannel.Id);
            }
            return(allocatedChannel);
        }
Beispiel #9
0
        /// <summary>
        /// Mediaportal TV playback changed
        /// </summary>
        void g_Player_TVPlayBackChanged()
        {
            TvDatabase.Channel current = MpTvServerHelper.GetCurrentTimeShiftingTVChannel();

            if (socketServer != null && current != null && (LatestChannelId == -1 || LatestChannelId != current.IdChannel))
            {
                LatestChannelId = current.IdChannel;
                LogMessage("TV Playback changed!", LogType.Debug);
                socketServer.SendNowPlayingToAllClients();
            }
        }
Beispiel #10
0
 private static void EnsureGuideChannelForDvbEpg(Channel channel, TvDatabase.Channel mpChannel)
 {
     if (!channel.GuideChannelId.HasValue)
     {
         string externalId = mpChannel.ExternalId;
         if (String.IsNullOrEmpty(externalId))
         {
             externalId = mpChannel.DisplayName;
         }
         channel.GuideChannelId = Proxies.GuideService.EnsureChannelExists(externalId, mpChannel.DisplayName, channel.ChannelType).Result;
         Proxies.SchedulerService.AttachChannelToGuide(channel.ChannelId, channel.GuideChannelId.Value).Wait();
     }
 }
Beispiel #11
0
        public bool IsAutoLinkedInternal(TvDatabase.Channel mpChannel)
        {
            EnsureLoaded();

            _readerWriterLock.EnterReadLock();
            try
            {
                return(_autoLinkedMPChannels.ContainsKey(mpChannel.IdChannel));
            }
            finally
            {
                _readerWriterLock.ExitReadLock();
            }
        }
Beispiel #12
0
        private static Channel EnsureChannelForDvbEpg(TvDatabase.Channel mpChannel, bool epgSyncAutoCreateChannels, bool epgSyncAutoCreateChannelsWithGroup)
        {
            ChannelLink channelLink = ChannelLinks.GetChannelLinkForMediaPortalChannel(mpChannel);
            ChannelType channelType = mpChannel.IsTv ? ChannelType.Television : ChannelType.Radio;
            Channel     channel     = null;

            if (channelLink != null)
            {
                channel = Proxies.SchedulerService.GetChannelById(channelLink.ChannelId).Result;
                if (channel == null)
                {
                    channel = Proxies.SchedulerService.GetChannelByDisplayName(channelType, channelLink.ChannelName).Result;
                }
            }
            if (channel == null)
            {
                channel = Proxies.SchedulerService.GetChannelByDisplayName(channelType, mpChannel.DisplayName).Result;
            }
            if (channel == null &&
                (epgSyncAutoCreateChannels || epgSyncAutoCreateChannelsWithGroup))
            {
                string groupName = "DVB-EPG";
                if (epgSyncAutoCreateChannelsWithGroup)
                {
                    IList <TvDatabase.GroupMap> groupMaps = mpChannel.ReferringGroupMap();
                    foreach (TvDatabase.GroupMap groupMap in groupMaps)
                    {
                        TvDatabase.ChannelGroup channelGroup = TvDatabase.ChannelGroup.Retrieve(groupMap.IdGroup);
                        if (channelGroup != null)
                        {
                            groupName = channelGroup.GroupName;
                            break;
                        }
                    }
                }

                Guid channelId = Proxies.SchedulerService.EnsureChannel(channelType, mpChannel.DisplayName, groupName).Result;
                channel = Proxies.SchedulerService.GetChannelById(channelId).Result;

                if (!channel.LogicalChannelNumber.HasValue &&
                    mpChannel.ChannelNumber > 0)
                {
                    channel.LogicalChannelNumber = mpChannel.ChannelNumber;
                    Proxies.SchedulerService.SaveChannel(channel).Wait();
                }
            }
            return(channel);
        }
Beispiel #13
0
        public void SetLinkedMediaPortalChannelInternal(Channel channel, TvDatabase.Channel mpChannel)
        {
            EnsureLoaded();

            _readerWriterLock.EnterWriteLock();
            try
            {
                ClearLinkedMediaPortalChannel(channel);
                ChannelLink link = new ChannelLink(channel.ChannelType, channel.ChannelId, channel.DisplayName, mpChannel.IdChannel, mpChannel.DisplayName);
                _linksById.Add(link.ChannelId, link);
            }
            finally
            {
                _readerWriterLock.ExitWriteLock();
            }
        }
Beispiel #14
0
        private void events_OnTvServerEvent(object sender, EventArgs eventArgs)
        {
            TvEngine.Events.TvServerEventArgs args = eventArgs as TvEngine.Events.TvServerEventArgs;

            if (args == null)
            {
                return;
            }

            Log.Debug("TVServerKodi: OnTvServerEvent: " + args.EventType.ToString());

            if (args.EventType == TvEngine.Events.TvServerEventType.ImportEpgPrograms &&
                args.EpgChannel != null &&
                args.EpgChannel.Programs.Count > 0)
            {
                try
                {
                    if (args.channel != null)
                    {
                        Log.Info("TVServerKodi: EPG import for channel: " + args.channel.Name);
                    }

                    TvLibrary.Channels.DVBBaseChannel dvbChannel = args.EpgChannel.Channel as TvLibrary.Channels.DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.TvBusinessLayer layer     = new TvDatabase.TvBusinessLayer();
                        TvDatabase.Channel         mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("TVServerKodi: received {0} programs on {1}", args.EpgChannel.Programs.Count, mpChannel.DisplayName);
                            //foreach (TvLibrary.Epg.EpgProgram p in args.EpgChannel.Programs)
                            //{
                            //  Log.Info("TVServerKodi: program: " + p.StartTime.ToString() + "-" + p.EndTime.ToString());
                            //}
                        }
                    }
                    //ImportEpgPrograms(args.EpgChannel);
                }
                catch (Exception ex)
                {
                    Log.Error("TVServerKodi: ImportEpgPrograms(): {0}", ex.Message);
                }
            }
        }
Beispiel #15
0
 public static TvDatabase.TuningDetail FindTuningDetailOnCard(TvDatabase.Channel channel, int cardId)
 {
     try
     {
         CardType cardType = TvServerPlugin.TvController_Type(cardId);
         IList <TvDatabase.TuningDetail> tuningDetails = channel.ReferringTuningDetail();
         foreach (TvDatabase.TuningDetail tuningDetail in tuningDetails)
         {
             if (CardTunesChannelType(cardType, tuningDetail.ChannelType))
             {
                 return(tuningDetail);
             }
         }
     }
     catch
     {
     }
     return(null);
 }
Beispiel #16
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="filename">The currently playing recording</param>
        public NowPlayingRecording(string filename)
        {
            TvDatabase.Recording recording = TvDatabase.Recording.Retrieve(filename);
            if (recording != null)
            {
                recordingFound     = true;
                ChannelId          = recording.IdChannel;
                RecordingId        = recording.IdRecording;
                ProgramName        = recording.Title;
                ProgramDescription = recording.Description;
                ProgramBegin       = recording.StartTime;
                ProgramEnd         = recording.EndTime;

                TvDatabase.Channel channel = TvDatabase.Channel.Retrieve(ChannelId);
                if (channel != null)
                {
                    ChannelName = channel.DisplayName;
                }
            }
        }
Beispiel #17
0
        public static IChannel FindTuningChannelOnCard(TvDatabase.Channel channel, int cardId)
        {
            IChannel tuningChannel = null;

            try
            {
                List <IChannel> tunings = new TvDatabase.TvBusinessLayer().GetTuningChannelsByDbChannel(channel);
                foreach (IChannel tuning in tunings)
                {
                    if (TvServerPlugin.TvController_CanTune(cardId, tuning))
                    {
                        tuningChannel = tuning;
                        break;
                    }
                }
            }
            catch
            {
                tuningChannel = null;
            }
            return(tuningChannel);
        }
Beispiel #18
0
        private ChannelLink GetChannelLinkForMediaPortalChannelInternal(TvDatabase.Channel channel)
        {
            EnsureLoaded();

            _readerWriterLock.EnterReadLock();
            try
            {
                foreach (ChannelLink link in _linksById.Values)
                {
                    if (link.MPChannelId == channel.IdChannel &&
                        link.MPChannelName == channel.DisplayName)
                    {
                        return(link);
                    }
                }
                return(null);
            }
            finally
            {
                _readerWriterLock.ExitReadLock();
            }
        }
        private List <TvDatabase.Card> GetCardsForChannel(Channel channel, out TvDatabase.Channel mpChannel)
        {
            List <TvDatabase.Card> availableCards = new List <TvDatabase.Card>();

            mpChannel = GetLinkedMediaPortalChannel(channel.ChannelType, channel.ChannelId, channel.DisplayName);
            if (mpChannel != null)
            {
                //
                // Now build a list of all available cards by getting a list of all the cards that
                // have this channel mapped.
                //
                IList <TvDatabase.ChannelMap> channelCardMap = mpChannel.ReferringChannelMap();
                IList <TvDatabase.Card>       allCards       = TvDatabase.Card.ListAll();
                foreach (TvDatabase.Card card in allCards)
                {
                    if (!availableCards.Contains(card) &&
                        card.Enabled)
                    {
                        TvDatabase.ChannelMap channelMap = null;
                        foreach (TvDatabase.ChannelMap map in channelCardMap)
                        {
                            if (map.IdCard == card.IdCard &&
                                !map.EpgOnly)
                            {
                                channelMap = map;
                                break;
                            }
                        }
                        if (channelMap != null)
                        {
                            availableCards.Add(card);
                        }
                    }
                }
            }
            return(availableCards);
        }
        private bool IsCardFreeOrSharedByAllocation(TvDatabase.Card card, TvDatabase.Channel mpChannel, CardChannelAllocation allocation,
                                                    CardChannelAllocation[] alreadyAllocated)
        {
            TvDatabase.TuningDetail tuning = Utility.FindTuningDetailOnCard(mpChannel, card.IdCard);
            if (GetCardId(card) == allocation.CardId &&
                tuning != null)
            {
                //
                // The card is allocated by this allocation, but may be able to reuse the card. So let's
                // check if the if the card (and CAM) allow this.
                //
                // Note: "!ChannelAlreadyAllocatedOn(alreadyAllocated, allocation.CardId, channelId)" was
                // not added since TV Server can record the same channel several times on the same transponder.
                if (card.DecryptLimit == 0 ||
                    CountNumTimesAllocated(alreadyAllocated, allocation.CardId) < card.DecryptLimit)
                {
                    // Get the previously allocated channel and its tuning details and let's check if the
                    // channel we want is on the same transponder as that channel.
                    TvDatabase.Channel allocatedChannel = GetLinkedMediaPortalChannel(allocation.ChannelType,
                                                                                      allocation.ChannelId, allocation.ChannelName);
                    TvDatabase.Card allocatedCard = GetCardByCardId(allocation.CardId);
                    if (allocatedChannel != null &&
                        allocatedCard != null &&
                        Utility.IsSameTransponder(allocatedCard.IdCard, tuning, allocatedChannel))
                    {
                        // Same transponder, so we can actually re-use this card and consider it free.
                        return(true);
                    }
                }
                // The card is allocated by this allocation, and it's not for a channel on the same
                // transponder, so it's not free.
                return(false);
            }

            // The card is not allocated by this allocation, so it's free.
            return(true);
        }
Beispiel #21
0
        private void LoadChannelLinks(bool forceLoad)
        {
            string settingsFileName = this.SettingsFileName;

            if (!File.Exists(settingsFileName))
            {
                _readerWriterLock.EnterWriteLock();
                try
                {
                    _linksById.Clear();
                    _autoLinkedMPChannels.Clear();
                    return;
                }
                finally
                {
                    _readerWriterLock.ExitWriteLock();
                }
            }

            DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(settingsFileName);

            if (forceLoad ||
                lastWriteTimeUtc != _lastFileWriteTimeUtc)
            {
                _readerWriterLock.EnterWriteLock();
                try
                {
                    _lastFileWriteTimeUtc = lastWriteTimeUtc;
                    _linksById.Clear();
                    _autoLinkedMPChannels.Clear();
                    using (StreamReader reader = new StreamReader(settingsFileName, Encoding.UTF8))
                    {
                        XPathDocument     xpathDocument = new XPathDocument(reader);
                        XPathNavigator    navigator     = xpathDocument.CreateNavigator();
                        XPathNodeIterator iterator      = navigator.Select("/links/link");
                        while (iterator.MoveNext())
                        {
                            ChannelLink link = ChannelLink.Parse(iterator.Current);
                            if (link != null)
                            {
                                TvDatabase.Channel mpChannel = GetChannelById(link.ChannelType, link.MPChannelId);
                                if (mpChannel == null ||
                                    mpChannel.DisplayName != link.MPChannelName)
                                {
                                    bool duplicateChannelsFound;
                                    mpChannel = GetChannelByDisplayName(link.ChannelType, link.MPChannelName, out duplicateChannelsFound);
                                }
                                if (mpChannel != null)
                                {
                                    _linksById.Add(link.ChannelId, link);
                                }
                            }
                        }
                    }
                }
                finally
                {
                    _readerWriterLock.ExitWriteLock();
                }
            }
        }
Beispiel #22
0
        private void ImportEpgPrograms(EpgChannel epgChannel)
        {
            if (!this.IsArgusTVConnectionInitialized)
            {
                InitializeArgusTVConnection(null);
            }
            if (this.IsArgusTVConnectionInitialized)
            {
                TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer();
                bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value);
                if (epgSyncOn)
                {
                    DVBBaseChannel dvbChannel = epgChannel.Channel as DVBBaseChannel;
                    if (dvbChannel != null)
                    {
                        TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId);
                        if (mpChannel != null)
                        {
                            Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms(): received {0} programs on {1}", epgChannel.Programs.Count, mpChannel.DisplayName);

                            bool   epgSyncAutoCreateChannels          = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value);
                            bool   epgSyncAutoCreateChannelsWithGroup = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannelsWithGroup, false.ToString()).Value);
                            string epgLanguages = layer.GetSetting("epgLanguages").Value;

                            Channel channel = EnsureChannelForDvbEpg(mpChannel, epgSyncAutoCreateChannels, epgSyncAutoCreateChannelsWithGroup);
                            if (channel != null)
                            {
                                EnsureGuideChannelForDvbEpg(channel, mpChannel);

                                List <GuideProgram> guidePrograms = new List <GuideProgram>();

                                foreach (EpgProgram epgProgram in epgChannel.Programs)
                                {
                                    string title;
                                    string description;
                                    string genre;
                                    int    starRating;
                                    string classification;
                                    int    parentalRating;
                                    GetProgramInfoForLanguage(epgProgram.Text, epgLanguages, out title, out description, out genre,
                                                              out starRating, out classification, out parentalRating);

                                    if (!String.IsNullOrEmpty(title))
                                    {
                                        GuideProgram guideProgram = new GuideProgram();
                                        guideProgram.GuideChannelId = channel.GuideChannelId.Value;
                                        guideProgram.StartTime      = epgProgram.StartTime;
                                        guideProgram.StopTime       = epgProgram.EndTime;
                                        guideProgram.StartTimeUtc   = epgProgram.StartTime.ToUniversalTime();
                                        guideProgram.StopTime       = epgProgram.EndTime;
                                        guideProgram.StopTimeUtc    = epgProgram.EndTime.ToUniversalTime();
                                        guideProgram.Title          = title;
                                        guideProgram.Description    = description;
                                        guideProgram.Category       = genre;
                                        guideProgram.Rating         = classification;
                                        guideProgram.StarRating     = starRating / 7.0;
                                        guidePrograms.Add(guideProgram);
                                    }
                                }

                                _dvbEpgThread.ImportProgramsAsync(guidePrograms);
                            }
                            else
                            {
                                Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to ensure channel.");
                            }
                        }
                        else
                        {
                            Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to find MP channel.");
                        }
                    }
                }
            }
        }
Beispiel #23
0
 public static bool IsSameTransponder(int cardId, TvDatabase.TuningDetail tuning, TvDatabase.Channel otherChannel)
 {
     TvDatabase.TuningDetail otherTuning = Utility.FindTuningDetailOnCard(otherChannel, cardId);
     if (tuning != null &&
         otherTuning != null)
     {
         if (tuning.ChannelType >= 2 && tuning.ChannelType <= 4 && // DVB-x channel? ,no Atsc(==1)
             tuning.ChannelType == otherTuning.ChannelType &&
             tuning.Frequency == otherTuning.Frequency &&
             tuning.Symbolrate == otherTuning.Symbolrate &&
             tuning.Polarisation == otherTuning.Polarisation &&
             tuning.Bandwidth == otherTuning.Bandwidth &&
             tuning.Modulation == otherTuning.Modulation)
         {
             return(true);
         }
         if (tuning.ChannelType == 0 && // Analog
             tuning.ChannelType == otherTuning.ChannelType &&
             tuning.IdChannel == otherTuning.IdChannel)
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #24
0
 public ChannelItem(TvDatabase.Channel channel)
 {
     _channel = channel;
 }
Beispiel #25
0
        /// <summary>
        /// Get all channels in a group, sorted by display name.
        /// </summary>
        /// <param name="channelType">The type of channels in the group.</param>
        /// <param name="groupId">The group ID or -1 for all channels.</param>
        /// <returns>A list containing zero or more channels.</returns>
        public static List <TvDatabase.Channel> GetAllChannelsInGroup(ChannelType channelType, int groupId)
        {
            List <TvDatabase.Channel> channels = new List <TvDatabase.Channel>();

            if (groupId < 0)
            {
                SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.Channel));
                if (channelType == ChannelType.Television)
                {
                    sb.AddConstraint(Operator.Equals, "isTv", true);
                }
                else
                {
                    sb.AddConstraint(Operator.Equals, "isRadio", true);
                }
                sb.AddConstraint(Operator.Equals, "visibleInGuide", true);
                sb.AddOrderByField("displayName");
                SqlResult result = Broker.Execute(sb.GetStatement());
                channels = (List <TvDatabase.Channel>)
                           ObjectFactory.GetCollection(typeof(TvDatabase.Channel), result, new List <TvDatabase.Channel>());
            }
            else
            {
                if (channelType == ChannelType.Television)
                {
                    SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.GroupMap));
                    sb.AddConstraint(Operator.Equals, "idGroup", groupId);
                    SqlResult result = Broker.Execute(sb.GetStatement());
                    List <TvDatabase.GroupMap> groupMaps = (List <TvDatabase.GroupMap>)
                                                           ObjectFactory.GetCollection(typeof(TvDatabase.GroupMap), result, new List <TvDatabase.GroupMap>());
                    foreach (TvDatabase.GroupMap groupMap in groupMaps)
                    {
                        TvDatabase.Channel mpChannel = groupMap.ReferencedChannel();
                        if (mpChannel.IsTv)
                        {
                            channels.Add(mpChannel);
                        }
                    }
                }
                else
                {
                    SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(TvDatabase.RadioGroupMap));
                    sb.AddConstraint(Operator.Equals, "idGroup", groupId);
                    SqlResult result = Broker.Execute(sb.GetStatement());
                    List <TvDatabase.RadioGroupMap> groupMaps = (List <TvDatabase.RadioGroupMap>)
                                                                ObjectFactory.GetCollection(typeof(TvDatabase.RadioGroupMap), result, new List <TvDatabase.RadioGroupMap>());
                    foreach (TvDatabase.RadioGroupMap groupMap in groupMaps)
                    {
                        TvDatabase.Channel mpChannel = groupMap.ReferencedChannel();
                        if (mpChannel.IsRadio)
                        {
                            channels.Add(mpChannel);
                        }
                    }
                }
                channels.Sort(
                    delegate(TvDatabase.Channel c1, TvDatabase.Channel c2) { return(c1.DisplayName.CompareTo(c2.DisplayName)); });
            }

            return(channels);
        }
Beispiel #26
0
 public static bool IsAutoLinked(TvDatabase.Channel mpChannel)
 {
     return(Instance.IsAutoLinkedInternal(mpChannel));
 }
        private LiveStreamResult StartTimeShifting(Channel channel, TvDatabase.Card card, TvDatabase.Channel mpChannel,
                                                   ref IUser tve3User, ref LiveStream liveStream)
        {
            IChannel tuningChannel = Utility.FindTuningChannelOnCard(mpChannel, card.IdCard);

            if (tuningChannel != null)
            {
                if (TvServerPlugin.TvController_Tune(ref tve3User, tuningChannel, mpChannel.IdChannel) == TvResult.Succeeded)
                {
                    string timeshiftFileName = Path.Combine(card.TimeShiftFolder,
                                                            String.Format(CultureInfo.InvariantCulture, @"live{0}-{1}", tve3User.CardId, tve3User.SubChannel));

                    switch (TvServerPlugin.TvController_StartTimeShifting(ref tve3User, ref timeshiftFileName))
                    {
                    case TvResult.Succeeded:
                        if (liveStream == null)
                        {
                            string rtspUrl      = TvServerPlugin.TvController_GetStreamingUrl(tve3User);
                            string tsBufferFile = GetTsBufferFile(tve3User);
                            liveStream = new LiveStream(channel, rtspUrl);
                            liveStream.TimeshiftFile = tsBufferFile;
#if USE_ARGUS_RTSP
                            string rtspUrlSuffix = String.Format(_rtspUrlSuffixFormat, tve3User.CardId, tve3User.SubChannel);
                            liveStream.RtspUrl = StartRtspStream(tsBufferFile, rtspUrlSuffix);
#endif
                        }
                        liveStream.Channel = channel;
                        liveStream.CardId  = tve3User.CardId.ToString(CultureInfo.InvariantCulture);
                        liveStream.StreamLastAliveTimeUtc = DateTime.UtcNow;
                        lock (_liveStreamsLock)
                        {
                            _liveStreams[liveStream.RtspUrl]     = liveStream;
                            _liveStreamUsers[liveStream.RtspUrl] = tve3User;
                        }
                        return(LiveStreamResult.Succeeded);

                    case TvResult.AllCardsBusy:
                        return(LiveStreamResult.NoFreeCardFound);

                    case TvResult.ChannelIsScrambled:
                        return(LiveStreamResult.IsScrambled);

                    case TvResult.ChannelNotMappedToAnyCard:
                    case TvResult.NoSignalDetected:
                    case TvResult.NoTuningDetails:
                    case TvResult.NoVideoAudioDetected:
                    case TvResult.UnknownChannel:
                        return(LiveStreamResult.ChannelTuneFailed);

                    default:
                        return(LiveStreamResult.UnknownError);
                    }
                }
                else
                {
                    Log(TraceEventType.Error, "StartTimeShifting(): failed to tune to {0}", tuningChannel.Name);
                    return(LiveStreamResult.ChannelTuneFailed);
                }
            }
            else
            {
                Log(TraceEventType.Error, "StartTimeShifting(): no tuning channel found for {0}", mpChannel.DisplayName);
                return(LiveStreamResult.ChannelTuneFailed);
            }
        }
 public ChannelItem(TvDatabase.Channel channel)
 {
     _channel = channel;
 }
Beispiel #29
0
 public static void SetLinkedMediaPortalChannel(Channel channel, TvDatabase.Channel mpChannel)
 {
     Instance.SetLinkedMediaPortalChannelInternal(channel, mpChannel);
 }
Beispiel #30
0
 public static ChannelLink GetChannelLinkForMediaPortalChannel(TvDatabase.Channel channel)
 {
     return(Instance.GetChannelLinkForMediaPortalChannelInternal(channel));
 }
 private static void EnsureGuideChannelForDvbEpg(SchedulerServiceAgent tvSchedulerAgent, GuideServiceAgent tvGuideAgent, Channel channel, TvDatabase.Channel mpChannel)
 {
     if (!channel.GuideChannelId.HasValue)
     {
         string externalId = mpChannel.ExternalId;
         if (String.IsNullOrEmpty(externalId))
         {
             externalId = mpChannel.DisplayName;
         }
         channel.GuideChannelId = tvGuideAgent.EnsureChannel(externalId, mpChannel.DisplayName, channel.ChannelType);
         tvSchedulerAgent.AttachChannelToGuide(channel.ChannelId, channel.GuideChannelId.Value);
     }
 }
Beispiel #32
0
 public static bool CardFreeOrUsingSameTransponder(TvDatabase.Card card, TvDatabase.Channel channel)
 {
     return(CardFreeOrUsingSameTransponder(card, channel, null));
 }