mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
re-org scripts
This commit is contained in:
parent
d157c1278b
commit
ad52df6be0
@ -274,32 +274,37 @@ namespace MediaBrowser.Api
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
job.ActiveRequestCount++;
|
OnTranscodeBeginRequest(job);
|
||||||
|
|
||||||
job.DisposeKillTimer();
|
|
||||||
|
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnTranscodeBeginRequest(TranscodingJob job)
|
||||||
|
{
|
||||||
|
job.ActiveRequestCount++;
|
||||||
|
|
||||||
|
job.DisposeKillTimer();
|
||||||
|
}
|
||||||
|
|
||||||
public void OnTranscodeEndRequest(TranscodingJob job)
|
public void OnTranscodeEndRequest(TranscodingJob job)
|
||||||
{
|
{
|
||||||
job.ActiveRequestCount--;
|
job.ActiveRequestCount--;
|
||||||
|
|
||||||
if (job.ActiveRequestCount == 0)
|
if (job.ActiveRequestCount == 0)
|
||||||
{
|
{
|
||||||
if (job.Type == TranscodingJobType.Progressive)
|
// TODO: Lower this hls timeout
|
||||||
{
|
var timerDuration = job.Type == TranscodingJobType.Progressive ?
|
||||||
const int timerDuration = 1000;
|
1000 :
|
||||||
|
14400000;
|
||||||
|
|
||||||
if (job.KillTimer == null)
|
if (job.KillTimer == null)
|
||||||
{
|
{
|
||||||
job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite);
|
job.KillTimer = new Timer(OnTranscodeKillTimerStopped, job, timerDuration, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
job.KillTimer.Change(timerDuration, Timeout.Infinite);
|
job.KillTimer.Change(timerDuration, Timeout.Infinite);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,7 +503,7 @@ namespace MediaBrowser.Api
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
Exception e = null;
|
Exception e = null;
|
||||||
|
|
||||||
foreach (var file in filesToDelete)
|
foreach (var file in filesToDelete)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -114,7 +114,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
|
|
||||||
if (File.Exists(segmentPath))
|
if (File.Exists(segmentPath))
|
||||||
{
|
{
|
||||||
job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
|
||||||
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
if (File.Exists(segmentPath))
|
if (File.Exists(segmentPath))
|
||||||
{
|
{
|
||||||
job = ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
job = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
|
||||||
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -145,6 +145,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
request.StartTimeTicks = GetSeekPositionTicks(state, requestedIndex);
|
request.StartTimeTicks = GetSeekPositionTicks(state, requestedIndex);
|
||||||
|
|
||||||
job = await StartFfMpeg(state, playlistPath, cancellationTokenSource).ConfigureAwait(false);
|
job = await StartFfMpeg(state, playlistPath, cancellationTokenSource).ConfigureAwait(false);
|
||||||
|
ApiEntryPoint.Instance.OnTranscodeBeginRequest(job);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -168,7 +169,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.Info("returning {0}", segmentPath);
|
Logger.Info("returning {0}", segmentPath);
|
||||||
job = job ?? ApiEntryPoint.Instance.GetTranscodingJob(playlistPath, TranscodingJobType);
|
job = job ?? ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType);
|
||||||
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
return await GetSegmentResult(playlistPath, segmentPath, requestedIndex, segmentLength, job, cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,8 +369,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
if (transcodingJob != null)
|
if (transcodingJob != null)
|
||||||
{
|
{
|
||||||
transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks);
|
transcodingJob.DownloadPositionTicks = Math.Max(transcodingJob.DownloadPositionTicks ?? segmentEndingPositionTicks, segmentEndingPositionTicks);
|
||||||
|
ApiEntryPoint.Instance.OnTranscodeEndRequest(transcodingJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Playback.Hls
|
namespace MediaBrowser.Api.Playback.Hls
|
||||||
{
|
{
|
||||||
@ -32,6 +36,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
|
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
|
||||||
public class GetHlsPlaylist
|
public class GetHlsPlaylist
|
||||||
{
|
{
|
||||||
|
// TODO: Deprecate with new iOS app
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the id.
|
/// Gets or sets the id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -52,22 +58,39 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
public string StreamId { get; set; }
|
public string StreamId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Class GetHlsVideoSegment
|
||||||
|
/// </summary>
|
||||||
|
[Route("/Videos/{Id}/hls/{PlaylistId}/{SegmentId}.ts", "GET")]
|
||||||
|
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
|
||||||
|
public class GetHlsVideoSegment : VideoStreamRequest
|
||||||
|
{
|
||||||
|
public string PlaylistId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the segment id.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The segment id.</value>
|
||||||
|
public string SegmentId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
public class HlsSegmentService : BaseApiService
|
public class HlsSegmentService : BaseApiService
|
||||||
{
|
{
|
||||||
private readonly IServerApplicationPaths _appPaths;
|
private readonly IServerApplicationPaths _appPaths;
|
||||||
|
private readonly IServerConfigurationManager _config;
|
||||||
|
|
||||||
public HlsSegmentService(IServerApplicationPaths appPaths)
|
public HlsSegmentService(IServerApplicationPaths appPaths, IServerConfigurationManager config)
|
||||||
{
|
{
|
||||||
_appPaths = appPaths;
|
_appPaths = appPaths;
|
||||||
|
_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Get(GetHlsPlaylist request)
|
public object Get(GetHlsPlaylist request)
|
||||||
{
|
{
|
||||||
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
var file = request.PlaylistId + Path.GetExtension(Request.PathInfo);
|
||||||
|
|
||||||
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
return GetFileResult(file, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(StopEncodingProcess request)
|
public void Delete(StopEncodingProcess request)
|
||||||
@ -80,13 +103,49 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">The request.</param>
|
/// <param name="request">The request.</param>
|
||||||
/// <returns>System.Object.</returns>
|
/// <returns>System.Object.</returns>
|
||||||
public object Get(GetHlsAudioSegment request)
|
public object Get(GetHlsVideoSegment request)
|
||||||
{
|
{
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
|
file = Path.Combine(_config.ApplicationPaths.TranscodingTempPath, file);
|
||||||
|
|
||||||
|
var normalizedPlaylistId = request.PlaylistId.Replace("-low", string.Empty);
|
||||||
|
|
||||||
|
var playlistPath = Directory.EnumerateFiles(_config.ApplicationPaths.TranscodingTempPath, "*")
|
||||||
|
.FirstOrDefault(i => string.Equals(Path.GetExtension(i), ".m3u8", StringComparison.OrdinalIgnoreCase) && i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1);
|
||||||
|
|
||||||
|
return GetFileResult(file, playlistPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the specified request.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">The request.</param>
|
||||||
|
/// <returns>System.Object.</returns>
|
||||||
|
public object Get(GetHlsAudioSegment request)
|
||||||
|
{
|
||||||
|
// TODO: Deprecate with new iOS app
|
||||||
|
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
||||||
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
file = Path.Combine(_appPaths.TranscodingTempPath, file);
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
return ResultFactory.GetStaticFileResult(Request, file, FileShare.ReadWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private object GetFileResult(string path, string playlistPath)
|
||||||
|
{
|
||||||
|
var transcodingJob = ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlistPath, TranscodingJobType.Hls);
|
||||||
|
|
||||||
|
return ResultFactory.GetStaticFileResult(Request, new StaticFileResultOptions
|
||||||
|
{
|
||||||
|
Path = path,
|
||||||
|
FileShare = FileShare.ReadWrite,
|
||||||
|
OnComplete = () =>
|
||||||
|
{
|
||||||
|
if (transcodingJob != null)
|
||||||
|
{
|
||||||
|
ApiEntryPoint.Instance.OnTranscodeEndRequest(transcodingJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
[Api(Description = "Gets a video stream using HTTP live streaming.")]
|
[Api(Description = "Gets a video stream using HTTP live streaming.")]
|
||||||
public class GetHlsVideoStream : VideoStreamRequest
|
public class GetHlsVideoStream : VideoStreamRequest
|
||||||
{
|
{
|
||||||
|
// TODO: Deprecate with new iOS app
|
||||||
|
|
||||||
[ApiMember(Name = "BaselineStreamAudioBitRate", Description = "Optional. Specify the audio bitrate for the baseline stream.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
[ApiMember(Name = "BaselineStreamAudioBitRate", Description = "Optional. Specify the audio bitrate for the baseline stream.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||||
public int? BaselineStreamAudioBitRate { get; set; }
|
public int? BaselineStreamAudioBitRate { get; set; }
|
||||||
|
|
||||||
@ -35,22 +37,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Class GetHlsVideoSegment
|
|
||||||
/// </summary>
|
|
||||||
[Route("/Videos/{Id}/hls/{PlaylistId}/{SegmentId}.ts", "GET")]
|
|
||||||
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
|
|
||||||
public class GetHlsVideoSegment : VideoStreamRequest
|
|
||||||
{
|
|
||||||
public string PlaylistId { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the segment id.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The segment id.</value>
|
|
||||||
public string SegmentId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class VideoHlsService
|
/// Class VideoHlsService
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -60,20 +46,6 @@ namespace MediaBrowser.Api.Playback.Hls
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the specified request.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request">The request.</param>
|
|
||||||
/// <returns>System.Object.</returns>
|
|
||||||
public object Get(GetHlsVideoSegment request)
|
|
||||||
{
|
|
||||||
var file = request.SegmentId + Path.GetExtension(Request.PathInfo);
|
|
||||||
|
|
||||||
file = Path.Combine(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, file);
|
|
||||||
|
|
||||||
return ResultFactory.GetStaticFileResult(Request, file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the specified request.
|
/// Gets the specified request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -288,7 +288,7 @@ namespace MediaBrowser.WebDashboard.Api
|
|||||||
"thirdparty/apiclient/ajax.js",
|
"thirdparty/apiclient/ajax.js",
|
||||||
"thirdparty/apiclient/events.js",
|
"thirdparty/apiclient/events.js",
|
||||||
"thirdparty/apiclient/deferred.js",
|
"thirdparty/apiclient/deferred.js",
|
||||||
"thirdparty/apiclient/mediabrowser.apiclient.js",
|
"thirdparty/apiclient/apiclient.js",
|
||||||
"thirdparty/apiclient/connectservice.js",
|
"thirdparty/apiclient/connectservice.js",
|
||||||
"thirdparty/apiclient/serverdiscovery.js",
|
"thirdparty/apiclient/serverdiscovery.js",
|
||||||
"thirdparty/apiclient/connectionmanager.js"
|
"thirdparty/apiclient/connectionmanager.js"
|
||||||
|
@ -190,7 +190,7 @@
|
|||||||
<Content Include="dashboard-ui\thirdparty\apiclient\deferred.js">
|
<Content Include="dashboard-ui\thirdparty\apiclient\deferred.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\thirdparty\apiclient\deferredAlt.js">
|
<Content Include="dashboard-ui\thirdparty\apiclient\alt\deferred.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\thirdparty\apiclient\device.js">
|
<Content Include="dashboard-ui\thirdparty\apiclient\device.js">
|
||||||
@ -202,7 +202,7 @@
|
|||||||
<Content Include="dashboard-ui\thirdparty\apiclient\logger.js">
|
<Content Include="dashboard-ui\thirdparty\apiclient\logger.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\thirdparty\apiclient\mediabrowser.apiclient.js">
|
<Content Include="dashboard-ui\thirdparty\apiclient\apiclient.js">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="dashboard-ui\channelitems.html">
|
<Content Include="dashboard-ui\channelitems.html">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user