Browse Source

use jwt for mpeg-ts streaming mode (#1661)

pull/1662/head
Jason Dove 1 year ago committed by GitHub
parent
commit
4e56117e0e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 4
      ErsatzTV.Application/Streaming/Queries/GetWrappedProcessByChannelNumber.cs
  3. 3
      ErsatzTV.Application/Streaming/Queries/GetWrappedProcessByChannelNumberHandler.cs
  4. 9
      ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs
  5. 8
      ErsatzTV.Core/Interfaces/FFmpeg/IFFmpegProcessService.cs
  6. 2
      ErsatzTV/Controllers/IptvController.cs

1
CHANGELOG.md

@ -56,6 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -56,6 +56,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- This fix will require a one-time re-scan of each Plex library in full
- After the initial full scan, incremental scans will behave as normal
- Fix edge case where some local episodes, music videos, other videos, songs, images would not automatically be restored from trash
- Fix `MPEG-TS` playback when JWT tokens are enabled for streaming endpoints
### Changed
- Log search index updates under scanner category at debug level, to indicate a potential cause for the UI being out of date

4
ErsatzTV.Application/Streaming/Queries/GetWrappedProcessByChannelNumber.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
public record GetWrappedProcessByChannelNumber : FFmpegProcessRequest
{
public GetWrappedProcessByChannelNumber(string scheme, string host, string channelNumber) : base(
public GetWrappedProcessByChannelNumber(string scheme, string host, string accessToken, string channelNumber) : base(
channelNumber,
"ts",
DateTimeOffset.Now,
@ -12,8 +12,10 @@ public record GetWrappedProcessByChannelNumber : FFmpegProcessRequest @@ -12,8 +12,10 @@ public record GetWrappedProcessByChannelNumber : FFmpegProcessRequest
{
Scheme = scheme;
Host = host;
AccessToken = accessToken;
}
public string Scheme { get; }
public string Host { get; }
public string AccessToken { get; }
}

3
ErsatzTV.Application/Streaming/Queries/GetWrappedProcessByChannelNumberHandler.cs

@ -35,7 +35,8 @@ public class GetWrappedProcessByChannelNumberHandler : FFmpegProcessHandler<GetW @@ -35,7 +35,8 @@ public class GetWrappedProcessByChannelNumberHandler : FFmpegProcessHandler<GetW
saveReports,
channel,
request.Scheme,
request.Host);
request.Host,
request.AccessToken);
return new PlayoutItemProcessModel(process, Option<TimeSpan>.None, DateTimeOffset.MaxValue, true);
}

9
ErsatzTV.Core/FFmpeg/FFmpegLibraryProcessService.cs

@ -724,12 +724,17 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService @@ -724,12 +724,17 @@ public class FFmpegLibraryProcessService : IFFmpegProcessService
bool saveReports,
Channel channel,
string scheme,
string host)
string host,
string accessToken)
{
var resolution = new FrameSize(channel.FFmpegProfile.Resolution.Width, channel.FFmpegProfile.Resolution.Height);
string accessTokenQuery = string.IsNullOrWhiteSpace(accessToken)
? string.Empty
: $"&access_token={accessToken}";
var concatInputFile = new ConcatInputFile(
$"http://localhost:{Settings.ListenPort}/iptv/channel/{channel.Number}.m3u8?mode=segmenter",
$"http://localhost:{Settings.ListenPort}/iptv/channel/{channel.Number}.m3u8?mode=segmenter{accessTokenQuery}",
resolution);
IPipelineBuilder pipelineBuilder = await _pipelineBuilderFactory.GetBuilder(

8
ErsatzTV.Core/Interfaces/FFmpeg/IFFmpegProcessService.cs

@ -60,7 +60,13 @@ public interface IFFmpegProcessService @@ -60,7 +60,13 @@ public interface IFFmpegProcessService
string scheme,
string host);
Task<Command> WrapSegmenter(string ffmpegPath, bool saveReports, Channel channel, string scheme, string host);
Task<Command> WrapSegmenter(
string ffmpegPath,
bool saveReports,
Channel channel,
string scheme,
string host,
string accessToken);
Task<Command> ResizeImage(string ffmpegPath, string inputFile, string outputFile, int height);

2
ErsatzTV/Controllers/IptvController.cs

@ -100,7 +100,7 @@ public class IptvController : ControllerBase @@ -100,7 +100,7 @@ public class IptvController : ControllerBase
FFmpegProcessRequest request = mode switch
{
"ts-legacy" => new GetConcatProcessByChannelNumber(Request.Scheme, Request.Host.ToString(), channelNumber),
_ => new GetWrappedProcessByChannelNumber(Request.Scheme, Request.Host.ToString(), channelNumber)
_ => new GetWrappedProcessByChannelNumber(Request.Scheme, Request.Host.ToString(), Request.Query["access_token"], channelNumber)
};
return await _mediator.Send(request)

Loading…
Cancel
Save