using System.Threading; using System.Threading.Tasks; namespace Jellyfin.Plugin.SRFPlay.Services.Interfaces; /// /// Interface for proxying SRF Play streams and managing authentication. /// public interface IStreamProxyService { /// /// Registers a stream for proxying with an already-authenticated URL. /// /// The item ID. /// The authenticated stream URL. /// The SRF URN for this content (used for re-fetching fresh URLs). /// Whether this is a livestream (livestreams always fetch fresh URLs). void RegisterStream(string itemId, string authenticatedUrl, string? urn = null, bool isLiveStream = false); /// /// 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. /// /// The item ID. /// The unauthenticated stream URL. /// The SRF URN for this content. /// Whether this is a livestream. void RegisterStreamDeferred(string itemId, string unauthenticatedUrl, string? urn = null, bool isLiveStream = false); /// /// Gets stream metadata for an item (URN and isLiveStream flag). /// /// The item ID. /// A tuple of (URN, IsLiveStream), or null if not found. (string? Urn, bool IsLiveStream)? GetStreamMetadata(string itemId); /// /// Gets the authenticated URL for an item. /// /// The item ID. /// Cancellation token. /// The authenticated URL, or null if not found or expired. Task GetAuthenticatedUrlAsync(string itemId, CancellationToken cancellationToken = default); /// /// Fetches and rewrites an HLS manifest to use proxy URLs. /// /// The item ID. /// The base proxy URL. /// Cancellation token. /// The rewritten manifest content. Task GetRewrittenManifestAsync(string itemId, string baseProxyUrl, CancellationToken cancellationToken = default); /// /// Fetches a segment from the original source. /// /// The item ID. /// The segment path. /// Cancellation token. /// The segment content as bytes. Task GetSegmentAsync(string itemId, string segmentPath, CancellationToken cancellationToken = default); /// /// Cleans up old and expired stream mappings. /// void CleanupOldMappings(); }