<?php

declare(strict_types=1);

namespace App\Application\Media;

use App\Framework\Attributes\Route;
use App\Framework\Http\Responses\AdaptiveStreamResponse;
use App\Framework\Http\Responses\StreamResponse;
use App\Framework\Http\Streaming\AdaptiveStreamingController;

final readonly class AdaptiveVideoStream
{
    public function __construct(
        private AdaptiveStreamingController $adaptiveStreamingController,
    ) {

    }

    #[Route('/videos/{videoId}/manifest')]
    public function manifestAutoFormat(string $videoId): AdaptiveStreamResponse
    {
        return $this->adaptiveStreamingController->manifest($videoId);
    }

    #[Route('/videos/{videoId}/manifest.m3u8')]
    public function hlsManifest(string $videoId): AdaptiveStreamResponse
    {
        return $this->adaptiveStreamingController->hlsManifest($videoId);
    }

    #[Route('/videos/{videoId}/manifest.mpd')]
    public function dashManifest(string $videoId): AdaptiveStreamResponse
    {
        return $this->adaptiveStreamingController->dashManifest($videoId);
    }

    #[Route('/videos/{videoId}/{quality}.m3u8')]
    public function hlsMediaPlaylist(string $videoId, string $quality): AdaptiveStreamResponse
    {
        return $this->adaptiveStreamingController->hlsMediaPlaylist($videoId, $quality);
    }

    #[Route('/videos/{videoId}/{quality}/{segment}/')]
    public function segment(string $videoId, string $quality, string $segment): StreamResponse
    {
        return $this->adaptiveStreamingController->segment($videoId, $quality, $segment);
    }
}
