Explorar o código

added HasUpdateAvailable

Luke Pulverenti %!s(int64=11) %!d(string=hai) anos
pai
achega
a01ee815fb

+ 17 - 1
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -864,7 +864,7 @@ namespace MediaBrowser.Api.Playback
         /// </summary>
         /// <param name="process">The process.</param>
         /// <param name="state">The state.</param>
-        protected void OnFfMpegProcessExited(Process process, StreamState state)
+        protected async void OnFfMpegProcessExited(Process process, StreamState state)
         {
             if (state.IsoMount != null)
             {
@@ -889,6 +889,18 @@ namespace MediaBrowser.Api.Playback
             {
                 Logger.Info("FFMpeg exited with an error for {0}", outputFilePath);
             }
+
+            if (!string.IsNullOrEmpty(state.LiveTvStreamId))
+            {
+                try
+                {
+                    await LiveTvManager.CloseLiveStream(state.LiveTvStreamId, CancellationToken.None).ConfigureAwait(false);
+                }
+                catch (Exception ex)
+                {
+                    Logger.ErrorException("Error closing live tv stream", ex);
+                }
+            }
         }
 
         /// <summary>
@@ -936,6 +948,8 @@ namespace MediaBrowser.Api.Playback
                 {
                     var streamInfo = await LiveTvManager.GetRecordingStream(request.Id, cancellationToken).ConfigureAwait(false);
 
+                    state.LiveTvStreamId = streamInfo.Id;
+
                     if (!string.IsNullOrEmpty(streamInfo.Path) && File.Exists(streamInfo.Path))
                     {
                         state.MediaPath = streamInfo.Path;
@@ -961,6 +975,8 @@ namespace MediaBrowser.Api.Playback
 
                 var streamInfo = await LiveTvManager.GetChannelStream(request.Id, cancellationToken).ConfigureAwait(false);
 
+                state.LiveTvStreamId = streamInfo.Id;
+
                 if (!string.IsNullOrEmpty(streamInfo.Path) && File.Exists(streamInfo.Path))
                 {
                     state.MediaPath = streamInfo.Path;

+ 2 - 0
MediaBrowser.Api/Playback/StreamState.cs

@@ -52,5 +52,7 @@ namespace MediaBrowser.Api.Playback
         public bool SendInputOverStandardInput { get; set; }
 
         public CancellationTokenSource StandardInputCancellationTokenSource { get; set; }
+
+        public string LiveTvStreamId { get; set; }
     }
 }

+ 8 - 0
MediaBrowser.Controller/LiveTv/ILiveTvManager.cs

@@ -227,5 +227,13 @@ namespace MediaBrowser.Controller.LiveTv
         /// <param name="cancellationToken">The cancellation token.</param>
         /// <returns>Task{QueryResult{RecordingGroupDto}}.</returns>
         Task<QueryResult<RecordingGroupDto>> GetRecordingGroups(RecordingGroupQuery query, CancellationToken cancellationToken);
+
+        /// <summary>
+        /// Closes the live stream.
+        /// </summary>
+        /// <param name="id">The identifier.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task.</returns>
+        Task CloseLiveStream(string id, CancellationToken cancellationToken);
     }
 }

+ 6 - 0
MediaBrowser.Model/System/SystemInfo.cs

@@ -122,6 +122,12 @@ namespace MediaBrowser.Model.System
         /// <value>The wan address.</value>
         public string WanAddress { get; set; }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether this instance has update available.
+        /// </summary>
+        /// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>
+        public bool HasUpdateAvailable { get; set; }
+
         /// <summary>
         /// Initializes a new instance of the <see cref="SystemInfo" /> class.
         /// </summary>

+ 5 - 0
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -945,5 +945,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 TotalRecordCount = groups.Count
             };
         }
+
+        public Task CloseLiveStream(string id, CancellationToken cancellationToken)
+        {
+            return ActiveService.CloseLiveStream(id, cancellationToken);
+        }
     }
 }

+ 8 - 2
MediaBrowser.ServerApplication/ApplicationHost.cs

@@ -293,7 +293,7 @@ namespace MediaBrowser.ServerApplication
             await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
             progress.Report(100);
 
-            await ((UserManager) UserManager).Initialize().ConfigureAwait(false);
+            await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
 
             SetKernelProperties();
         }
@@ -628,7 +628,8 @@ namespace MediaBrowser.ServerApplication
                 OperatingSystem = Environment.OSVersion.ToString(),
                 CanSelfRestart = CanSelfRestart,
                 CanSelfUpdate = CanSelfUpdate,
-                WanAddress = GetWanAddress()
+                WanAddress = GetWanAddress(),
+                HasUpdateAvailable = _hasUpdateAvailable
             };
         }
 
@@ -699,6 +700,7 @@ namespace MediaBrowser.ServerApplication
             }
         }
 
+        private bool _hasUpdateAvailable;
         /// <summary>
         /// Checks for update.
         /// </summary>
@@ -712,6 +714,8 @@ namespace MediaBrowser.ServerApplication
             var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion,
                                                            ConfigurationManager.CommonConfiguration.SystemUpdateLevel);
 
+            _hasUpdateAvailable = version != null;
+
             return version != null ? new CheckForUpdateResult { AvailableVersion = version.version, IsUpdateAvailable = version.version > ApplicationVersion, Package = version } :
                        new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
         }
@@ -727,6 +731,8 @@ namespace MediaBrowser.ServerApplication
         {
             await InstallationManager.InstallPackage(package, progress, cancellationToken).ConfigureAwait(false);
 
+            _hasUpdateAvailable = false;
+
             OnApplicationUpdated(package.version);
         }