<?php

declare(strict_types=1);

namespace Blax\WebRtc\Contracts;

/**
 * Where a call's audio is stored. The browser streams its mic to the server over
 * the WebSocket as binary frames; the relay appends them here per participant and
 * finalizes on leave/disconnect. Implement this to store to S3, a DB blob, etc.
 */
interface RecordingStore
{
    /** Append a chunk of a participant's audio for a call. */
    public function append(string $roomId, string $peerId, string $chunk): void;

    /**
     * Finish a participant's recording (they left / the call ended).
     *
     * @return string|null a locator (path/URL) for the finished recording, or null
     */
    public function finalize(string $roomId, string $peerId): ?string;

    /** Discard a participant's recording so a new one starts clean (e.g. re-join / restart). */
    public function discard(string $roomId, string $peerId): void;
}
