<?php

declare(strict_types=1);

namespace Drupal\ffmpeg_media\Event;

use Drupal\Component\EventDispatcher\Event;
use Drupal\ffmpeg_media\ValueObject\ConversionOptions;
use Drupal\media\MediaInterface;

/**
 * Event dispatched when a video conversion starts.
 */
final class ConversionStartedEvent extends Event {

  /**
   * Constructs a ConversionStartedEvent.
   *
   * @param \Drupal\media\MediaInterface $media
   *   The media entity being converted.
   * @param \Drupal\ffmpeg_media\ValueObject\ConversionOptions $options
   *   The conversion options being used.
   * @param string $sourcePath
   *   Path to the source video file.
   * @param array<int, string> $outputFormats
   *   List of output formats being generated.
   */
  public function __construct(
    public readonly MediaInterface $media,
    public readonly ConversionOptions $options,
    public readonly string $sourcePath,
    public readonly array $outputFormats,
  ) {}

  /**
   * Gets the media entity ID.
   *
   * @return int
   *   The media entity ID.
   */
  public function getMediaId(): int {
    return (int) $this->media->id();
  }

}
