using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.MediaEncoding;
///
/// Provides a durable store for HLS transcoding session state, enabling
/// HA recovery and lease-based ownership between pods.
///
public interface ITranscodeSessionStore
{
///
/// Attempts to retrieve a transcoding session by its play session identifier.
///
/// The play session identifier.
/// A cancellation token.
///
/// The if it exists and its lease has not expired;
/// otherwise null.
///
Task TryGetAsync(string playSessionId, CancellationToken cancellationToken = default);
///
/// Attempts to take over ownership of an existing session by claiming the lease for
/// . Takeover succeeds only when the session exists and
/// its current lease has already expired.
///
/// The play session identifier.
/// The name of the pod attempting to claim ownership.
/// A cancellation token.
///
/// true if the takeover succeeded (the claiming pod now holds the lease);
/// false if the session does not exist, its lease is still valid, or another
/// concurrent caller already claimed it.
///
Task TryTakeoverAsync(string playSessionId, string claimingPod, CancellationToken cancellationToken = default);
///
/// Persists a new or updated transcoding session.
///
/// The session to store.
/// A cancellation token.
/// A representing the asynchronous operation.
Task SetAsync(TranscodeSession session, CancellationToken cancellationToken = default);
///
/// Renews the lease for an existing session, extending its
/// by the store's configured lease duration.
/// The renewal is rejected when no longer owns the lease, so a
/// renewal in flight while another pod wins cannot revert the takeover.
///
/// The play session identifier.
/// The name of the pod that believes it owns the lease.
/// A cancellation token.
///
/// true if the lease was renewed; false if the session no longer exists or is
/// owned by another pod.
///
Task RenewLeaseAsync(string playSessionId, string ownerPod, CancellationToken cancellationToken = default);
///
/// Removes a transcoding session from the store.
///
/// The play session identifier.
/// A cancellation token.
/// A representing the asynchronous operation.
Task DeleteAsync(string playSessionId, CancellationToken cancellationToken = default);
///
/// Returns all currently active transcoding sessions from the store.
///
/// A cancellation token.
///
/// An enumerable of objects representing all active sessions.
/// Returns an empty enumerable if no sessions are active or if the store cannot be reached.
///
Task> GetActiveSessionsAsync(CancellationToken cancellationToken = default);
}