mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-01 19:17:23 -04:00 
			
		
		
		
	live tv updates
This commit is contained in:
		
							parent
							
								
									e4f5a3f005
								
							
						
					
					
						commit
						fdca3bd9c4
					
				| @ -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 | ||||
| { | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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" /> | ||||
|  | ||||
| @ -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); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -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> | ||||
|  | ||||
| @ -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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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> | ||||
|  | ||||
| @ -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 | ||||
|                 { | ||||
|  | ||||
| @ -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); | ||||
|                 } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user