/// <summary> /// Prüft, ob eine Aufzeichnung läuft oder in Kürze beginnt. /// </summary> public override void KeepAlive() { // Read results var activities = (m_allActivities ?? Enumerable.Empty <VCRNETRestProxy.Current>()).Where(activity => ProfileManager.ProfileNameComparer.Equals(activity.device, Profile)).ToArray(); var running = activities.Where(activity => activity.IsActive).ToArray(); var gotResult = m_allActivitiesValid; // Prepare for next call m_allActivities = null; m_allActivitiesValid = false; // See if result is available if (gotResult) { if (running.Length > 0) { ValidateActiveRecording(running); } else if (activities.Length > 0) { ValidateIdle(activities[0]); } else { Adaptor.StartLIVE(); } } else { VCRNETRestProxy.GetActivities(Adaptor.EndPoint, ReceiveCurrentRecording, null); } }
/// <summary> /// Prüft die Liste der aktiven Aufzeichnungen. /// </summary> /// <param name="activities">Eine nicht leere Liste von aktiven Auzeichnungen.</param> private void ValidateActiveRecording(VCRNETRestProxy.Current[] activities) { // Check for special operations var first = activities[0]; var current = m_CurrentSource; // See if there is a task running if (first.streamIndex < 0) { ShowMessage(Properties.Resources.CurrentUntil, Properties.Resources.Warning_NotAvailable, false, first.source, first.EndsAt.ToLocalTime()); } // See if we have no current source else if (current == null) { // Start watching Adaptor.StartWatch(null); // Done return; } // Check for current stream else { // Set if we are connected var newCurrent = activities.First(activity => activity.referenceId.Value == current.Activity.referenceId.Value); if (newCurrent != null) { if (string.IsNullOrEmpty(newCurrent.streamTarget)) { // Start watching Adaptor.StartWatch(null); // Done return; } } } // Restart request VCRNETRestProxy.GetActivities(Adaptor.EndPoint, ReceiveCurrentRecording, null); }
/// <summary> /// Prüft, ob in den LIVE Modus gewechselt werden kann. /// </summary> /// <param name="next">Die als nächstens anstehende Aktivität.</param> private void ValidateIdle(VCRNETRestProxy.Current next) { // Get the next recording if (next.start.HasValue) { // When will it start var delta = next.start.Value - DateTime.UtcNow; if (delta.TotalMinutes <= 3) { // Report ShowMessage(Properties.Resources.NextRecording, Properties.Resources.Warning_NotAvailable, false, (int)delta.TotalSeconds); // Restart request VCRNETRestProxy.GetActivities(Adaptor.EndPoint, ReceiveCurrentRecording, null); // Done return; } } // Can use LIVE Adaptor.StartLIVE(); }