@ -5,11 +5,9 @@ using System.Timers;
@@ -5,11 +5,9 @@ using System.Timers;
using CliWrap ;
using CliWrap.Buffered ;
using ErsatzTV.Core ;
using ErsatzTV.Core.Domain ;
using ErsatzTV.Core.FFmpeg ;
using ErsatzTV.Core.Interfaces.FFmpeg ;
using ErsatzTV.Core.Interfaces.Metadata ;
using ErsatzTV.Core.Interfaces.Repositories ;
using Microsoft.Extensions.DependencyInjection ;
using Microsoft.Extensions.Logging ;
using Timer = System . Timers . Timer ;
@ -21,7 +19,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
@@ -21,7 +19,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
private readonly SemaphoreSlim _ slim = new ( 1 , 1 ) ;
//private static int _workAheadCount;
private readonly IConfigElementRepository _ configElementRepository ;
private readonly string _ host ;
private readonly ILocalFileSystem _l ocalFileSystem ;
private readonly ILogger < HlsSessionWorkerV2 > _l ogger ;
@ -32,7 +29,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
@@ -32,7 +29,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
private CancellationTokenSource _ cancellationTokenSource ;
private string _ channelNumber ;
private bool _d isposedValue ;
private bool _ hasWrittenSegments ;
private DateTimeOffset _l astAccess ;
private Option < PlayoutItemProcessModel > _l astProcessModel ;
private IServiceScope _ serviceScope ;
@ -42,7 +38,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
@@ -42,7 +38,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
public HlsSessionWorkerV2 (
IServiceScopeFactory serviceScopeFactory ,
IConfigElementRepository configElementRepository ,
ILocalFileSystem localFileSystem ,
ILogger < HlsSessionWorkerV2 > logger ,
Option < int > targetFramerate ,
@ -51,7 +46,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
@@ -51,7 +46,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
{
_ serviceScope = serviceScopeFactory . CreateScope ( ) ;
_ mediator = _ serviceScope . ServiceProvider . GetRequiredService < IMediator > ( ) ;
_ configElementRepository = configElementRepository ;
_l ocalFileSystem = localFileSystem ;
_l ogger = logger ;
_ targetFramerate = targetFramerate ;
@ -298,8 +292,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
@@ -298,8 +292,6 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
foreach ( PlayoutItemProcessModel processModel in result . RightToSeq ( ) )
{
_ hasWrittenSegments = true ;
_l ogger . LogDebug ( "Next playout item process will transcode until {Until}" , processModel . Until ) ;
_ transcodedUntil = processModel . Until ;
@ -366,45 +358,4 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
@@ -366,45 +358,4 @@ public class HlsSessionWorkerV2 : IHlsSessionWorker
return result ;
}
private async Task < long > GetPtsOffset ( string channelNumber , CancellationToken cancellationToken )
{
await _ slim . WaitAsync ( cancellationToken ) ;
try
{
long result = 0 ;
// if we haven't yet written any segments, start at zero
if ( ! _ hasWrittenSegments )
{
return result ;
}
Either < BaseError , PtsAndDuration > queryResult = await _ mediator . Send (
new GetLastPtsDuration ( channelNumber ) ,
cancellationToken ) ;
foreach ( BaseError error in queryResult . LeftToSeq ( ) )
{
_l ogger . LogWarning ( "Unable to determine last pts offset - {Error}" , error . ToString ( ) ) ;
}
foreach ( ( long pts , long duration ) in queryResult . RightToSeq ( ) )
{
result = pts + duration + 1 ;
}
return result ;
}
finally
{
_ slim . Release ( ) ;
}
}
private async Task < int > GetWorkAheadLimit ( ) = >
await _ configElementRepository . GetValue < int > ( ConfigElementKey . FFmpegWorkAheadSegmenters )
. Map ( maybeCount = > maybeCount . Match ( identity , ( ) = > 1 ) ) ;
private sealed record Segment ( string File , int SequenceNumber ) ;
}