Merge pull request #3528 from Ullmie02/api-entrypoint

Make TranscodingJobHelper an IDisposable (api-migration)
pull/3807/head
Patrick Barron 4 years ago committed by GitHub
commit 6a42a48c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,7 +30,7 @@ namespace Jellyfin.Api.Helpers
/// <summary>
/// Transcoding job helpers.
/// </summary>
public class TranscodingJobHelper
public class TranscodingJobHelper : IDisposable
{
/// <summary>
/// The active transcoding jobs.
@ -46,7 +46,6 @@ namespace Jellyfin.Api.Helpers
private readonly EncodingHelper _encodingHelper;
private readonly IFileSystem _fileSystem;
private readonly IIsoManager _isoManager;
private readonly ILogger<TranscodingJobHelper> _logger;
private readonly IMediaEncoder _mediaEncoder;
private readonly IMediaSourceManager _mediaSourceManager;
@ -90,10 +89,12 @@ namespace Jellyfin.Api.Helpers
_authorizationContext = authorizationContext;
_isoManager = isoManager;
_loggerFactory = loggerFactory;
_encodingHelper = new EncodingHelper(mediaEncoder, fileSystem, subtitleEncoder, configuration);
DeleteEncodedMediaCache();
sessionManager!.PlaybackProgress += OnPlaybackProgress;
sessionManager!.PlaybackStart += OnPlaybackProgress;
}
/// <summary>
@ -834,6 +835,14 @@ namespace Jellyfin.Api.Helpers
}
}
private void OnPlaybackProgress(object sender, PlaybackProgressEventArgs e)
{
if (!string.IsNullOrWhiteSpace(e.PlaySessionId))
{
PingTranscodingJob(e.PlaySessionId, e.IsPaused);
}
}
/// <summary>
/// Deletes the encoded media cache.
/// </summary>
@ -850,5 +859,28 @@ namespace Jellyfin.Api.Helpers
_fileSystem.DeleteFile(file);
}
}
/// <summary>
/// Dispose transcoding job helper.
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
/// Dispose throttler.
/// </summary>
/// <param name="disposing">Disposing.</param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
_loggerFactory.Dispose();
_sessionManager!.PlaybackProgress -= OnPlaybackProgress;
_sessionManager!.PlaybackStart -= OnPlaybackProgress;
}
}
}
}

Loading…
Cancel
Save