The Free Software Media System - Server Backend & API
live tv updates
Luke Pulverentifdca3bd9c407
diff --git a/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs b/MediaBrowser.Api/AuthorizationRequestFilterAttribute.csindex 8f9babd06a..82df791ded 100644--- a/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs+++ b/MediaBrowser.Api/AuthorizationRequestFilterAttribute.cs@@ -5,7 +5,6 @@ using MediaBrowser.Model.Logging;using ServiceStack.Web;using System;using System.Collections.Generic;-using System.Net.Http.Headers;namespace MediaBrowser.Api{diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.csindex 8febe4a65d..556f3b57d5 100644--- a/MediaBrowser.Api/BaseApiService.cs+++ b/MediaBrowser.Api/BaseApiService.cs@@ -6,7 +6,6 @@ using MediaBrowser.Model.Logging;using ServiceStack.Web;using System;using System.Collections.Generic;-using System.IO;using System.Linq;namespace MediaBrowser.Apidiff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csprojindex 409d152f79..a04aca2a03 100644--- a/MediaBrowser.Api/MediaBrowser.Api.csproj+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj@@ -99,7 +99,6 @@<Compile Include="Playback\EndlessStreamCopy.cs" /><Compile Include="Playback\Hls\AudioHlsService.cs" /><Compile Include="Playback\Hls\BaseHlsService.cs" />- <Compile Include="Playback\Hls\HlsSegmentResponseFilter.cs" /><Compile Include="Playback\Hls\HlsSegmentService.cs" /><Compile Include="Playback\Hls\VideoHlsService.cs" /><Compile Include="Playback\Progressive\AudioService.cs" />diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentResponseFilter.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentResponseFilter.csdeleted file mode 100644index 10ea6bc639..0000000000--- a/MediaBrowser.Api/Playback/Hls/HlsSegmentResponseFilter.cs+++ /dev/null@@ -1,53 +0,0 @@-using MediaBrowser.Controller;-using MediaBrowser.Model.Logging;-using ServiceStack.Text.Controller;-using ServiceStack.Web;-using System;-using System.IO;-using System.Linq;--namespace MediaBrowser.Api.Playback.Hls-{- public class HlsSegmentResponseFilter : Attribute, IHasResponseFilter- {- public ILogger Logger { get; set; }- public IServerApplicationPaths ApplicationPaths { get; set; }-- public void ResponseFilter(IRequest req, IResponse res, object response)- {- var pathInfo = PathInfo.Parse(req.PathInfo);- var itemId = pathInfo.GetArgumentValue<string>(1);- var playlistId = pathInfo.GetArgumentValue<string>(3);-- OnEndRequest(itemId, playlistId);- }-- public IHasResponseFilter Copy()- {- return this;- }-- public int Priority- {- get { return -1; }- }-- /// <summary>- /// Called when [end request].- /// </summary>- /// <param name="itemId">The item id.</param>- /// <param name="playlistId">The playlist id.</param>- protected void OnEndRequest(string itemId, string playlistId)- {- Logger.Info("OnEndRequest " + playlistId);- var normalizedPlaylistId = playlistId.Replace("-low", string.Empty);-- foreach (var playlist in Directory.EnumerateFiles(ApplicationPaths.TranscodingTempPath, "*.m3u8")- .Where(i => i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1)- .ToList())- {- ApiEntryPoint.Instance.OnTranscodeEndRequest(playlist, TranscodingJobType.Hls);- }- }- }-}diff --git a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.csindex 31583ac197..5d2dd07c7e 100644--- a/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs+++ b/MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs@@ -28,28 +28,6 @@ namespace MediaBrowser.Api.Playback.Hlspublic string SegmentId { 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- {- /// <summary>- /// Gets or sets the id.- /// </summary>- /// <value>The id.</value>- public string Id { get; set; }-- public string PlaylistId { get; set; }-- /// <summary>- /// Gets or sets the segment id.- /// </summary>- /// <value>The segment id.</value>- public string SegmentId { get; set; }- }-/// <summary>/// Class GetHlsVideoSegment/// </summary>@@ -99,22 +77,6 @@ namespace MediaBrowser.Api.Playback.HlsApiEntryPoint.Instance.KillTranscodingJobs(request.DeviceId, true);}- /// <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(_appPaths.TranscodingTempPath, file);-- OnBeginRequest(request.PlaylistId);-- return ResultFactory.GetStaticFileResult(Request, file);- }-/// <summary>/// Gets the specified request./// </summary>diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.csindex fae9e26c62..174cbe9ba0 100644--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs@@ -10,6 +10,8 @@ using MediaBrowser.Model.IO;using ServiceStack;using System;using System.Collections.Generic;+using System.IO;+using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;@@ -56,6 +58,28 @@ 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+ {+ /// <summary>+ /// Gets or sets the id.+ /// </summary>+ /// <value>The id.</value>+ public string Id { get; set; }++ public string PlaylistId { get; set; }++ /// <summary>+ /// Gets or sets the segment id.+ /// </summary>+ /// <value>The segment id.</value>+ public string SegmentId { get; set; }+ }+/// <summary>/// Class VideoHlsService/// </summary>@@ -87,6 +111,22 @@ namespace MediaBrowser.Api.Playback.Hlsreturn result;}+ /// <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);++ OnBeginRequest(request.PlaylistId);++ return ResultFactory.GetStaticFileResult(Request, file);+ }+private async Task<object> GetPlaylistAsync(VideoStreamRequest request, string name){var state = await GetState(request, CancellationToken.None).ConfigureAwait(false);@@ -313,5 +353,30 @@ namespace MediaBrowser.Api.Playback.Hls{return ".ts";}++ /// <summary>+ /// Called when [begin request].+ /// </summary>+ /// <param name="playlistId">The playlist id.</param>+ protected void OnBeginRequest(string playlistId)+ {+ var normalizedPlaylistId = playlistId.Replace("-low", string.Empty);++ foreach (var playlist in Directory.EnumerateFiles(ServerConfigurationManager.ApplicationPaths.TranscodingTempPath, "*.m3u8")+ .Where(i => i.IndexOf(normalizedPlaylistId, StringComparison.OrdinalIgnoreCase) != -1)+ .ToList())+ {+ ExtendPlaylistTimer(playlist);+ }+ }++ private async void ExtendPlaylistTimer(string playlist)+ {+ ApiEntryPoint.Instance.OnTranscodeBeginRequest(playlist, TranscodingJobType.Hls);++ await Task.Delay(20000).ConfigureAwait(false);++ ApiEntryPoint.Instance.OnTranscodeEndRequest(playlist, TranscodingJobType.Hls);+ }}}diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.csindex 6a0d135c83..bf453ccf4d 100644--- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs+++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs@@ -102,6 +102,12 @@ namespace MediaBrowser.Controller.LiveTv/// <value>The audio.</value>public ProgramAudio? Audio { get; set; }+ /// <summary>+ /// Gets or sets the original air date.+ /// </summary>+ /// <value>The original air date.</value>+ public DateTime? OriginalAirDate { get; set; }+/// <summary>/// Gets or sets a value indicating whether this instance is movie./// </summary>diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.csindex 0ef5c9dc01..389df2248f 100644--- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs@@ -90,6 +90,12 @@ namespace MediaBrowser.Model.LiveTv/// </summary>public DateTime EndDate { get; set; }+ /// <summary>+ /// Gets or sets the original air date.+ /// </summary>+ /// <value>The original air date.</value>+ public DateTime? OriginalAirDate { get; set; }+/// <summary>/// Gets or sets the status./// </summary>diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.csindex c042e7750d..ad9f769eb1 100644--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs@@ -161,7 +161,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn null;}- return val.Value * 2;+ return val.Value;}public string GetStatusName(RecordingStatus status)@@ -222,6 +222,7 @@ namespace MediaBrowser.Server.Implementations.LiveTvIsPremiere = info.IsPremiere,RunTimeTicks = (info.EndDate - info.StartDate).Ticks,LocationType = recording.LocationType,+ OriginalAirDate = info.OriginalAirDate,MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery{diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.csindex 6f956ba207..b09ff623e7 100644--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs@@ -249,11 +249,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder{process.Kill();}- catch (InvalidOperationException ex1)- {- _logger.ErrorException("Error killing ffprobe", ex1);- }- catch (Win32Exception ex1)+ catch (Exception ex1){_logger.ErrorException("Error killing ffprobe", ex1);}