aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-03 10:14:40 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-10-03 10:14:40 -0400
commit16fd474ad3e7d74cd78779350d2ee0ea7017f627 (patch)
treedfd6012a22f5410e34410773ea164a2b578e9468
parenteb72c2db513f5306eecccb94f0f1cd5296a7d7db (diff)
safer hls kill
-rw-r--r--MediaBrowser.Api/ApiEntryPoint.cs27
-rw-r--r--MediaBrowser.Api/Playback/BaseStreamingService.cs2
-rw-r--r--MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs13
-rw-r--r--MediaBrowser.Api/Playback/StreamRequest.cs3
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs1
-rw-r--r--MediaBrowser.Api/UserLibrary/UserLibraryService.cs3
-rw-r--r--MediaBrowser.Common.Implementations/BaseApplicationHost.cs2
-rw-r--r--MediaBrowser.Common/IApplicationHost.cs7
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs5
-rw-r--r--MediaBrowser.Model/Dto/StreamOptions.cs6
-rw-r--r--MediaBrowser.Providers/Games/GameProviderFromXml.cs2
-rw-r--r--MediaBrowser.Providers/Games/GameSystemProviderFromXml.cs2
-rw-r--r--MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs2
-rw-r--r--MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs2
-rw-r--r--Nuget/MediaBrowser.Common.Internal.nuspec4
-rw-r--r--Nuget/MediaBrowser.Common.nuspec2
-rw-r--r--Nuget/MediaBrowser.Server.Core.nuspec4
17 files changed, 57 insertions, 30 deletions
diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs
index b648e7fd3..343672877 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.Api
ActiveRequestCount = 1,
IsVideo = isVideo,
StartTimeTicks = startTimeTicks,
- SourcePath = sourcePath
+ SourcePath = sourcePath,
+ DeviceId = deviceId
});
}
}
@@ -180,7 +182,7 @@ namespace MediaBrowser.Api
if (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.Api
public 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.cs
index f3164ad69..1772cc547 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -624,7 +624,7 @@ namespace MediaBrowser.Api.Playback
EnableRaisingEvents = 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.cs
index f1fa86f78..be7aadec0 100644
--- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
+++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs
@@ -66,6 +66,14 @@ namespace MediaBrowser.Api.Playback.Hls
public 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.Hls
return 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.cs
index 07f9d31e9..339de0e6c 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.cs
index b588e4a85..f4976bba3 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.cs
index efb1d5d43..a43ed276d 100644
--- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
+++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs
@@ -721,9 +721,6 @@ namespace MediaBrowser.Api.UserLibrary
var item = _dtoService.GetItemByDtoId(request.Id, user.Id);
- // Kill the encoding
- ApiEntryPoint.Instance.KillSingleTranscodingJob(item.Path);
-
var session = GetSession();
var info = new PlaybackStopInfo
diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs
index 8b8e81e8a..e20258520 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.cs
index c634871fa..177df5afa 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.cs
index caf332a5b..e900dd77e 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -136,10 +136,7 @@ namespace MediaBrowser.Controller.Entities
get { 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.cs
index 0cf59183d..17fd06cb6 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.cs
index 5e498c578..f982e5658 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 file
diff --git a/MediaBrowser.Providers/Games/GameSystemProviderFromXml.cs b/MediaBrowser.Providers/Games/GameSystemProviderFromXml.cs
index ed76d0842..526170db5 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.cs
index 727768b9f..4fb65a764 100644
--- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs
+++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs
@@ -323,6 +323,8 @@ namespace MediaBrowser.Providers.MediaInfo
FetchWtvInfo(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.cs
index 9f3d26e24..88def28db 100644
--- a/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs
+++ b/MediaBrowser.ServerApplication/FFMpeg/FFMpegDownloader.cs
@@ -21,7 +21,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
private 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.nuspec
index 18187392a..6714bb59e 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.nuspec
index a9cc361a9..814a4cd7e 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.nuspec
index 56e9222d4..894905447 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>