The Free Software Media System - Server Backend & API
safer hls kill
Luke Pulverenti16fd474ad3e7
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.csindex b648e7fd38..343672877a 100644--- a/MediaBrowser.Api/ApiEntryPoint.cs+++ b/MediaBrowser.Api/ApiEntryPoint.cs@@ -85,7 +85,8 @@ namespace MediaBrowser.Api/// <param name="isVideo">if set to <c>true</c> [is video].</param>/// <param name="startTimeTicks">The start time ticks.</param>/// <param name="sourcePath">The source path.</param>- public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process, bool isVideo, long? startTimeTicks, string sourcePath)+ /// <param name="deviceId">The device id.</param>+ public void OnTranscodeBeginning(string path, TranscodingJobType type, Process process, bool isVideo, long? startTimeTicks, string sourcePath, string deviceId){lock (_activeTranscodingJobs){@@ -97,7 +98,8 @@ namespace MediaBrowser.ApiActiveRequestCount = 1,IsVideo = isVideo,StartTimeTicks = startTimeTicks,- SourcePath = sourcePath+ SourcePath = sourcePath,+ DeviceId = deviceId});}}@@ -180,7 +182,7 @@ namespace MediaBrowser.Apiif (job.ActiveRequestCount == 0){- var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 180000;+ var timerDuration = type == TranscodingJobType.Progressive ? 1000 : 120000;if (job.KillTimer == null){@@ -208,12 +210,14 @@ namespace MediaBrowser.Api/// <summary>/// Kills the single transcoding job./// </summary>- /// <param name="sourcePath">The source path.</param>- internal void KillSingleTranscodingJob(string sourcePath)+ /// <param name="deviceId">The device id.</param>+ /// <param name="isVideo">if set to <c>true</c> [is video].</param>+ /// <exception cref="System.ArgumentNullException">sourcePath</exception>+ internal void KillTranscodingJobs(string deviceId, bool isVideo){- if (string.IsNullOrEmpty(sourcePath))+ if (string.IsNullOrEmpty(deviceId)){- throw new ArgumentNullException("sourcePath");+ throw new ArgumentNullException("deviceId");}var jobs = new List<TranscodingJob>();@@ -222,14 +226,12 @@ namespace MediaBrowser.Api{// This is really only needed for HLS.// Progressive streams can stop on their own reliably- jobs.AddRange(_activeTranscodingJobs.Where(i => string.Equals(sourcePath, i.SourcePath) && i.Type == TranscodingJobType.Hls));+ jobs.AddRange(_activeTranscodingJobs.Where(i => isVideo == i.IsVideo && string.Equals(deviceId, i.DeviceId, StringComparison.OrdinalIgnoreCase)));}- // This method of killing is a bit of a shortcut, but it saves clients from having to send a request just for that- // But we can only kill if there's one active job. If there are more we won't know which one to stop- if (jobs.Count == 1)+ foreach (var job in jobs){- KillTranscodingJob(jobs.First());+ KillTranscodingJob(job);}}@@ -405,6 +407,7 @@ namespace MediaBrowser.Apipublic bool IsVideo { get; set; }public long? StartTimeTicks { get; set; }public string SourcePath { get; set; }+ public string DeviceId { get; set; }}/// <summary>diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.csindex f3164ad69a..1772cc5471 100644--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs@@ -624,7 +624,7 @@ namespace MediaBrowser.Api.PlaybackEnableRaisingEvents = true};- ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath, TranscodingJobType, process, video != null, state.Request.StartTimeTicks, state.Item.Path);+ ApiEntryPoint.Instance.OnTranscodeBeginning(outputPath, TranscodingJobType, process, video != null, state.Request.StartTimeTicks, state.Item.Path, state.Request.DeviceId);Logger.Info(process.StartInfo.FileName + " " + process.StartInfo.Arguments);diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.csindex f1fa86f780..be7aadec09 100644--- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs+++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs@@ -66,6 +66,14 @@ namespace MediaBrowser.Api.Playback.Hlspublic string PlaylistId { get; set; }}+ [Route("/Videos", "DELETE")]+ [Api(Description = "Stops an encoding process")]+ public class StopEncodingProcess+ {+ [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "DELETE")]+ public string DeviceId { get; set; }+ }+public class HlsSegmentService : BaseApiService{private readonly IServerApplicationPaths _appPaths;@@ -86,6 +94,11 @@ namespace MediaBrowser.Api.Playback.Hlsreturn ResultFactory.GetStaticFileResult(RequestContext, file, FileShare.ReadWrite);}+ public void Delete(StopEncodingProcess request)+ {+ ApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, true);+ }+/// <summary>/// Gets the specified request./// </summary>diff --git a/MediaBrowser.Api/Playback/StreamRequest.cs b/MediaBrowser.Api/Playback/StreamRequest.csindex 07f9d31e94..339de0e6c6 100644--- a/MediaBrowser.Api/Playback/StreamRequest.cs+++ b/MediaBrowser.Api/Playback/StreamRequest.cs@@ -15,6 +15,9 @@ namespace MediaBrowser.Api.Playback[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]public string Id { get; set; }+ [ApiMember(Name = "DeviceId", Description = "The device id of the client requesting. Used to stop encoding processes when needed.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]+ public string DeviceId { get; set; }+/// <summary>/// Gets or sets the audio codec./// </summary>diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.csindex b588e4a852..f4976bba30 100644--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs@@ -5,7 +5,6 @@ using MediaBrowser.Controller.Entities.Movies;using MediaBrowser.Controller.Entities.TV;using MediaBrowser.Controller.Library;using MediaBrowser.Controller.Localization;-using MediaBrowser.Controller.Persistence;using MediaBrowser.Model.Entities;using MediaBrowser.Model.Querying;using ServiceStack.ServiceHost;diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.csindex efb1d5d43f..a43ed276df 100644--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs@@ -721,9 +721,6 @@ namespace MediaBrowser.Api.UserLibraryvar item = _dtoService.GetItemByDtoId(request.Id, user.Id);- // Kill the encoding- ApiEntryPoint.Instance.KillSingleTranscodingJob(item.Path);-var session = GetSession();var info = new PlaybackStopInfodiff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.csindex 8b8e81e8a9..e202585209 100644--- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs+++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs@@ -384,7 +384,7 @@ namespace MediaBrowser.Common.Implementations/// </summary>/// <param name="type">The type.</param>/// <returns>System.Object.</returns>- protected object CreateInstance(Type type)+ public object CreateInstance(Type type){try{diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.csindex c634871fab..177df5afaa 100644--- a/MediaBrowser.Common/IApplicationHost.cs+++ b/MediaBrowser.Common/IApplicationHost.cs@@ -125,5 +125,12 @@ namespace MediaBrowser.Common/// </summary>/// <returns>Task.</returns>Task Init();++ /// <summary>+ /// Creates the instance.+ /// </summary>+ /// <param name="type">The type.</param>+ /// <returns>System.Object.</returns>+ object CreateInstance(Type type);}}diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.csindex caf332a5b6..e900dd77e9 100644--- a/MediaBrowser.Controller/Entities/Video.cs+++ b/MediaBrowser.Controller/Entities/Video.cs@@ -136,10 +136,7 @@ namespace MediaBrowser.Controller.Entitiesget { return Video3DFormat.HasValue; }}- public bool IsHD- {- get { return MediaStreams != null && MediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1280); }- }+ public bool IsHD { get; set; }/// <summary>/// Gets the type of the media.diff --git a/MediaBrowser.Model/Dto/StreamOptions.cs b/MediaBrowser.Model/Dto/StreamOptions.csindex 0cf59183df..17fd06cb6a 100644--- a/MediaBrowser.Model/Dto/StreamOptions.cs+++ b/MediaBrowser.Model/Dto/StreamOptions.cs@@ -151,6 +151,12 @@/// </summary>/// <value>The output file extension.</value>public string OutputFileExtension { get; set; }++ /// <summary>+ /// Gets or sets the device id.+ /// </summary>+ /// <value>The device id.</value>+ public string DeviceId { get; set; }}/// <summary>diff --git a/MediaBrowser.Providers/Games/GameProviderFromXml.cs b/MediaBrowser.Providers/Games/GameProviderFromXml.csindex 5e498c578d..f982e56586 100644--- a/MediaBrowser.Providers/Games/GameProviderFromXml.cs+++ b/MediaBrowser.Providers/Games/GameProviderFromXml.cs@@ -92,7 +92,7 @@ namespace MediaBrowser.Providers.Games/// </summary>public override MetadataProviderPriority Priority{- get { return MetadataProviderPriority.First; }+ get { return MetadataProviderPriority.Second; }}}}\ No newline at end of filediff --git a/MediaBrowser.Providers/Games/GameSystemProviderFromXml.cs b/MediaBrowser.Providers/Games/GameSystemProviderFromXml.csindex ed76d08424..526170db54 100644--- a/MediaBrowser.Providers/Games/GameSystemProviderFromXml.cs+++ b/MediaBrowser.Providers/Games/GameSystemProviderFromXml.cs@@ -37,7 +37,7 @@ namespace MediaBrowser.Providers.Games/// <value>The priority.</value>public override MetadataProviderPriority Priority{- get { return MetadataProviderPriority.First; }+ get { return MetadataProviderPriority.Second; }}private const string XmlFileName = "gamesystem.xml";diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.csindex 727768b9f7..4fb65a764d 100644--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs@@ -323,6 +323,8 @@ namespace MediaBrowser.Providers.MediaInfoFetchWtvInfo(video, force, data);+ video.IsHD = video.MediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1270);+if (chapters.Count == 0 && video.MediaStreams.Any(i => i.Type == MediaStreamType.Video)){AddDummyChapters(video, chapters);diff --git a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.csindex 9f3d26e24b..88def28db3 100644--- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs+++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs@@ -21,7 +21,7 @@ namespace MediaBrowser.ServerApplication.FFMpegprivate readonly ILogger _logger;private readonly IZipClient _zipClient;- private const string Version = "ffmpeg20130904";+ private const string Version = "ffmpeg20130904.1";private readonly string[] _fontUrls = new[]{diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspecindex 18187392a0..6714bb59e1 100644--- a/Nuget/MediaBrowser.Common.Internal.nuspec+++ b/Nuget/MediaBrowser.Common.Internal.nuspec@@ -2,7 +2,7 @@<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"><metadata><id>MediaBrowser.Common.Internal</id>- <version>3.0.216</version>+ <version>3.0.217</version><title>MediaBrowser.Common.Internal</title><authors>Luke</authors><owners>ebr,Luke,scottisafool</owners>@@ -12,7 +12,7 @@<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description><copyright>Copyright © Media Browser 2013</copyright><dependencies>- <dependency id="MediaBrowser.Common" version="3.0.216" />+ <dependency id="MediaBrowser.Common" version="3.0.217" /><dependency id="NLog" version="2.0.1.2" /><dependency id="ServiceStack.Text" version="3.9.58" /><dependency id="SimpleInjector" version="2.3.2" />diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspecindex a9cc361a99..814a4cd7ee 100644--- a/Nuget/MediaBrowser.Common.nuspec+++ b/Nuget/MediaBrowser.Common.nuspec@@ -2,7 +2,7 @@<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"><metadata><id>MediaBrowser.Common</id>- <version>3.0.216</version>+ <version>3.0.217</version><title>MediaBrowser.Common</title><authors>Media Browser Team</authors><owners>ebr,Luke,scottisafool</owners>diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspecindex 56e9222d4e..8949054475 100644--- a/Nuget/MediaBrowser.Server.Core.nuspec+++ b/Nuget/MediaBrowser.Server.Core.nuspec@@ -2,7 +2,7 @@<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"><metadata><id>MediaBrowser.Server.Core</id>- <version>3.0.216</version>+ <version>3.0.217</version><title>Media Browser.Server.Core</title><authors>Media Browser Team</authors><owners>ebr,Luke,scottisafool</owners>@@ -12,7 +12,7 @@<description>Contains core components required to build plugins for Media Browser Server.</description><copyright>Copyright © Media Browser 2013</copyright><dependencies>- <dependency id="MediaBrowser.Common" version="3.0.216" />+ <dependency id="MediaBrowser.Common" version="3.0.217" /></dependencies></metadata><files>