#pragma once

#include <filesystem>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

namespace smartcut::media {

std::string build_video_frame_index(const std::filesystem::path& path, std::size_t stream_index = 0);
std::string build_fast_video_navigation(const std::filesystem::path& path, std::size_t stream_index = 0);
std::string load_or_build_video_frame_index(const std::filesystem::path& path,
                                            std::size_t stream_index = 0,
                                            const std::filesystem::path& cache_path = {});
std::optional<std::int64_t> indexed_frame_pts(const std::filesystem::path& path,
                                              std::size_t display_frame,
                                              std::size_t stream_index = 0);

// Presentation-order timestamps from a compact packet index. A missing result
// means that packet timestamps were absent, duplicated, reset, or otherwise
// unsafe for exact boundary seeking, so callers must decode sequentially.
struct IndexedFramePtsRange {
  std::uint64_t first_frame{};
  std::vector<std::int64_t> pts;
};

std::optional<IndexedFramePtsRange> indexed_frame_pts_range(
    const std::filesystem::path& path, std::uint64_t first_frame,
    std::uint64_t end_frame, std::size_t stream_index = 0);

}  // namespace smartcut::media
