<?php

declare(strict_types=1);

namespace Blax\WebRtc\Rooms;

use Blax\WebRtc\Contracts\RoomRegistry;

/**
 * How a room's MEDIA is carried — an orthogonal dimension to {@see RoomType}
 * (which governs membership/auth). Configured per room in the {@see RoomRegistry}.
 *
 *   p2p  browsers connect directly (mesh); the server only RELAYS signaling
 *        (SDP/ICE). No server-side media, no recording of the media, E2E
 *        encrypted. Best for small rooms.
 *   sfu  the server TERMINATES media (the Rust SFU MediaEngine — ICE/DTLS/SRTP
 *        server-side, forwards without decoding). Enables server recording,
 *        moderation and large rooms. Requires the media engine to be available.
 */
enum RoomMode: string
{
    case P2P = 'p2p';
    case Sfu = 'sfu';

    public function isServerHandled(): bool
    {
        return $this === self::Sfu;
    }

    public static function fromString(?string $value, self $default = self::P2P): self
    {
        return self::tryFrom((string) $value) ?? $default;
    }
}
