The Free Software Media System - Server Backend & API
added HasUpdateAvailable
Luke Pulverentia01ee815fbd4
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex 1ce7d2db33..f6872acd23 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/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.Playbackvar 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;diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.csindex f705b5e335..bf584c3852 100644--- a/MediaBrowser.Api/Playback/StreamState.cs+++ b/MediaBrowser.Api/Playback/StreamState.cs@@ -52,5 +52,7 @@ namespace MediaBrowser.Api.Playbackpublic bool SendInputOverStandardInput { get; set; }public CancellationTokenSource StandardInputCancellationTokenSource { get; set; }++ public string LiveTvStreamId { get; set; }}}diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex b7acb07359..ceca14f5bf 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/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);}}diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.csindex d475517dc6..733c9b6e5c 100644--- a/MediaBrowser.Model/System/SystemInfo.cs+++ b/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>diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 96c4249570..131c5c0fbe 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs@@ -945,5 +945,10 @@ namespace MediaBrowser.Server.Implementations.LiveTvTotalRecordCount = groups.Count};}++ public Task CloseLiveStream(string id, CancellationToken cancellationToken)+ {+ return ActiveService.CloseLiveStream(id, cancellationToken);+ }}}diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex c703cf18ed..0e66f2caf9 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -293,7 +293,7 @@ namespace MediaBrowser.ServerApplicationawait 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.ServerApplicationOperatingSystem = 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.ServerApplicationvar 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);}