#pragma once

#include <cstddef>
#include <cstdint>
#include <functional>
#include <string>
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "core/preview_frame.hpp"

namespace smartcut::media {

std::string decode_frame(const std::string& path, std::size_t frame_index, std::size_t max_decode_frames = 0);
std::shared_ptr<core::PreviewFrame> decode_preview_frame(const std::string& path, std::size_t frame_index,
                                                         std::optional<std::int64_t> target_pts_override = std::nullopt);
std::vector<std::shared_ptr<core::PreviewFrame>> decode_preview_frames(
    const std::string& path,
    const std::vector<std::pair<std::size_t, std::int64_t>>& requests,
    int output_width = 0);
struct PreviewStreamResult {
  std::size_t decoded_frames{};
  bool hardware_accelerated{};
  bool completed{};
  std::string backend{"software"};
};
PreviewStreamResult decode_preview_stream(
    const std::string& path, std::size_t start_frame, std::int64_t start_pts,
    const std::function<bool(std::shared_ptr<core::PreviewFrame>, std::uint64_t)>& present,
    bool allow_hardware = true);
std::string validate_random_seeks(const std::string& path, std::size_t iterations, std::uint64_t seed = 0x534d415254435554ULL);

}  // namespace smartcut::media
