#ifndef PROBE_H
#define PROBE_H

#include "language.h"

typedef struct {
  bool has_video;
  bool has_audio;
  bool video_duration_known;
  bool audio_duration_known;
  double video_duration;
  double audio_duration;
} ProbeResult;

typedef bool (*ProbeRunner)(const char* path, ProbeResult* result, void* context, Error* error);

typedef struct ProbeCacheEntry ProbeCacheEntry;

typedef struct {
  Arena arena;
  ProbeCacheEntry* entries;
  ProbeRunner runner;
  void* runner_context;
  size_t invocation_count;
} ProbeCache;

void probe_cache_init(ProbeCache* cache, ProbeRunner runner, void* context);
bool probe_cache_get(ProbeCache* cache, const char* path, ProbeResult* result, Error* error);
void probe_cache_destroy(ProbeCache* cache);
bool probe_run_ffprobe(const char* path, ProbeResult* result, void* context, Error* error);

#endif