浏览代码

live tv updates

Luke Pulverenti 11 年之前
父节点
当前提交
fdca3bd9c4

+ 0 - 1
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
 {

+ 0 - 1
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.Api

+ 0 - 1
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" />

+ 0 - 53
MediaBrowser.Api/Playback/Hls/HlsSegmentResponseFilter.cs

@@ -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);
-            }
-        }
-    }
-}

+ 0 - 38
MediaBrowser.Api/Playback/Hls/HlsSegmentService.cs

@@ -28,28 +28,6 @@ namespace MediaBrowser.Api.Playback.Hls
         public 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.Hls
             ApiEntryPoint.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>

+ 65 - 0
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.Hls
             return 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);
+        }
     }
 }

+ 6 - 0
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>

+ 6 - 0
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>

+ 2 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs

@@ -161,7 +161,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 return null;
             }
 
-            return val.Value * 2;
+            return val.Value;
         }
 
         public string GetStatusName(RecordingStatus status)
@@ -222,6 +222,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                 IsPremiere = info.IsPremiere,
                 RunTimeTicks = (info.EndDate - info.StartDate).Ticks,
                 LocationType = recording.LocationType,
+                OriginalAirDate = info.OriginalAirDate,
 
                 MediaStreams = _itemRepo.GetMediaStreams(new MediaStreamQuery
                 {

+ 1 - 5
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);
                 }