TvController_StopTimeShifting() public static method

public static TvController_StopTimeShifting ( IUser &user ) : bool
user IUser
return bool
        public override void StopLiveStream(LiveStream liveStream)
        {
            lock (_liveStreamsLock)
            {
                try
                {
                    if (_liveStreams.ContainsKey(liveStream.RtspUrl))
                    {
                        IUser tve3User = _liveStreamUsers[liveStream.RtspUrl];

#if USE_ARGUS_RTSP
                        StopRtspStream(liveStream);
#endif

                        if (TvServerPlugin.TvController_IsTimeShifting(ref tve3User))
                        {
                            if (!TvServerPlugin.TvController_StopTimeShifting(ref tve3User))
                            {
                                Log(TraceEventType.Error, "Failed to stop live stream '{0}'", liveStream.RtspUrl);
                            }
                        }
                        _liveStreams.Remove(liveStream.RtspUrl);
                        _liveStreamUsers.Remove(liveStream.RtspUrl);
                    }
                    CleanUpTimeshiftingFiles(liveStream.TimeshiftFile);
                }
                catch (Exception ex)
                {
                    Log(TraceEventType.Error, ex.Message);
                }
            }
        }
 private bool EnsureCardFree(bool allowOtherArgusUser, ref string errorMessage, out bool argusIsRecordingOnCard)
 {
     argusIsRecordingOnCard = false;
     IUser[] cardUsers = TvServerPlugin.TvController_GetUsersForCard(_recordOnCard.IdCard);
     if (cardUsers != null)
     {
         TvDatabase.TuningDetail tuning = Utility.FindTuningDetailOnCard(_channel, _recordOnCard.IdCard);
         foreach (IUser cardUser in cardUsers)
         {
             if (!cardUser.Name.Equals("epg", StringComparison.InvariantCultureIgnoreCase))
             {
                 if (cardUser.Name.StartsWith("ArgusTV"))
                 {
                     if (!allowOtherArgusUser &&
                         !Utility.IsSameTransponder(_recordOnCard.IdCard, tuning, cardUser.IdChannel))
                     {
                         // Seems another ARGUS TV user is using this card, but on a different
                         // transponder!  Normally this should never happen, but in rare conditions
                         // we need to be able to handle this.
                         errorMessage           = "Card is in use by previous recording";
                         argusIsRecordingOnCard = true;
                         return(false);
                     }
                 }
                 else
                 {
                     IUser tmpUser = cardUser;
                     if (TvServerPlugin.TvController_IsRecording(ref tmpUser))
                     {
                         if (!TvServerPlugin.TvController_StopRecording(ref tmpUser))
                         {
                             errorMessage = "Failed to stop recording on channel " + _channel.DisplayName;
                             return(false);
                         }
                     }
                     else if (TvServerPlugin.TvController_IsTimeShifting(ref tmpUser))
                     {
                         if (!Utility.IsSameTransponder(_recordOnCard.IdCard, tuning, tmpUser.IdChannel))
                         {
                             if (!TvServerPlugin.TvController_StopTimeShifting(ref tmpUser, TvStoppedReason.RecordingStarted))
                             {
                                 errorMessage = "Failed to stop timeshifting on channel " + _channel.DisplayName;
                                 return(false);
                             }
                         }
                     }
                 }
             }
         }
     }
     return(true);
 }
        public override LiveStream[] GetLiveStreams()
        {
            List <LiveStream> liveStreams = new List <LiveStream>();

            lock (_liveStreamsLock)
            {
                try
                {
                    // Get cards in reverse priority.
                    List <TvDatabase.Card> cards = Utility.GetAllCards();
                    cards.Sort(delegate(TvDatabase.Card c1, TvDatabase.Card c2) { return(-c1.Priority.CompareTo(c2.Priority)); });

                    // Get the list of live streams from TV Server
                    Dictionary <string, IUser> mpStreamUsers = new Dictionary <string, IUser>();
                    foreach (TvDatabase.Card card in cards)
                    {
                        IUser[] cardUsers = TvServerPlugin.TvController_GetUsersForCard(card.IdCard);
                        if (cardUsers != null)
                        {
                            foreach (IUser user in cardUsers)
                            {
                                if (user.Name.StartsWith(_argusLiveUserName))
                                {
                                    IUser tve3User = user;
                                    if (TvServerPlugin.TvController_IsTimeShifting(ref tve3User))
                                    {
                                        mpStreamUsers.Add(TvServerPlugin.TvController_GetStreamingUrl(tve3User), tve3User);
                                    }
                                }
                            }
                        }
                    }

                    // Now loop our own list and check if all those streams are indeed still up.
                    List <string> keysToRemove = new List <string>();

                    foreach (LiveStream stream in _liveStreams.Values)
                    {
                        if (mpStreamUsers.ContainsKey(stream.RtspUrl))
                        {
                            liveStreams.Add(stream);
                        }
                        else
                        {
                            keysToRemove.Add(stream.RtspUrl);
                        }
                    }

                    // Remove streams that no longer exist.
                    foreach (string keyToRemove in keysToRemove)
                    {
                        _liveStreams.Remove(keyToRemove);
                        _liveStreamUsers.Remove(keyToRemove);
                    }

                    // Check if there are any live streams within MP that we don't know about.
                    // If so, stop those streams (they may be left-overs from client crashes).
                    foreach (string rtspUrl in mpStreamUsers.Keys)
                    {
                        if (!_liveStreams.ContainsKey(rtspUrl))
                        {
                            IUser tve3User = mpStreamUsers[rtspUrl];
                            TvServerPlugin.TvController_StopTimeShifting(ref tve3User, TvStoppedReason.KickedByAdmin);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log(TraceEventType.Error, ex.Message);
                }
            }
            return(liveStreams.ToArray());
        }