Browse Source

fix hls direct with jellyfin 10.11 (#2570)

pull/2571/head
Jason Dove 7 months ago committed by GitHub
parent
commit
0dbdcc3674
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      CHANGELOG.md
  2. 33
      ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs
  3. 3
      ErsatzTV/Controllers/IptvController.cs

2
CHANGELOG.md

@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Fixed
- Fix HLS Direct playback with Jellyfin 10.11
## [25.8.0] - 2025-10-26
### Added

33
ErsatzTV.Application/Streaming/Queries/GetHlsPlaylistByChannelNumberHandler.cs

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
using ErsatzTV.Core;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;
using ErsatzTV.FFmpeg.OutputFormat;
using ErsatzTV.Infrastructure.Data;
using ErsatzTV.Infrastructure.Extensions;
using Microsoft.EntityFrameworkCore;
@ -11,13 +13,16 @@ public class GetHlsPlaylistByChannelNumberHandler : @@ -11,13 +13,16 @@ public class GetHlsPlaylistByChannelNumberHandler :
IRequestHandler<GetHlsPlaylistByChannelNumber, Either<BaseError, string>>
{
private readonly IDbContextFactory<TvContext> _dbContextFactory;
private readonly IConfigElementRepository _configElementRepository;
private readonly IMemoryCache _memoryCache;
public GetHlsPlaylistByChannelNumberHandler(
IDbContextFactory<TvContext> dbContextFactory,
IConfigElementRepository configElementRepository,
IMemoryCache memoryCache)
{
_dbContextFactory = dbContextFactory;
_configElementRepository = configElementRepository;
_memoryCache = memoryCache;
}
@ -31,7 +36,7 @@ public class GetHlsPlaylistByChannelNumberHandler : @@ -31,7 +36,7 @@ public class GetHlsPlaylistByChannelNumberHandler :
return await validation.Apply(parameters => GetPlaylist(dbContext, request, parameters, now));
}
private Task<string> GetPlaylist(
private async Task<string> GetPlaylist(
TvContext dbContext,
GetHlsPlaylistByChannelNumber request,
Parameters parameters,
@ -44,11 +49,25 @@ public class GetHlsPlaylistByChannelNumberHandler : @@ -44,11 +49,25 @@ public class GetHlsPlaylistByChannelNumberHandler :
_ => string.Empty
};
string endpoint = request.Mode switch
string endpoint = "ffmpeg/stream";
string extension = string.Empty;
if (request.Mode is "hls-direct")
{
"hls-direct" => "iptv/hls-direct",
_ => "ffmpeg/stream"
};
endpoint = "iptv/hls-direct";
OutputFormatKind outputFormat = await _configElementRepository
.GetValue<OutputFormatKind>(ConfigElementKey.FFmpegHlsDirectOutputFormat, CancellationToken.None)
.IfNoneAsync(OutputFormatKind.MpegTs);
extension = outputFormat switch
{
OutputFormatKind.MpegTs => ".ts",
OutputFormatKind.Mp4 => ".mp4",
OutputFormatKind.Mkv => ".mkv",
_ => string.Empty
};
}
long index = GetIndexForChannel(parameters.Channel, parameters.PlayoutItem);
double timeRemaining = Math.Abs((parameters.PlayoutItem.FinishOffset - now).TotalSeconds);
@ -58,8 +77,8 @@ public class GetHlsPlaylistByChannelNumberHandler : @@ -58,8 +77,8 @@ public class GetHlsPlaylistByChannelNumberHandler :
#EXT-X-MEDIA-SEQUENCE:{index}
#EXT-X-DISCONTINUITY
#EXTINF:{timeRemaining:F2},
{request.Scheme}://{request.Host}/{endpoint}/{request.ChannelNumber}?index={index}{mode}
".AsTask();
{request.Scheme}://{request.Host}/{endpoint}/{request.ChannelNumber}{extension}?index={index}{mode}
";
}
private static Task<Validation<BaseError, Parameters>> Validate(

3
ErsatzTV/Controllers/IptvController.cs

@ -282,6 +282,9 @@ public class IptvController : StreamingControllerBase @@ -282,6 +282,9 @@ public class IptvController : StreamingControllerBase
}
[HttpGet("iptv/hls-direct/{channelNumber}")]
[HttpGet("iptv/hls-direct/{channelNumber}.ts")]
[HttpGet("iptv/hls-direct/{channelNumber}.mkv")]
[HttpGet("iptv/hls-direct/{channelNumber}.mp4")]
public async Task<IActionResult> GetStream(string channelNumber) =>
await GetHlsDirectStream(channelNumber);

Loading…
Cancel
Save