Duncan Tourolle 198fc4c58d
All checks were successful
🚀 Release Plugin / build-and-release (push) Successful in 2m51s
🏗️ Build Plugin / build (push) Successful in 2m50s
🧪 Test Plugin / test (push) Successful in 1m20s
more consolidation
2025-12-07 13:29:13 +01:00

68 lines
3.1 KiB
C#

using System.Threading;
using System.Threading.Tasks;
namespace Jellyfin.Plugin.SRFPlay.Services.Interfaces;
/// <summary>
/// Interface for proxying SRF Play streams and managing authentication.
/// </summary>
public interface IStreamProxyService
{
/// <summary>
/// Registers a stream for proxying with an already-authenticated URL.
/// </summary>
/// <param name="itemId">The item ID.</param>
/// <param name="authenticatedUrl">The authenticated stream URL.</param>
/// <param name="urn">The SRF URN for this content (used for re-fetching fresh URLs).</param>
/// <param name="isLiveStream">Whether this is a livestream (livestreams always fetch fresh URLs).</param>
void RegisterStream(string itemId, string authenticatedUrl, string? urn = null, bool isLiveStream = false);
/// <summary>
/// Registers a stream for deferred authentication (authenticates on first playback request).
/// Use this when browsing to avoid wasting 30-second tokens before the user clicks play.
/// </summary>
/// <param name="itemId">The item ID.</param>
/// <param name="unauthenticatedUrl">The unauthenticated stream URL.</param>
/// <param name="urn">The SRF URN for this content.</param>
/// <param name="isLiveStream">Whether this is a livestream.</param>
void RegisterStreamDeferred(string itemId, string unauthenticatedUrl, string? urn = null, bool isLiveStream = false);
/// <summary>
/// Gets stream metadata for an item (URN and isLiveStream flag).
/// </summary>
/// <param name="itemId">The item ID.</param>
/// <returns>A tuple of (URN, IsLiveStream), or null if not found.</returns>
(string? Urn, bool IsLiveStream)? GetStreamMetadata(string itemId);
/// <summary>
/// Gets the authenticated URL for an item.
/// </summary>
/// <param name="itemId">The item ID.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The authenticated URL, or null if not found or expired.</returns>
Task<string?> GetAuthenticatedUrlAsync(string itemId, CancellationToken cancellationToken = default);
/// <summary>
/// Fetches and rewrites an HLS manifest to use proxy URLs.
/// </summary>
/// <param name="itemId">The item ID.</param>
/// <param name="baseProxyUrl">The base proxy URL.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The rewritten manifest content.</returns>
Task<string?> GetRewrittenManifestAsync(string itemId, string baseProxyUrl, CancellationToken cancellationToken = default);
/// <summary>
/// Fetches a segment from the original source.
/// </summary>
/// <param name="itemId">The item ID.</param>
/// <param name="segmentPath">The segment path.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>The segment content as bytes.</returns>
Task<byte[]?> GetSegmentAsync(string itemId, string segmentPath, CancellationToken cancellationToken = default);
/// <summary>
/// Cleans up old and expired stream mappings.
/// </summary>
void CleanupOldMappings();
}